mac389
mac389

Reputation: 3133

How to trigger action from Chip Suggestions in Dialog Flow?

I want to create a ChatBot where the user (mostly) selects from Chip Suggestions. I can't understand how to construct the Chip Suggestions in Flask.

The following yields null:

@app.route('/webhook', methods=['POST'])
def webhook():
    two_chips = jsonify(fulfillment_text="This message is from Dialogflow's testing!",
       fulfillment_messages=[
           {
               "payload": {
                  "richContent": [
                    [
                      {
                        "type": "chips",
                        "options": [
                          {
                            "text": "HIV Testing Schedule",
                            "link": "https://example.com" #Links work, but I don't want links
                          },
                          {
                            "link": "https://example.com",
                            "text": "PreP"
                          }
                        ]
                      }
                    ]
                  ]
                }
            }])
     return two_chips

Ideally, the button clicking would trigger a new action/intent and the bot would respond with more specific text. I.e. what should I replace the link field with?

This link suggests that there is a replyMetadata field, but that seems to be specific to kommunicate, not Google?

I looked flask-dialogflow, but the documentation is too sparse and conflicting for me.

Upvotes: 1

Views: 1859

Answers (2)

Devashish Mamgain
Devashish Mamgain

Reputation: 2097

Are you looking for suggestion chips like the one below? enter image description here

The sample payload that you have shared is from Kommunicate [Disclaimer: I am founder @kommunicate] and it is specific to Kommunicate platform for link buttons. Seems like what you are looking for is direct buttons/suggestion chips, here is the right doc from Kommunicate for this: https://docs.kommunicate.io/docs/message-types#suggested-replies As Kommunicate supports omnichannel and multiple platforms web, android, iOS, whatsapp, LINE, facebook, etc so Kommunicate supports its own rich message payload along with Dialogflow specific payload.

For Dialogflow specific suggestion chips, use:

{
  "payload": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "These are suggestion chips."
            }
          },
          {
            "simpleResponse": {
              "textToSpeech": "Which type of response would you like to see next?"
            }
          }
        ],
        "suggestions": [
          {
            "title": "Suggestion 1"
          },
          {
            "title": "Suggestion 2"
          },
          {
            "title": "Suggestion 3"
          }
        ],
        "linkOutSuggestion": {
          "destinationName": "Suggestion Link",
          "url": "https://assistant.google.com/"
        }
      }
    }
  }
}

Source: https://developers.google.com/assistant/conversational/df-asdk/rich-responses#df-json-suggestion-chips

Upvotes: 1

Jeffrey Williams
Jeffrey Williams

Reputation: 99

Those chips which require a link, should be replaced by a list 1. List items are clickable and trigger an intent via events 2 (to make the bot respond with more specific text).

To get started, update your code to use lists and then add the event name you'd like to trigger in your code. Then add that same event name to the Events section of the intent you want to trigger.

Here is an example of what that can look like. I tested a list and clicked on a list item to triggered a test event that ran my test intent:

A list sample and the result from clicking on a list item

Upvotes: 2

Related Questions