javascript - Dialogflow Agent 在 Google 模拟器中工作,在控制台和网络链接中失败

标签 javascript webhooks dialogflow-es fulfillment

我正在使用 Dialogflow V2 API。

通过 Actions on Google 模拟器进行测试时一切正常。请找到附件中的图片。

但是,当尝试在 Dialogflow 中使用控制台(右栏)以及 Web 集成链接时,它不起作用。

代理能够从用户输入中检测到适当的实体,但无法调用在 webhook 中声明的意图。 https://bot.dialogflow.com/acc64a26-8d1d-4459-8ce0-24c890acb6d7

我试图在 Dialogflow 论坛中发帖,但发帖出错。使用 Dialogflow 提高支持的类似案例。

Google 模拟器代理的图片(有效):

enter image description here

公共(public)链接代理的图像(失败):

enter image description here

在 webhook js 文件和控制台中声明的响应图像:

enter image description here

请在下面找到我的 index.js webhook 的一部分。我正在使用 Dialogflow 的内联编辑器。

'use strict';

const functions = require('firebase-functions')
const { dialogflow } = require('actions-on-google')

const app = dialogflow()

app.intent('Default Welcome Intent', conv => {
  conv.ask('Welcome to Zera! We provide medicine and drug advice. What seems to be bothering you today?')
})

app.intent('QSpecific Problem', (conv, {SpecificProb}) => {
  conv.contexts.set('specificprob', 10, {SpecificProb: SpecificProb})
  conv.ask(`Do you have these problems before?`)
})

app.intent('QRecurring', (conv, {Recurring}) => { 
  conv.contexts.set('recurring', 10, {Recurring: Recurring})
  if (Recurring === "Recur") { 
    conv.ask(`Have you taken any medication for this?`);    
  } else { 
    const specProb = conv.contexts.get('specificprob')
    conv.ask(`How long have you been having this ${specProb.parameters.SpecificProb}?`) 
  } 
})


exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app)

最佳答案

我实际上写信给 Dialogflow 的支持团队寻求帮助。我和 Riel 谈过,他非常乐于助人。请在下面查看他的回复:

Your agent works as expected in Actions on Google Simulator because the library you used is specifically for Actions on Google. The library you've been using is Actions on Google Node.js client library.

If you want to also use the web demo integration for your responses, you can use Dialogflow’s fulfillment library that has an integration with the Google Assistant using AoG client library.

You can refer to this example code for your fulfillment. 'use strict';

const functions = require('firebase-functions');
const { WebhookClient } = require('dialogflow-fulfillment');

process.env.DEBUG = 'dialogflow:debug';

exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });

function welcome(agent) {
let conv = agent.conv();
conv.ask('Welcome to my agent!');
agent.add(conv);
}

let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
agent.handleRequest(intentMap);
});

Dialogflow 的支持团队非常乐于助人,他们的回复非常快。我建议您写信,因为每个人的问题都不同且非常具体!您可以通过 support@dialogflow.com 联系他们

关于javascript - Dialogflow Agent 在 Google 模拟器中工作,在控制台和网络链接中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51112543/

相关文章:

javascript - MySQL 使用 Ajax 返回表名而不是值

javascript - 如何在 webapp 中执行此拉动刷新?

c# - SimpleInjector 和 Microsoft Webhook ASP.Net Webhooks

json - 解析内容丰富的 Webhook(自定义 JSON 类型)

node.js - Dialogflow 通过 NodeJS 传递参数

Google Dialogflow V2 的 C# 库

javascript - 使用 AJAX 从 JSON 文件中检索数据

javascript - 每次动画结束后完全删除元素。 - 仅使用 CSS

node.js - Stripe webhook 错误 : No signatures found matching the expected signature for payload

automated-tests - DialogFlow 自动化测试