Dialogflow selecting from list

Viewed 320

I am creating a chat bot which mimic the ivr in call. So for example when user say hi (welcome intent) I send a message like please select an option from below.

 1, 2, 3, 4, 5 (every option gives user a unique information)

then I create a follow up intent of welcome intent as Default welcome intent select.number

in this situation when user type 2 I give him another set of options. choose the option from below

a, b, c, d, e, f

Now for e.g user type a what intent I need to create on dialogflow to process further.

I am intercepting the user reply using my python script

and calling dialogflow from python script.

 reply, intent, parameter = fetch_reply(x, session_id)

 def fetch_reply(query, session_id):
    response = detect_intent_from_text(query, session_id)

    inetnt = response.intent.display_name

    # print(inetnt)

    # print('-----')
    value = 0.0
    try:
        if response.parameters['number']:
            value = response.parameters['number'][0]

    except ValueError:
        print('no value found')

    return response.fulfillment_text, inetnt, value

From here I can simply use if else if user select a and then send him reply but is there anything that dialogflow provide which can I use to give answers to user inputs.

Also there is a option for user like press 0 to go back to main menu. How can I handle it?

If you want me to provide any other info please let me know.

1 Answers

One possible way is to create Intent for each possible options {1, 2, 3 ..a, b, c} and include them in as Suggestion after each reply. For example, when the user says "Hi" you can respond as "Hello" with 1, 2, 3 ... as selectable suggestions. And when user selects 1 then a, b, c... appear as Suggestions. Here's some code that can help:

.
.
.
const {Card, Suggestion} = require('dialogflow-fulfillment');
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
    const agent = new WebhookClient({request, response });
    function welcome(agent){
    agent.add(`Hello!`);
    agent.add(new Suggestion(`1`));
    agent.add(new Suggestion(`2`));
    agent.add(new Suggestion(`3`));
    }
.
.
.
Related