简体   繁体   English

如何在 Dialogflow V1 中触发不同的 Intent

[英]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?我很清楚 Dialogflow V1 将于 2020 年 5 月底弃用。但是,我想知道是否有人知道如何通过 webhook fulfillment 触发 Dialogflow 中的意图? 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.现在,我有 javascript function 正在发送带有上下文的 webhook 响应。 I put that context into my dialogflow intent context input but when I run the agent, the intent is never triggered.我将该上下文放入我的 dialogflow 意图上下文输入中,但是当我运行代理时,从未触发该意图。

Javascript code: Javascript 代码:

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.这是我在 dialogflow 中的上下文上下文的图片最近遇到了困难,希望得到任何帮助/解释,以便我可以继续前进。

First, remember that Intents represent what the user says or does and not how you react to them.首先,请记住 Intents 代表用户说的或做的,而不是你对它们的反应。 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.多个 Intent 处理程序都可以调用同一个 function 以相同的方式响应。

Setting a Context does not automatically trigger an Intent.设置 Context 不会自动触发 Intent。 Setting the Input Context for an Intent restricts under what conditions that Intent can be triggered.为 Intent 设置输入上下文限制了可以触发 Intent 的条件。 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 .只需 从您的 webhook 调用一个事件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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