Trigger one intent at the end of another
Asked Answered
A

3

1

Sorry - very newbie question. I have a number of separate intents (let’s call them intent1, intent2, intent3, etc) which constitute a basic FAQ chatbot.

I want users to be able to trigger these independently but I’d also like to guide them from one to the next. So I’d like to be able, at the end of responding to intent1 to ask ‘would you like to hear about intent2 or ask another question’ and respond appropriately.

So far I’ve not messed with node backends etc so there is a possibility the answer lies there.

Adali answered 1/8, 2019 at 16:6 Comment(0)
S
1

okay, I am late here! Yes, It is possible with the event. I have recently done this.

function helloIntent(agent){
  agent.add("Hi, how are you ?");
  agent.setFollowupEvent({ name: 'NextIntentEvent', parameters: {} }); // this will do the trick
}    

app.js

    let intentMap = new Map();
    intentMap.set("Hello Intent", helloIntent);

NextIntentEvent should be an event name defined in the intent that you want to trigger.

some code removed for brevity

Spoofery answered 15/1, 2020 at 9:11 Comment(0)
D
1

You don't need to use a fulfillment webhook, but it does make things somewhat easier.

First, remember that Intents handle what the user says, and not what you do with that. Dialogflow's responses appear to suggest they do, but once you get into more complicated interactions (where two different things from the user need to respond the same way), you find that the response section becomes less useful, and you should store your responses in code.

Those responses should include the prompt about the next question.

During fulfillment you should also set a Context (and possibly clear older contexts) to keep track of which question you are suggesting for them next.

This way - the next response will be triggered by two possible Intents:

  • One that directly asks a question.

    In these cases, you'll use the Intent or action name to determine which question was asked, and provide an answer (and followup prompt).

  • One that responds "yes".

    For this, you'll get the Context that includes information about the question you prompted them for, and provide that answer (and followup prompt).

While the "Followup Intent" feature sounds tempting, it is likely not what you want to use, since it does not allow multiple ways to access it and forces a very narrow path.

You may also wish to take a look at Thinking For Voice: Design Conversations, Not Logic for more about designing your conversation (and how to model it in Dialogflow, in a followup article).

Duiker answered 2/8, 2019 at 10:31 Comment(0)
S
1

okay, I am late here! Yes, It is possible with the event. I have recently done this.

function helloIntent(agent){
  agent.add("Hi, how are you ?");
  agent.setFollowupEvent({ name: 'NextIntentEvent', parameters: {} }); // this will do the trick
}    

app.js

    let intentMap = new Map();
    intentMap.set("Hello Intent", helloIntent);

NextIntentEvent should be an event name defined in the intent that you want to trigger.

some code removed for brevity

Spoofery answered 15/1, 2020 at 9:11 Comment(0)
V
0

If you want to make chain of conversation there are few options for that.

  • Slot filling

    Here you need to add your questions as prompt and you can make that optional so if user wants to make the conversation they proceed by answering that question. Example

  • Contexts

    You can set the follow-up question with contexts, Example

  • Events

    Events are something that you can trigger from your web hook once you send the response of your current question, To trigger the event, Example

POST Authorization: Bearer <AccessToken>
https://dialogflow.googleapis.com/v2/projects/<ProjectID>/agent/sessions/<SessionID>:detectIntent
{
        "queryInput": {
                "event": {
                        "name": "event-name",
                        "parameters": {
                                "parameter-name-1": "parameter-value-1",
                                "parameter-name-2": "parameter-value-2",
                                ...
                        },
                        "languageCode": "en-US"
                }
        }
}
Variance answered 2/8, 2019 at 3:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.