我正在尝试将contextOut
数组添加到我的 firebase webhook 为 api.ai 给出的响应中,如此处所述。
我简化的firebase代码如下:
exports.myEndPoint = functions.https.onRequest((req, res) => {
const assistant = new Assistant({ request: req, response: res });
function firstHandler(assistant) {
const i = Math.floor(Math.random() * 200);
// I want to append contextOut to the response for api.ai here
assistant.ask(message generated using i);
}
function secondHandler(assistant) {
// I want to retrieve i from the request from api.ai here
assistant.tell(a different message generated using i from earlier);
}
const actionMap = new Map();
actionMap.set('first', firstHandler);
actionMap.set('second', secondHandler);
assistant.handleRequest(actionMap);
});
在创建助手实例之前以及创建实例之后,res.contextOut
我已经尝试过。我在 api.ai 控制台的 json 响应中看不到变量。res.data
assistant.contextOut
assistant.data
谁能告诉我我错过了什么?谢谢!