Multiple Responses with Dialogflow (aka Api.ai)

10,793

Solution 1

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

Solution 2

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"
            }
        ]
    }
Share:
10,793
Twister013
Author by

Twister013

Updated on June 13, 2022

Comments

  • Twister013
    Twister013 about 2 years

    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?

  • RAHUL VISHWAKARMA
    RAHUL VISHWAKARMA over 4 years
    Hey hi i am trying the same but for me i am not getting two responses back to back but i am getting one among the two. Can you please help me with that.