How to "click" a button w/ Dialog Manager SDK?

Hi there–

I’m having a problem trying to click/tap a button using the REST API

  • I started a new project in Voiceflow and am using the “built-in”/starter default conversation flow, ex

What I expected

  1. POST “launch” request to start the conversation from the beginning

  2. Receive back buttons

  3. Send a text “text” event with one of the button labels/text

What happened

  • I “launch” the chat with one request, however, attempting to follow up with.subsequent “text” request (that include the button label) leads to a no-match.

  • it appears just entering the “text” as a payload for a button isn’t the right way to tap a button

Is there a proper way to “tap” button from REST API in Voiceflow?

Steps taken so far

Step 1: “launch” the chat from beginning

POST https://general-runtime.voiceflow.com/state/user/my_terrific_user/interact

Body:

{
     "action": {
          "type": "launch"
     },
     "config": {
          "tts": false,
          "stripSSML": true,
          "stopAll": true
     }
}

This returns the buttons/labels as expected

Step 2: Try to “invoke” button

The 2 buttons have the labels (1) “Click here!” or (2) “Or, click here!”, attempting to send either of those as text results in re-prompt/won’t follow the path

POST https://general-runtime.voiceflow.com/state/user/my_terrific_user/interact

Body:

{
     "action": {
          "type": "text",
          "payload": "Click here!"
     },
     "config": {
          "tts": false,
          "stripSSML": true,
          "stopAll": true
     }
}

Should the action type be something other than just text?

Will update this thread if any lessons/revelations

button responses should be like this.

  {
    "type": "choice",
    "payload": {
      "buttons": [
        {
          "name": "red",
          "request": {
            "type": "path-xm38q3gr5",
            "payload": {
              "label": "red"
            }
          }
        },
        {
          "name": "blue",
          "request": {
            "type": "path-rj39r3g79",
            "payload": {
              "label": "blue"
            }
          }
        },
        {
          "name": "yellow",
          "request": {
            "type": "path-ea39t3gk6",
            "payload": {
              "label": "yellow"
            }
          }
        }
      ]
    }
  }

you need to request with the type defined with each button like this.

$ curl  --request POST "https://general-runtime.voiceflow.com/state/user/$USER_ID/interact" \
      --header "Authorization: $API_KEY" \
      --header 'Content-Type: application/json'  \
      --data-raw "{
            \"request\": { \"type\": \"path-ea39t3gk6\", \"payload\": { \"label\": \"yellow\"} }
     }"

in this case, payload seems optional.

1 Like

Bingo that’s it, thanks @kun432! Just confirmed you do NOT need payload/text

So to invoke VF buttons…

  1. “Launch”
    POST https://general-runtime.voiceflow.com/state/user/steve/interact
{
     "action": {
          "type": "launch"
     },
     "config": {
          "tts": false,
          "stripSSML": true,
          "stopAll": true,
          "excludeTypes": [
               "block",
               "debug",
               "flow"
          ]
     }
}
  1. Tap button (note type is just path name, no payload required)
{
     "action": {
          "type": "path-erm34gu"
     },
     "config": {
          "tts": false,
          "stripSSML": true,
          "stopAll": true,
          "excludeTypes": [
               "block",
               "debug",
               "flow"
          ]
     }
}

This is initial response from Launch req (note the “type” fields w/ names like ‘path-nc1234’)