首页 > 解决方案 > 尝试在 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>

包.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"
  }

请帮忙

标签: dialogflow-esactions-on-google

解决方案


请尝试以下解决方案,您缺少 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 
}

推荐阅读