sunny-green
sunny-green2y ago

Handling buttons with a custom frontend (Dialog API)

Hi, i have deployed my agent to a custom website. I am having a hard time trying to make buttons work. More specifically on what should i send to voiceflow when a button is pressed? For example if a button object looks like this: { "name": "I would like to ask a question", "request": { "type": "path-rs1rm39g6", "payload": { "label": "I would like to ask a question", "actions": [] } } } When the button is pressed, what do i include in the "body" of the API call. If i construck the body like this, it just replys with the "I would like to ask a question" as a text but doesnt go down the path that is attached to the button. const body = { uniqueId: uniqueId, config: { tts: true, stripSSML: true }, action: { type: "text", payload: button.request.payload}, };
1 Reply
Tico | Voiceflow Assistant
To make buttons work in your custom frontend using the Dialog API, you need to send a specific type of request when a button is pressed. Instead of sending a "text" type action with the button's label as the payload, you should send a request that matches the intended action or path you want to trigger in your Voiceflow project. Here's a general approach: - Use the "type" and "payload" from your button's "request" object to construct the body of the API call. - Ensure the "type" in your action matches the type of interaction you want to trigger, such as navigating a path or submitting a response. - The "payload" should contain the necessary information or data that the action requires to be executed properly. If the button is meant to navigate a specific path or trigger a specific action in your Voiceflow project, make sure the action type and payload in your API call body accurately reflect that. This way, when the button is pressed, the API call will instruct your Voiceflow project to proceed according to the button's intended function, rather than just treating the button press as a simple text input. For more detailed examples and guidance on constructing API calls and handling different types of requests, you can refer to the Voiceflow documentation and API examples: - Voiceflow API Reference - Voiceflow Custom Channel API Documentation

Did you find this page helpful?