当消息从 SfB 客户端发送到机器人时,它会收到两个响应。带"sip"和不带"sip"的地址 ID



机器人信息

  • SDK平台:节点.js
  • 机器人构建器版本:3.8.4
  • 活动频道:Skype for Bussiness
  • 部署环境:Azure Bot Service、Azure App Service

问题描述

在使用 Skype for Business 客户端(如 Android、iOS 和 Mac(从用户到机器人发起聊天时,机器人会收到来自用户的两个响应(类型:消息(。

但是在使用 Windows SFB 客户端时,机器人只收到 1 个响应。

这只发生在第一条消息(在聊天启动期间(:第一条消息中的地址 -Id 没有 sip 第二条消息是 sip .

var builder = require('botbuilder');
//
//other Code
//
var intents = new builder.IntentDialog()
    .onDefault((session) => {        
        session.send('Sorry, I did not understand '%s'.', session.message.text);
    });

下面是机器人收到的两条 json 格式的不同消息。

第一条消息中的地址 -Id Json 不带 sip 第二条消息的地址 ID 中带有sip

{
    "type": "message",
    "timestamp": "2017-12-22T05:18:19.4976179Z",
    "textFormat": "plain",
    "text": "hi",
    "address": {
        "id": //GUID
        "channelId": "skypeforbusiness",
        "user": {
            "id": "test@xyz.com",
            "name": "TestUserName"
        },
        "conversation": {
            "isGroup": true,
            "id": "NDJjOGUzNjcjc2lwOmJ1bWJsZWJlZUBiYW5uZXJ0ZWNoLm9ubWljcm9zb2Z0LmNvbQ=="
        },
        "bot": {
            "id": "sip:testbot@xyz.onmicrosoft.com",
            "name": "sip:text@xyz.onmicrosoft.com"
        },
        "serviceUrl": "https://webpoolbl20r04.infra.lync.com/platformservice/tgt-abcd/botframework"
    },
    "source": "skypeforbusiness",
    "agent": "botbuilder",
    "user": {
        "id": "test@xyz.onmicrosoft.com",
        "name": "TestUserName"
    }
}

{
    "type": "message",
    "timestamp": "2017-12-22T05:18:19.5601021Z",
    "textFormat": "plain",
    "text": "hi",
    "address": {
        "id": "2",
       "channelId": "skypeforbusiness",
        "user": {
            "id": "sip:test@xyz.onmicrosoft.com",
            "name": "TestUserName"
        },
        "conversation": {
            "isGroup": true,
            "id": "NDJjOGUzNjcjc2lwOmJ1bWJsZWJlZUBiYW5uZXJ0ZWNoLm9ubWljcm9zb2Z0LmNvbQ=="
        },
        "bot": {
            "id": "sip:testbot@xyz.onmicrosoft.com",
            "name": "sip:testbot@xyz.onmicrosoft.com"
        },
        "serviceUrl": "https://webpoolbl20r04.infra.lync.com/platformservice/tgt-3e269d45c99c53b8a53d91bd8610020f/botframework"
    },
    "source": "skypeforbusiness",
    "agent": "botbuilder",
    "user": {
        "id": "sip:test@xyz.onmicrosoft.com",
        "name": "TestUserName"
    }
}

取决于你实际想要完成的任务......您可以检查该字段并删除sip:或在代码中添加sip:

let id = idFromJson;
let prefix = "sip:";
if (id.includes(prefix)) {
   id = id.substring(3, id.length-1);
}

let id = idFromJson;
let prefix = "sip:";
if (!id.includes(prefix)) {
   id = prefix + id;
}

最新更新