【发布时间】:2017-11-24 11:32:19
【问题描述】:
我正在使用 Dialogflow 构建应用程序。用户回答了一些问题,并且可以稍后查看他们的答案。我的问题是构建服务器以返回用户以前的答案。
这是目前为止的代码,intent是QUESTION_1和QUESTION_2,参数是GRATEFUL_1和GRATEFUL_2:
'use strict';
process.env.DEBUG = 'actions-on-google:*';
const App = require('actions-on-google').DialogflowApp;
const functions = require('firebase-functions');
// a. the action names from the Dialogflow intents
const QUESTION_1 = 'Question-1';
const QUESTION_2 = 'Question-2';
// b. the parameters that are parsed from the intents
const GRATEFUL_1 = 'any-grateful-1';
const GRATEFUL_2 = 'any-grateful-2';
exports.JournalBot = 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));
// Return the last journal entry
function reflect (app) {
let grateful_1 = app.getArgument(GRATEFUL_1);
app.tell('Here is your previous entry: ' + grateful_1);
}
// Build an action map, which maps intent names to functions
let actionMap = new Map();
actionMap.set(QUESTION_1, reflect);
app.handleRequest(actionMap);
});
我希望将“反射”函数映射到 GRATEFUL_2 响应以及 GRATEFUL_1。我知道如何做到这一点,但我如何改变下一点以包含两个意图:
actionMap.set(QUESTION_1, reflect);
【问题讨论】:
标签: node.js webhooks dialogflow-es actions-on-google