我需要在dialogflow中获取用户的当前位置。为此,我创建了一个意图-UseMyLocation,然后跟进了意图并在其中添加了事件GOOGLE_ASSISTANT PERMISSION
function requestPermission(agent) {
agent.requestSource = agent.ACTIONS_ON_GOOGLE;
let conv = agent.conv();
console.log('conv '+conv);
conv.ask(new Permission({
context: 'to locate you',
permissions: 'DEVICE_PRECISE_LOCATION',
}));
}
intentMap.set('movie.book.ticket - UseMyLocation',requestPermission);
agent.handleRequest(intentMap);
It should ask for user's permission for the location instead it is throwing exception:
Error: No responses defined for platform: ACTIONS_ON_GOOGLE
at V2Agent.sendResponses_ (/srv/node_modules/dialogflow-fulfillment/src/v2-agent.js:243:13)
at WebhookClient.send_ (/srv/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:505:17)
at promise.then (/srv/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:316:38)
at <anonymous>
package.json
"dependencies": {
"actions-on-google": "^2.2.0",
"firebase-admin": "^5.13.1",
"firebase-functions": "^2.0.2",
"dialogflow": "^0.6.0",
"dialogflow-fulfillment": "^0.6.0"
}
请帮助
答案 0 :(得分:0)
请尝试以下解决方案,您缺少agent.add(conv);
function requestPermission(agent)
{
agent.requestSource = agent.ACTIONS_ON_GOOGLE;
let conv = agent.conv();
console.log('conv '+conv);
conv.ask(new Permission({
context: 'to locate you',
permissions: 'DEVICE_PRECISE_LOCATION',
}));
agent.add(conv); // Please add this
}