我创建了一个可以添加到群组对话中的 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/