简体   繁体   English

如何结束我对助手的自定义操作?

[英]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.

相关问题 如何使用 android 深度链接和谷歌助手的自定义 DialogFlow 操作? - How to use android deeplink with custom DialogFlow action for google assistant? 我如何部署我的谷歌助手机器人以便每个人都可以使用它? - How do i deploy my google assistant bot so that everyone can use it? 如何在 Google 助理中获取我的设备的时区? - How can I get the timezone my device in Google Assistant? 如何用 Assistant SDK 操作替换现有的 DialogFlow 操作 - How to replace an existing DialogFlow action with Assistant SDK action Dialogflow 中的 Google 助理测验操作 - Google Assistant quiz action in Dialogflow 在 Dialogflow 中,如何使用我的 webhook 将参数设置为自定义值(不想询问用户) - In Dialogflow, how do I set parameter to a custom value with my webhook (Dont want to ask the user) 从助手动作到安卓应用的深层链接 - deeplinking from assistant action to android app Google Assistant Action Dialogflow 集成不再起作用 - Google Assistant Action Dialogflow integration no longer working 如何在对话期间强制谷歌动作切换语言? - How do I force google action to switch the language during conversation? 如何从 Google Assistant 深度链接应用程序? - how can I deeplink an app from Google Assistant?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM