Using Custom Javascript for Standard Responses

Hi,

I want to bring up button template for standard response where i call an array that is defined in the Dialog task using a script node.

I am not getting any response when i trigger the standard response. The standard response is triggered correctly for the utterance that is intended and i have changed the standard response with the help of Debug task

In Dialog Task, setting the context as,

context.arr = [“HTTPS Expansion”,“Difference between HTTP and HTTPS”,“Which Protocol is secure”];

In Standard Response, Listing all FAQs after not understanding your request,

Channel : Any Channel

Response : Advanced Mode

var info = context.arr;

var message = {
“type”:“template”,
“payload”:
{
“template_type”:“button”,
“buttons”:[]
}
};

for(i=0;i<info.length;i++)
{
var button = {
“type”:“postback”,
''title":info[i],
“payload”:info[i]
};
message.payload.buttons.push(button);
}

print(JSON.stringify(message));

Hi @thenaveenm,

We can use the button template for standard response, but the standard response should be configured with any specific channel. As I can see that you selected “Any Channel” in which the button template will not work on some channels, to achieve the button template
–> In the standard response add a specific channel like the “Web/Mobile” client along with “Any channel”.
–> In Any Channel use simple response.
You didn’t mention the event handlers.

I tried the above use case with the sample bot please find the below screenshots
image
image
image
image
image

Hope you understood.

Regards,
Sunil Kumar.J

1 Like

Thanks for the Explanation :+1: :+1: