简体   繁体   English

在使用内联编辑器实现的 DialogFlow Messenger 中,setContext() 干扰 setFollowupEvent()

[英]in DialogFlow Messenger using inline editor for fulfillment, setContext() is interfering with setFollowupEvent()

I have an intent for password reset within DialogFlow using a one time password.我打算在 DialogFlow 中使用一次性密码重置密码。 You tell DF that you want to reset your password, it asks for your LAN ID, it sends an email with a short code to your email of record, you enter the code, and if it's correct, you can reset your password.您告诉 DF 您要重置密码,它会询问您的 LAN ID,它会向您的记录 email 发送带有短代码的 email,您输入代码,如果正确,您可以重置密码。

After you give your LAN ID, it sets context and triggers a follow up event "verifyCode" which prompts you for the code and then compares it to the stored value.在您提供 LAN ID 后,它会设置上下文并触发后续事件“verifyCode”,该事件会提示您输入代码,然后将其与存储的值进行比较。 If correct, then it sets context and triggers another follow up event.如果正确,那么它会设置上下文并触发另一个后续事件。

It works perfectly in the web integration and the "try it now" box, all the way through, but not in the DialogFlow Messenger integration, where it looks like setting context interferes with the setFollowupEvent function, although it does send the email. It works perfectly in the web integration and the "try it now" box, all the way through, but not in the DialogFlow Messenger integration, where it looks like setting context interferes with the setFollowupEvent function, although it does send the email. I have tested it and if I disable the context setting the follow up event fires, but that's not helpful.我已经对其进行了测试,如果我禁用上下文设置,则会触发后续事件,但这没有帮助。

Below is the relevant code and console values.以下是相关代码和控制台值。

  function sendOneTimePassword(agent){
    var lanIdParam = request.body.queryResult.outputContexts[0].parameters.lanId;
    var lanId = lanIdParam.toLowerCase();
    var user = userList[lanId]; 
    if (user == null){ 
      agent.add("We could not find a user with that lan ID. Please try again.");
    } else {
    var emailAddress = user.email; 
    var code = generateOneTimePassword(); 
    var deadline = generateExpirationTime();
    sendResetMail(emailAddress, code);
    agent.add("Just a moment, please...");  
      console.log("code = "+code);
    agent.setContext({
            "name": 'projects/BOTNAME/agent/sessions/STRINGOFTEXT/contexts/verify',
            "lifespan": 5,
            "parameters":{"code": code, "deadline": deadline, "lanId": lanId}
    });  
    agent.setFollowupEvent("validateCode");  
    } 
  }

If I remove the setContext method above, the follow up event fires, but then I have no context.如果我删除上面的 setContext 方法,则会触发后续事件,但是我没有上下文。

第一意图

跟进意图

I can see that you are attempting to trigger a verification event [1] but it sometimes fails.我可以看到您正在尝试触发验证事件 [1],但有时会失败。

This may be due to how 'setFollowupEvent' works.这可能是由于“setFollowupEvent”的工作方式。 As you can see here [2], a similar issue where 'setFollowupEvent' caused 'agent.add' to be skipped over, therefore it may not be triggering as you would expect it to.正如您在此处看到的 [2],类似的问题是“setFollowupEvent”导致“agent.add”被跳过,因此它可能不会像您期望的那样触发。

Instead of setting context, events may instead require event parameters to be set [3].代替设置上下文,事件可能需要设置事件参数 [3]。

Sample Node.js code for how to properly use events can be seen here [4].有关如何正确使用事件的示例 Node.js 代码可以在此处查看 [4]。

[1]https://cloud.google.com/dialogflow/docs/events-overview#config [1]https://cloud.google.com/dialogflow/docs/events-overview#config

[2] https://github.com/dialogflow/dialogflow-fulfillment-nodejs/issues/102#issuecomment-410088688 [2] https://github.com/dialogflow/dialogflow-fulfillment-nodejs/issues/102#issuecomment-410088688

[3] https://cloud.google.com/dialogflow/docs/events-custom#webhook [3] https://cloud.google.com/dialogflow/docs/events-custom#webhook

[4] https://github.com/dialogflow/dialogflow-fulfillment-nodejs/blob/master/test/webhook-v2-test.js#L348 [4] https://github.com/dialogflow/dialogflow-fulfillment-nodejs/blob/master/test/webhook-v2-test.js#L348

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

相关问题 使用 DialogFlow Messenger 实现中的“agent.setFollowupEvent(targetIntentEventName)”方法跳转到另一个意图 - Jumping over to another intent by using the 'agent.setFollowupEvent(targetIntentEventName)' method in the DialogFlow Messenger fulfillment Dialogflow 实现内联编辑器 api 请求 - Dialogflow fulfillment inline editor api request 我可以在 Inline Fulfillment Dialogflow 编辑器中跨对话存储计数器吗? - Can I store a counter across conversation in Inline Fulfillment Dialogflow editor? Dialogflow:setFollowupEvent 在“then”内不起作用 - Dialogflow: setFollowupEvent not working inside 'then' 如何使用DialogFlow在线编辑器从Firebase检索数据 - How to retrieve data from Firebase using DialogFlow Inline Editor 使用对话框流在内联编辑器之外创建不可知的卡片 - Creating agnostic cards outside inline editor using dialogflow 内联编辑器中的对话流捕获实体 - dialogflow capturing entity in inline editor 如何使用 nodejs 在 Dialogflow 中处理 webhook 实现 - How to handle webhook fulfillment in Dialogflow using nodejs 是否可以在dialogflow内联编辑器中使用外部库? - Is it possible to use external libraries in the dialogflow inline editor? 如何从 IDE 而不是内联编辑器编写实现代码? - How to write fulfillment code from an IDE instead of the inline editor?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM