【发布时间】:2018-07-08 04:54:08
【问题描述】:
我在测试我的 Google 助理应用(在 DialogFlow 中制作)时遇到问题。每次我运行第一个意图并满足运行相应操作的条件时,助手就会结束并且不允许用户输入可能触发后续意图的值。每次都关闭麦克风而不是继续对话。
有没有办法设置 Intent 和相应的 webhook 以确保应用不会在每次完成单个操作时自行关闭?
'use strict';
process.env.DEBUG = 'actions-on-google:*';
const App = require('actions-on-google').DialogflowApp;
const functions = require('firebase-functions');
// x. start custom code
const orderLists = [
{
reference: '0',
clothing: ['shirt', 'top', 'bra'],
deliveryStatus: 'will be delivered before 1pm, make sure youre in!'
},
{
reference: '1',
clothing: ['shirt', 'top', 'bra'],
deliveryStatus: 'is due for delivery on February 2nd.'
},
{
reference: '2',
clothing: ['shirt', 'top', 'bra'],
deliveryStatus: 'is due for delivery on February 3rd.'
},
{
reference: '3',
clothing: ['shirt', 'top', 'bra'],
deliveryStatus: 'was delivered today at 2pm to your default address.'
},
{
reference: '4',
clothing: ['shirt', 'top', 'bra'],
deliveryStatus: 'was left with your neighbour at 22 Waltham Drive, today at 2pm.'
}
]
// a. the action name from the make_name Dialogflow intent
// const NAME_ACTION = 'make_name';
const NAME_ACTION = 'query_order';
const NAME_ACTION2 = 'query_order.query_order-more';
// b. the parameters that are parsed from the make_name intent
// const COLOR_ARGUMENT = 'color';
// const NUMBER_ARGUMENT = 'number';
const ORDERNUMBER_ARGUMENT = 'number';
const min = 0;
const max = 10;
exports.sillyNameMaker = functions.https.onRequest((request, response) => {
const app = new App({request, response});
console.log('Request headers: ' + JSON.stringify(request.headers));
console.log('Request body: ' + JSON.stringify(request.body));
// c. The function that generates the silly name
function queryOrder (app) {
let number = app.getArgument(ORDERNUMBER_ARGUMENT);
app.tell('Order number '+ number + ', ' + orderLists[number].deliveryStatus) + 'Would you like to know more?';
}
function queryOrderItems (app) {
let number = app.getArgument(ORDERNUMBER_ARGUMENT);
app.tell('Order number '+ number + ', ' + orderLists[number].clothing);
}
// d. build an action map, which maps intent names to functions
let actionMap = new Map();
actionMap.set(NAME_ACTION, queryOrder);
let actionMap2 = new Map();
actionMap2.set(NAME_ACTION2, queryOrderItems);
app.handleRequest(actionMap);
app.handleRequest(actionMap2);
});
【问题讨论】:
标签: javascript action actions-on-google dialogflow-es