Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 650
Twister013 Avatar asked Oct 16 '17 09:10

Twister013


2 Answers

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

like image 83
matthewayne Avatar answered Oct 09 '22 03:10

matthewayne


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"
            }
        ]
    }
like image 31
Rana Avatar answered Oct 09 '22 04:10

Rana