问题描述
我正在使用dialogFlow获取用户的详细信息(名称,位置,编号)。然后,我将此详细信息发送到电子邮件。我有两个意图:一个问用户是否得到了帮助,如果第二个意图没有被触发,第二个意图是负责获取客户详细信息的人。
如何实现Permission API,以便Google发布我的项目?
解决方法
您可以使用权限构造函数在当前上下文中向代理请求权限。
在意图图中
intentMap.set("LocationIntent - yes",senderLocationYes);
intentMap.set("LocationIntent - yes",senderLocationAccess);
function senderLocationYes(agent) {
const conv = agent.conv();
conv.ask(
new Permission({
context: "To use your location for tracking purpose",permissions: "DEVICE_PRECISE_LOCATION"
})
);
agent.add(conv);
}
function senderLocationAccess(agent) {
const conv = agent.conv();
const location = conv.device.location;
console.log(location);// here is the location
conv.ask('Great ! I will need few more details. Plese help me with that.');
conv.ask('What is your good name ?');
agent.add(conv);
}
请确保在意图图和对话框流中配置此意图。