sunny-green
sunny-green15mo ago

Dynamic buttons using Custom action

Hi, I am tring to create severals buttons dynamicly using custom action. Here is JSON that I tried : But I can't find the proper JSON for Buttons { "type": "choice", "payload": { "buttons": [ { "name": "Label A", "request": { "type": "path-9x2sh3elw", "payload": { "label": "Label A", "actions": [] } } }, { "name": "Label B", "request": { "type": "path-dm3533een", "payload": { "label": "Label B", "actions": [] } } } ] } } No buttons are being rendered.
2 Replies
Tico | Voiceflow Assistant
In Voiceflow, buttons can be dynamically rendered using the choice trace. Here's an example of how to format your choice trace for buttons:
{
"type": "choice",
"payload": {
"buttons": [
{
"name": "Button A",
"request": {
"type": "eventA",
"payload": {
"label": "example"
}
}
},
{
"name": "Button B",
"request": {
"type": "eventB",
"payload": {
"label": "another-example"
}
}
}
]
}
}
{
"type": "choice",
"payload": {
"buttons": [
{
"name": "Button A",
"request": {
"type": "eventA",
"payload": {
"label": "example"
}
}
},
{
"name": "Button B",
"request": {
"type": "eventB",
"payload": {
"label": "another-example"
}
}
}
]
}
}
In this example: - Each button has a name which is the label displayed on the button. - The request object contains a type which should match the event type you are listening for in your Voiceflow project. - The payload within the request can contain any additional data you want to pass along with the button click event. Make sure that your Voiceflow project is set up to handle these events. For instance, you should have a next command listening for eventA and eventB:
next: {
listen: true,
to: [
{ on: 'event.type', event: 'eventA', dest: 'path-A' },
{ on: 'event.type', event: 'eventB', dest: 'path-B' }
],
defaultTo: 'path-C'
}
next: {
listen: true,
to: [
{ on: 'event.type', event: 'eventA', dest: 'path-A' },
{ on: 'event.type', event: 'eventB', dest: 'path-B' }
],
defaultTo: 'path-C'
}
This setup ensures that when a button is clicked, the corresponding event is triggered, and the flow proceeds to the designated path. For more detailed information, you can refer to the Voiceflow documentation.
sunny-green
sunny-greenOP15mo ago
I can't see the buttons with this json

Did you find this page helpful?