2

我正在使用 Dialogflow V2 API。

一切都在通过 Google 模拟器上的 Actions 进行测试时完美运行。请找到附上的图片。

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

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

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

谷歌模拟器代理的图片(作品):

在此处输入图像描述

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

在此处输入图像描述

在 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! 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)

4

1 回答 1

1

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

于 2019-04-15T09:31:46.400 回答