我有 5 个意图从用户那里获取各种输入。我必须在最后一个意图中显示所有采用的输入。我使用了上下文仍然无法正常工作。
1 回答
-1
使用如下所示的全局变量。不是最好的软件开发实践,但适用于您的情况。
'use strict';
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
// Once you make it global it will be accessible for the function below
var YourParameter;
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
function welcome(agent) {
YourParameter = agent.parameters.yourParameter
}
});
于 2020-05-20T06:40:51.893 回答