【发布时间】:2020-09-17 10:39:52
【问题描述】:
我有一个非常简单的操作,它只是给了我一些状态,然后我想结束它,没有对话,没有别的,只是获取状态并结束它。现在我正在这样做:
agent.add(message1);
agent.add(message2);
agent.end('done');
我也尝试过(正如您将在下面的代码中看到的那样,只是在做agent.end(completeMessage);,但助手一直在等我做更多事情,我的行动并没有结束。
我制作了一个完全简单的示例来演示,test intent 是具有end() 调用的示例:
代码:
'use strict';
const functions = require('firebase-functions');
const { WebhookClient } = require('dialogflow-fulfillment');
const { Card, Suggestion } = require('dialogflow-fulfillment');
const fetch = require("node-fetch");
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
function welcome(agent) {
agent.add(`Welcome to my agent!`);
}
function fallback(agent) {
agent.add(`I didn't understand`);
agent.add(`I'm sorry, can you try again?`);
}
function testIntent(agent) {
agent.end('done');
}
intent name
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Default Fallback Intent', fallback);
intentMap.set('test intent', testIntent);
agent.handleRequest(intentMap);
});
当我致电test intent 时,任何人都知道如何让我的行动完全结束?
【问题讨论】:
-
您能清楚地知道您使用的是哪个库吗? (显示 require 和 package.json 文件)
-
我只是在使用他们的 DialogFlow 内联编辑器,不知道他们的 package.json 长什么样?但我已经添加了要求行。
-
我应该提一下,我几天前才开始执行此操作,所以我假设它使用的是内联编辑器的最新默认值。
-
您能否更新问题以准确说明在调用 end 时发生了什么?有什么记录吗?你能告诉 Intent Handler 的其余部分发生这种情况吗?
-
要添加我的代码,希望这能解释问题。基本上,一旦我使用 Google Home 设备给
testIntent打电话,它就会坐在那里等待更多,并且每隔一段时间就会说对不起,我听不懂或类似的话,最终它放弃了。我听说done,所以end方法有效。
标签: dialogflow-es actions-on-google