我正在尝试让v4机器人框架机器人(C# SDK)发起与用户的1:1对话,并且我需要能够获取/创建对话ID。
var response = await m_client.Conversations.CreateDirectConversationAsync(new ChannelAccount(aadObjectId: "DB84C737-2161-4A35-B8C3-274B1FA4CF15", role: "bot"),
new ChannelAccount(role:"user",aadObjectId:"045AD4DB-133B-4C1B-870B-8201B7233625"));
// Construct the message to post to conversation
Activity newActivity = new Activity()
{
Text = "Hello",
Type = ActivityTypes.Message,
Conversation = new ConversationAccount
{
Id = response.Id
},
};
// Post the message to chat conversation with user
await m_client.Conversations.SendToConversationAsync(newActivity);这是一个糟糕的请求。如果我让用户先给我的机器人发消息(或者在他们添加机器人时查找ConversationUpdated事件),我可以保存会话ID (类似于a:1NJglnU1nkB-rqiCw2pQjbwMVViEYxyGxqGr8roBJMwtzzyDt_usg02D4HyaACgen_dOkikceYF3vdQ6kt6UAlxcT-tgCw7H8RWw46lLHBKYpxhkzgmMYJ9kOxiseAZga),,但我希望能够为用户检索/生成该ID,而不必先向机器人发送消息,这是我认为CreateDirectConversationAsync会提供给我的。
我还尝试为user/bot (address@domain)和aad对象ID设置ID参数,但结果是相同的。有没有办法让我的机器人为SDK中的1:1聊天创建一个对话ID?
发布于 2020-03-05 23:37:16
我已经有一段时间没有使用它了,那是在Microsoft.Bot.Connector.Teams包还存在的时候,但现在它已经进入了核心机器人框架。因此,我认为您现在会考虑使用:
m_client.Conversations.CreateConversationAsync而不是
m_client.Conversations.CreateDirectConversationAsync在这个重载中,关键是在"ConversationParameters“对象上设置正确的值,特别是"Bot”、"Members“和"TenantId”属性。
https://stackoverflow.com/questions/60548801
复制相似问题