本文介绍了在dialogflow Webhook请求中将设备位置获取为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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);
    }
}


推荐答案

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

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.

这篇关于在dialogflow Webhook请求中将设备位置获取为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-02 22:03