【问题标题】:How to exit conversation in DialogFlow Fullfilment for an Action如何在 DialogFlow Fulfillment 中退出对话以执行操作
【发布时间】:2018-11-02 06:15:07
【问题描述】:

我有一个动作是一个简单的文字游戏,完成游戏后应该退出对话。我希望该操作支持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!");
     }
  }
  ...
}

这会导致日志错误MalformedResponse: 'final_response' must be set

我也尝试了 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);
    }
  }
  ...
}

请建议如何在游戏结束时关闭麦克风并仍然发送响应。

【问题讨论】:

    标签: dialogflow-es actions-on-google fulfillment


    【解决方案1】:

    根据记录的问题https://github.com/dialogflow/dialogflow-fulfillment-nodejs/issues/149dialogflow-fullfillment 软件包的版本0.5.0 似乎存在问题

    我尝试更新到 0.6.0,它具有重大更改,解决了我发布的当前问题,但产生了与上下文相关的问题。

    【讨论】:

      【解决方案2】:

      你试过close方法吗:

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

      【讨论】:

      • 这是正确的做法,但我遇到了问题,因为我的 dialogflow-fullfilment 版本有问题
      【解决方案3】:

      请检查您的意图的生命周期是否为 1。之后您可以使用以下命令:

      agent.end("再见");

      【讨论】:

      • 清除意图生命周期的最佳方法是什么?在调用 agent.end() 之前,我尝试执行 agent.clearOutgoingContexts(),但它仍然让麦克风打开等待响应。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多