Dialogflow代理可在Google模拟器中使用,在控制台和Web链接中失败 [英] Dialogflow Agent works in Google simulator, failed in console and web link

查看:129
本文介绍了Dialogflow代理可在Google模拟器中使用,在控制台和Web链接中失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Dialogflow V2 API。



在通过Google模拟器上的Actions进行测试时,所有功能都能完美运行。请找到所附图片。



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



Agent可以从用户输入中检测到适当的实体,但无法调用在webhook中声明的intent。



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





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





请在下面找到我的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!我们提供药物和药品方面的建议。今天似乎困扰您的是'?}})app.intent('QSpecific Problem',(conv,{SpecificProb})=> {conv.contexts.set('specificprob ',10,{SpecificProb:SpecificProb})conv.ask(`您以前有过这些问题吗?`)})app.intent('QRecurring',(conv,{Recurring})=> {conv.contexts.set ('recurring',10,{Recurring:Recurring})if(Recurring === Recur){conv.ask(`您是否为此服用了药物?);} else {const specProb = conv.contexts。 get('specificprob')conv.ask(`How l和你有没有这个$ {specProb.parameters.SpecificProb}?`}})exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app) 

解决方案

我实际上写信给Dialogflow的支持团队以寻求帮助。我和瑞尔(Riel)进行了交谈,后者非常有帮助。请在下面查看他的答复:


您的代理按预期在Google Simulators上工作,因为
您使用的库专门用于在Google上的操作。您一直在使用的
库是Google Node.js客户端库上的操作。



如果您还希望使用网络演示集成来进行响应,
您可以使用Dialogflow的实现库,该库具有
与使用AoG客户端库的Google Assistant集成。



您可以参考以下示例代码您的成就。 ‘使用严格’;

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

process.env.DEBUG =‘dialogflow:debug’;

exports.dialogflowFirebaseFulfillment =函数.https.onRequest((请求,响应)=> {
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


与他们联系。

I am using Dialogflow V2 API.

Everything works perfectly in testing via Actions on Google simulator. Please find pic attached.

However, when attempted using the console (right column) within Dialogflow, and also the web integration link, it does not work.

Agent is able to detect appropriate entity from user input, but unable to call intent declared in webhook. https://bot.dialogflow.com/acc64a26-8d1d-4459-8ce0-24c890acb6d7

I have attempted to post in Dialogflow forum but there was an error posting. Similar case for raising support withing Dialogflow.

Image of Google simulator agent (works):

Image of public link agent (fails):

Image of Response declared in both webhook js file and within console:

Please find part of my index.js webhook below. I am using Dialogflow's inline editor.

'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)

解决方案

I actually wrote in to Dialogflow's support team to seek help. I spoke with Riel, who was very helpful. Please see his reply below:

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's support team is very helpful and their replies are very quick. I recommend you to write in since everyone's issue is different and quite specific! You can reach them at support@dialogflow.com

这篇关于Dialogflow代理可在Google模拟器中使用,在控制台和Web链接中失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆