You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MS Bot Framework下,Skype机器人能否通过按钮/快速回复提示用户发位置?

很高兴能帮你解答这个问题!结合Bot Framework的最新更新和Skype客户端的支持情况,我把相关内容整理如下:

一、通过按钮/快速回复提示用户发送位置

没错,两年前的限制已经解除了!现在你完全可以通过Hero Card或者快速回复(Suggested Actions)添加“发送位置”的交互按钮,触发Skype客户端弹出位置选择界面,用户确认后就能把位置发送给机器人。

给你两个常用的实现示例:

Hero Card 方式(Node.js)

const { CardFactory } = require('botbuilder');

async function promptLocationWithCard(turnContext) {
    const locationCard = CardFactory.heroCard(
        '需要你的位置信息来提供服务',
        [], // 这里可以添加图片,不需要的话留空
        [
            {
                type: 'location',
                title: '分享我的位置'
            }
        ]
    );

    await turnContext.sendActivity({
        text: '请分享你的位置,我会为你提供针对性服务:',
        attachments: [locationCard]
    });
}

快速回复方式(Node.js)

async function promptLocationWithQuickReply(turnContext) {
    await turnContext.sendActivity({
        text: '是否愿意分享你的位置?',
        suggestedActions: {
            actions: [
                {
                    type: 'location',
                    title: '发送位置'
                }
            ]
        }
    });
}
二、Skype上定位用户的实现方式

需要明确的是,出于隐私保护的要求,Skype机器人无法主动获取用户的实时位置,只能通过以下两种合法方式获取位置数据:

  • 用户主动发送位置:用户直接在Skype客户端手动选择发送位置,机器人可以通过解析消息实体来获取地理坐标。比如C#中的处理逻辑:
if (turnContext.Activity.Entities != null)
{
    var locationEntity = turnContext.Activity.Entities.FirstOrDefault(e => e.Type == "Place");
    if (locationEntity != null)
    {
        var geoData = locationEntity.Properties["geo"] as Newtonsoft.Json.Linq.JObject;
        double latitude = geoData["latitude"].Value<double>();
        double longitude = geoData["longitude"].Value<double>();
        // 在这里处理获取到的经纬度信息,比如存储、调用第三方服务等
    }
}
  • 通过交互组件引导用户发送:也就是上面第一部分提到的按钮/快速回复方式,本质上还是用户主动提交位置数据,机器人被动接收——这是目前Skype上获取用户位置的核心方式。

所有位置数据的获取都必须经过用户的明确同意,Skype的隐私政策严格禁止机器人在用户不知情的情况下获取位置信息。

内容的提问来源于stack exchange,提问作者Amit be

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 08:30:37