[英]How do I end my custom action on assistant?
I have a very simple action that just gives me some status and then I want to end it, no conversation, nothing else, just get the status and end it.我有一个非常简单的操作,只是给了我一些状态,然后我想结束它,没有对话,没有别的,只是获取状态并结束它。 Right now I'm doing this:
现在我正在这样做:
agent.add(message1);
agent.add(message2);
agent.end('done');
I've also tried (as you'll see on the code below just doing agent.end(completeMessage);
but assistant keeps waiting for me to do more, my action doesn't end.我也尝试过(正如您将在下面的代码中看到的那样,只是在做
agent.end(completeMessage);
但助手一直在等待我做更多事情,我的行动并没有结束。
I've made a totally simple sample to demostrate, test intent
is the one that has the end()
call:我制作了一个完全简单的示例来演示,
test intent
是具有end()
调用的意图:
Code:代码:
'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);
});
Anyone have any ideas of how I can make my action just totally end when I called test intent
?当我调用
test intent
时,任何人都知道如何让我的行为完全结束?
If you are using the dialogflow-fulfillment library with Actions on Google, you can only have two simple responses (text or SSML strings).如果您将 dialogflow-fulfillment 库与 Actions on Google 一起使用,则只能有两个简单的响应(文本或 SSML 字符串)。 Since your code calls
agent.end()
after two messages have already been set, it may be ignored.由于您的代码在设置了两条消息后调用
agent.end()
,因此它可能会被忽略。
Instead you can call it as相反,您可以将其称为
agent.add(message1);
agent.end(message2);
The documentation for agent
is for the WebhookClient object. agent
的文档适用于WebhookClient object。 If you want to skip the library, there is also the webhook response JSON documentation.如果你想跳过这个库,还有webhook 响应JSON 文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.