botframework - 如何让机器人列出/获取群组对话的参与者或成员?

标签 botframework

我创建了一个可以添加到群组对话中的 skypeBot。有没有办法让机器人从对话中获取参与者列表?

最佳答案

至少有 2 种方法可以让 Skype 中的机器人参与群组对话,但您只能获得他们的 ID:

情况 1: 通过检查创建对话时引发的 ConversationUpdate 消息。

示例(用我的一个机器人制作):

{
    "type": "conversationUpdate",
    "id": "f:6c9b7aa2",
    "timestamp": "2017-06-30T11:40:09.3Z",
    "localTimestamp": null,
    "serviceUrl": "https://smba.trafficmanager.net/apis/",
    "channelId": "skype",
    "from": {
        "id": "29:1AE5BB....",
        "name": null
    },
    "conversation": {
        "isGroup": true,
        "id": "19:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="35535106511b1b1b1b75415d475054511b465e4c4550" rel="noreferrer noopener nofollow">[email protected]</a>",
        "name": null
    },
    "recipient": {
        "id": "28:myBotAppId",
        "name": "myBotName"
    },
    "textFormat": null,
    "attachmentLayout": null,
    "membersAdded": [{
        "id": "29:1AE5BB...",
        "name": null
    }, {
        "id": "29:1DwlGVz...",
        "name": null
    }, {
        "id": "28:myBotAppId",
        "name": null
    }],
    "membersRemoved": [],
    "topicName": null,
    "historyDisclosed": null,
    "locale": null,
    "text": null,
    "speak": null,
    "inputHint": null,
    "summary": null,
    "suggestedActions": null,
    "attachments": [],
    "entities": [],
    "channelData": null,
    "action": null,
    "replyToId": null,
    "value": null,
    "name": null,
    "relatesTo": null,
    "code": null
}

此处,membersAdded block 中的群组对话中有 2 个用户:29:1AE5BB....29:1DwlGVz... 。最后一个ID是机器人ID

情况 2:通过请求 API。 您可以向 https://smba.trafficmanager.net/apis/v3/conversations/yourConversationId/members 发出 GET 请求,您将获得相同的 2 个 ID。

另请参阅此处的更多详细信息:https://github.com/Microsoft/BotBuilder-Samples/tree/master/Node/core-GetConversationMembers

因此,您可以通过 C# 代码执行以下操作:

ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
var members = connector.Conversations.GetConversationMembersWithHttpMessagesAsync(activity.Conversation.Id).Result.Body;

关于botframework - 如何让机器人列出/获取群组对话的参与者或成员?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44830461/

相关文章:

c# - 如何使用c#在客户端获取建议的cardaction内容

azure - 如何为所有用户更新机器人的 Microsoft Teams list ?

azure - 为什么 Microsoft Bot Framework 机器人需要 Azure AD 应用 ID 和 key ?

node.js - 如何在使用 waterfall 对话框(Node js)的同时使用微软机器人框架将英雄卡片发送到 fb 信使

azure - 使用 Clickatell 将 Whatsapp 作为 Microsoft Bot Framework 的 channel

.net - MS 团队应用程序 : There was a problem reaching this app

c# - 机器人上下文。等待不显示下一条消息

node.js - 此事件没有渲染器 - Microsoft Bot Framework Emulator qnamaker

azure - Botframework 可以使用德语或其他语言吗?

c# - Bot 框架门户 - "Test connection to your bot"401 未经授权