dialogflow Webhookclient "request_" 属性
dialogflow Webhookclient "request_" property
我正在尝试使用 Dialogflow 构建一个 facebook Messenger 聊天机器人。在 dialogflow fulfillment 内联编辑器中,我发现我可以使用 agent.request_.body 来获取请求的主体。我假设 "request_" 是 WebhoodClient 对象的 属性?但是我找不到任何详细说明的文档,请问我的理解是否正确,在哪里可以找到参考或文档?
const agent = new WebhookClient({ request, response });
console.log(JSON.stringify(agent.request_.body));
谢谢
Google 为 Dialogflow webhooks here 提供文档,其中包括此示例 webhook 以检查参数并动态创建插槽填充提示:
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
function flight(agent) {
const city = agent.parameters['geo-city'];
const time = agent.parameters['time'];
const gotCity = city.length > 0;
const gotTime = time.length > 0;
if(gotCity && gotTime) {
agent.add(`Nice, you want to fly to ${city} at ${time}.`);
} else if (gotCity && !gotTime) {
agent.add('Let me know which time you want to fly');
} else if (gotTime && !gotCity) {
agent.add('Let me know which city you want to fly to');
} else {
agent.add('Let me know which city and time you want to fly');
}
}
let intentMap = new Map();
intentMap.set('flight', flight);
agent.handleRequest(intentMap);
});
我的猜测是添加
console.log(agent);
在定义飞行函数之前,然后检查日志以查看代理包含哪些对象,然后添加 console.log(agent.fakeObjectName) 的迭代,直到找到您要查找的信息。
如果您正在关注 the deployment process recommended in Actions on Google's Codelabs level 2,您的日志将显示在 Firebase 控制台中,如下所示:
希望对您有所帮助!
请注意。
我有一个类似于这样的代码:
const city = agent.parameters['geo-city'];
有一个图标表明它最好用点符号书写。
在我将其更改为后消失了:
const city = agent.parameters.geo-city;
我正在尝试使用 Dialogflow 构建一个 facebook Messenger 聊天机器人。在 dialogflow fulfillment 内联编辑器中,我发现我可以使用 agent.request_.body 来获取请求的主体。我假设 "request_" 是 WebhoodClient 对象的 属性?但是我找不到任何详细说明的文档,请问我的理解是否正确,在哪里可以找到参考或文档?
const agent = new WebhookClient({ request, response });
console.log(JSON.stringify(agent.request_.body));
谢谢
Google 为 Dialogflow webhooks here 提供文档,其中包括此示例 webhook 以检查参数并动态创建插槽填充提示:
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
function flight(agent) {
const city = agent.parameters['geo-city'];
const time = agent.parameters['time'];
const gotCity = city.length > 0;
const gotTime = time.length > 0;
if(gotCity && gotTime) {
agent.add(`Nice, you want to fly to ${city} at ${time}.`);
} else if (gotCity && !gotTime) {
agent.add('Let me know which time you want to fly');
} else if (gotTime && !gotCity) {
agent.add('Let me know which city you want to fly to');
} else {
agent.add('Let me know which city and time you want to fly');
}
}
let intentMap = new Map();
intentMap.set('flight', flight);
agent.handleRequest(intentMap);
});
我的猜测是添加
console.log(agent);
在定义飞行函数之前,然后检查日志以查看代理包含哪些对象,然后添加 console.log(agent.fakeObjectName) 的迭代,直到找到您要查找的信息。
如果您正在关注 the deployment process recommended in Actions on Google's Codelabs level 2,您的日志将显示在 Firebase 控制台中,如下所示:
希望对您有所帮助!
请注意。 我有一个类似于这样的代码:
const city = agent.parameters['geo-city'];
有一个图标表明它最好用点符号书写。 在我将其更改为后消失了:
const city = agent.parameters.geo-city;