在dialogflow Webhook请求中将设备位置获取为空

时间:2018-10-16 10:34:38

标签: dialogflow actions-on-google

嗨,我正在尝试通过请求权限来获取用户的设备位置。它对于模拟器很好用,但是当我用google mini设备进行测试时,在webhook请求中获取的设备位置未定义。下面是代码

const {Permission} = require('actions-on-google');
const {WebhookClient} = require('dialogflow-fulfillment');
const agent = new WebhookClient({ request: req, response: res });
conv.ask(new Permission({context:'To Locate You',permissions:'DEVICE_COARSE_LOCATION'}));
function userinfo(agent){
        var conv=agent.conv();
        var resp=conv.arguments.get('PERMISSION');
    console.log(conv.device.location);
    if(resp){

                var country=conv.device.location.country;
                var speech="you are located in "+country;
                conv.ask(speech);
                agent.add(conv);
        }else{
            conv.ask('Sorry, I could not figure out where you are');
            agent.add(conv);
    }
}

1 个答案:

答案 0 :(得分:1)

您不能混合使用dialogflow-fulfillmentactions-on-google库。数据类型不一定要兼容。如果您需要Google特定于Actions的功能,则应完全使用actions-on-google。如果您需要Dialogflow支持的多种平台之间的兼容性,请使用dialogflow-fulfillment