Getting device location as empty in dialogflow webhook request

时光毁灭记忆、已成空白 提交于 2019-12-11 18:12:33

问题


Hi i'm trying to get device location of the user by asking permission.It works fine for simulator but when i tested with google mini device getting undefined for device location in webhook request.Below is the code

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:


You can't mix the dialogflow-fulfillment and actions-on-google libraries. The data types aren't necessarily going to be compatible. If you require features specific to Actions on Google, you should use actions-on-google completely. If you require compatibility between a variety of platforms supported by Dialogflow, use dialogflow-fulfillment.



来源:https://stackoverflow.com/questions/52833499/getting-device-location-as-empty-in-dialogflow-webhook-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!