我正在尝试使用dialogflow-fulfillment库而不是action-google来一次性获取dialogflow中的所有参数。
这样做是可能的吗?
我的代码类似于-:
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));
let conv= agent.conv();
function welcome(agent) {
let date = new Date();
var curHr = date.getHours();
if(curHr.toString() < 12)
{
agent.add('Hello, Good Morning!');
}
else{
agent.add('Hello, Hope you are having good day!');
}
}
function fein(agent){
const fein = agent.parameters.fein;
const name = agent.parameters['business-name'];
conv.user.storage = {
fein: fein
};
agent.add(conv.user.storage.fein.toString());
}但是不能获取输出。
我不确定我做的是不是正确的方法,请帮助我如何完成它。
发布于 2019-11-13 16:49:33
在使用user.storage对象之前,您应该检查是否需要在两次对话之间保存保存的数据。如果您只需要数据在当前对话中可用,那么使用conv.data会更容易。
如果您需要在多个会话之间保持该信息,请使用conv.user.storage。当您使用conv.user.storage时,请确保您的用户在activity controls中启用了Chrome & App Activity设置和Include Chrome history复选框。

如果要在会话之间使用用户存储来保存数据,则需要这些设置。如果您不启用它们,您的数据将根本不会保存在用户存储中。
https://stackoverflow.com/questions/58832065
复制相似问题