问题
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)
回答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
来源:https://stackoverflow.com/questions/51112543/dialogflow-agent-works-in-google-simulator-failed-in-console-and-web-link