Twister013
Twister013

Reputation: 183

Multiple Responses with Dialogflow (aka Api.ai)

I'm trying to create a chatbot which once "greetings" process is done goes on and initiate a new topic without any user query. It has to be something like the following:

bot : hello

user : hello

bot : how old are you?

user : 35

bot : Great.

bot : Let's talk about politics. Are you american?

Until the "great" line everything works but then I cannot trigger the event that will prompt the line "Let's talk about politics...."

The doc is vague, can I do this without webhooks? And if not, how would a webhook like this look like?

Upvotes: 6

Views: 12364

Answers (2)

Rana
Rana

Reputation: 31

Yes, you can define multiple responses. If you are planning to use Facebook Messenger platform to show the responses you can use the code below. Change "Response 1" and "Response 2" to your desired text and dump the my_result object as json and return it back. You need to change the "platform" if you want to use any other platforms than messenger.

my_result = {
        "fulfillmentMessages": [
            {
                "text": {
                    "text": [
                    "Response 1"
                    ]
                },
                "platform": "FACEBOOK"
            },
            {
                "text": {
                    "text": [
                        "Response 2"
                    ]
                },
                "platform": "FACEBOOK"
            }
        ]
    }

Upvotes: 3

mattcarrollcode
mattcarrollcode

Reputation: 3469

You can define multiple responses in Dialogflow's console as seen in the screenshots below by clicking the Add Message Content button in the response section of the intent you'd like to add the response to. You can also send multiple messages for some platforms (depending on platform feature availability) with webhook fulfillment using rich messaging responses documented here: https://dialogflow.com/docs/rich-messages


Go to the response section of the intent you'd like to add a 2nd response to: enter image description here Click ADD MESSAGE CONTENT and select Text response: enter image description here Enter you second message in the second text box provided: enter image description here

Upvotes: 5

Related Questions