Button template

i amusing button template json. On bot on click of the button , i want to show the same on UI, how could i proceed with that??How to capture clicked button text?

var message={
“type”: “template”,
“payload”:
{
“template_type”: “button”,
“text”: “What do you want to do next?”,
“buttons”:
[{
“type”: “web_url”,
“title”: “Show Website”,
“url”: “https://petersapparel.parseapp.com
},
{
“type”: “postback”,
“title”: “Start Chatting”,
“payload”: “USER_DEFINED_PAYLOAD”
}
]
}
}

i want to capture start chatting selected

Hello @sureka505,

Please review the community post below. It should provide you with the information requested.

Thanks for your reply.
But i want to capture that selected button value in a variable to check the condition.It is just getting displayed is fine.But want to capture in session variable.

i would like to do something like below on button select “button 1” payload should display one more button/quick reply template.

“payload”: {
“template_type”: “button”,
“text”: “What do you want to do next?”,
“buttons”:
[
{
“type”: “postback”,
“title”: “Start Chatting”,
“payload”: “USER_DEFINED_PAYLOAD”
}
]
}

var info = [“Button1”, “Button2”, “Button3”];
var message = {
“type”: “template”,
“payload”: {
“template_type”: “button”,
“text”: “Button Template Label”,
“subText”: “Button Template Description”,
“buttons”: []
}
};
for (i = 0; i < info.length; i++) {
// if the button is to send back text to platform
var button = {
“type”: “postback”,
“title”: info[i],
“payload”: {
“template_type”: “button”,
“text”: “What do you want to do next?”,
“buttons”:
[
{
“type”: “postback”,
“title”: “Start Chatting”,
“payload”: “USER_DEFINED_PAYLOAD”
}
]
}
};

/* Uncomment this if the button is to redirect to url
 var button = {
 "type":"web_url", // type can be "postback" if
 "url":"URL_TO_REDIRECT",
 "title":buttons[i]
 };
 */

message.payload.buttons.push(button);

}
print(JSON.stringify(message));

could you please help me on this.

Hi @sureka505,

We infer from your explanation that you would like to display a button template and then based on the selection, you would like to display another buttons group to the user.

Let us know if we understood your requirement.

Regards,
Yoga Ramya.

yes.you are right.would like to display another buttons tempalte group.On second button group user click should display post back message.

Hi @sureka505,

For the button template 1, based on the selection(as per your requirement) made make a transition to another entity node that displays another button template.

This should allow you to achieve your requirement.

Let us know your thoughts on implementing this.

Regards,
Yoga Ramya.

Based on selection payload value we are not able to capture or selected value we are not able to capture.

@sureka505,

You can capture the selected button name by sending the button name in the payload of the button object.

image

Regards,
Yoga Ramya.

please let me know how can we give condition if selected value==“button1” then print “button1 is selected” dynamically