我创建了一个可以添加到群组对话中的skypeBot。机器人如何从对话中获取参与者列表?
答案 0 :(得分: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:fd3d....@thread.skype",
"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
区块中的群组对话中有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;
答案 1 :(得分:1)
对于c#,你可以在messageController
中试试 ConnectorClient connector = new ConnectorClient(new System.Uri(activity.ServiceUrl));
var members = connector.Conversations.GetConversationMembersWithHttpMessagesAsync(activity.Conversation.Id).Result.Body;