【发布时间】:2018-04-08 17:37:58
【问题描述】:
我有一个具有 3 个意图的对话流助手应用程序。第一个意图向用户询问来自谷歌的位置和名称详细信息。我正在使用 webhook 来实现这一意图。我能够提取用户信息名称和位置,但是在显示 webhook 的输出后,它正在退出流程。但它应该将位置参数传递给下一个意图并保持流程。谁能帮助我如何阻止助手退出? 这是网络钩子代码
'use strict';
const functions = require('firebase-functions');
const DialogflowApp = require('actions-on-google').DialogflowApp;
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const requestPermission = (app) => {
app.askForPermissions('To report ', [app.SupportedPermissions.NAME, app.SupportedPermissions.DEVICE_PRECISE_LOCATION]);
};
const userInfo = (app) => {
if (app.isPermissionGranted()) {
const address = app.getDeviceLocation().coordinates;
const name = app.getUserName().givenName;
if (name) {
app.tell(`You are name ${name}`);
}
else {
// Note: Currently, precise locaton only returns lat/lng coordinates on phones and lat/lng coordinates
// and a geocoded address on voice-activated speakers.
// Coarse location only works on voice-activated speakers.
app.tell('Sorry, I could not figure out where you are.Plaese try again');
}
} else {
app.tell('Sorry, I could not figure out where you are.Please try again');
}
};
const app = new DialogflowApp({request, response});
const actions = new Map();
actions.set('request_permission', requestPermission);
actions.set('user_info', userInfo);
app.handleRequest(actions);
});
【问题讨论】:
标签: webhooks actions-on-google dialogflow-es