简体   繁体   中英

How to Trigger a Different Intent in Dialogflow V1

I am well aware that Dialogflow V1 is being deprecated at the end of May 2020. However, I am wondering does anybody know how to trigger an intent in Dialogflow via webhook fulfillment? I have google searched the past few days looking everywhere and there seems to be a consensus that while events are available to trigger intent matching, they shouldn't be used. Right now, I have javascript function that is sending a webhook response with context out. I put that context into my dialogflow intent context input but when I run the agent, the intent is never triggered.

Javascript code:

function createTextResponse() {

    let response = {
        "speech": "Nice! Let's keep going.",
        "displayText": "displayed response",
        "contextOut": [
            {
              "name": "trythis",
              "lifespan": 5
            }
          ]
    }    

    return response;
}

Here is a picture with my contexts contexts in dialogflow Been having a hard time with this lately and would appreciate any help/explanation in order so that I can move forward.

First, remember that Intents represent what the user says or does and not how you react to them. So in general it doesn't make sense to "trigger an Intent". This is why the advice usually is to not use events - while they do make some sense in limited cases, those cases usually represent a user event and not your program trying to do something.

If you want your fulfillment to do something - just do it. Multiple Intent handlers can all call the same function to respond the same way.

Setting a Context does not automatically trigger an Intent. Setting the Input Context for an Intent restricts under what conditions that Intent can be triggered. While it still requires one of the training phrases to be matched, it also requires that all the Input Contexts be active.

This is exactly what events are provided for. Just invoke an event from your webhook .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM