简体   繁体   English

如何在 DialogFlow Fullfilment 中退出对话以进行操作

[英]How to exit conversation in DialogFlow Fullfilment for an Action

I have an action which is a simple word game and upon completing the game should exit the conversation.我有一个简单的文字游戏动作,完成游戏后应该退出对话。 I want the action to support Google Assistant and speaker based devices ( mobile phone etc) so i am handling the intent in a general fashion.我希望该操作支持Google Assistant和基于扬声器的设备(手机等),因此我正在以一般方式处理该意图。

const {WebhookClient} = require('dialogflow-fulfillment');
...
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
  ...
  function answerIntent(agent) {
     if (gameShouldEnd) {
       agent.end("Your score is 3/5. Cheers! GoodBye!");
     }
  }
  ...
}

This results in log error MalformedResponse: 'final_response' must be set这会导致日志错误MalformedResponse: 'final_response' must be set

I tried the conv api too and that results in the same error.我也尝试了 conv api,结果是同样的错误。

const {WebhookClient} = require('dialogflow-fulfillment');
...
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
  ...
  function answerIntent(agent) {
    if (gameShouldEnd) {
      let conv = agent.conv();
      conv.tell("Your score is 3/5. Cheers! GoodBye!");
      agent.add(conv);
    }
  }
  ...
}

Please suggest how to close the Mic when the game ends and still sends a response.请建议如何在游戏结束时关闭麦克风并仍然发送响应。

Seems there is an issue with version 0.5.0 of the dialogflow-fullfillment package according to the issue logged https://github.com/dialogflow/dialogflow-fulfillment-nodejs/issues/149似乎没有与版本的问题0.5.0中的dialogflow-fullfillment包根据问题记录https://github.com/dialogflow/dialogflow-fulfillment-nodejs/issues/149

I tried updating to 0.6.0 which has breaking changes which solved the current question i posted but created context related problems.我尝试更新到0.6.0 ,它具有重大更改,解决了我发布的当前问题,但创建了与上下文相关的问题。

您是否尝试过close方法:

  conv.close("Your score is 3/5. Cheers! GoodBye!");

please check if the lifespam of your intent is 1. After that you can use the command bellow:请检查您的意图的生命垃圾邮件是否为 1。之后您可以使用以下命令:

agent.end("bye"); agent.end("再见");

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

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