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”
}
]
}
}
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);
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.
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.