Microsoft Bot Connector-发送消息后从响应获取活动ID
我正在使用Microsoft的漫游器框架(使用.NET API)为MS Teams开发一个漫游器.我现在想做的是检索 Activity.Id
.当漫游器收到消息时,其中会包含一个Activity.Id
,我希望有一种方法可以在发送消息时对其进行检索.
I'm working on a bot for MS Teams using Microsoft's bot framework (using the .NET API). What I am trying to do right now is to retrieve the Activity.Id
of a message the bot has just sent. When the bot receives a message, an Activity.Id
is included and I was hoping there was a way to retrieve that when sending a message.
我目前正在使用以下方式发送:
var response = connector.Conversations.SendToConversation((Activity)activity);
I am currently sending using:
var response = connector.Conversations.SendToConversation((Activity)activity);
connector
是Microsoft.Bot.Connector.ConnectorClient
This returns a ResourceResponse
, which contains an Id, but this Id does not appear to be in the same format as that of the Activity.Id that comes with a message received.
有人知道是否有可能获得此信息吗? 预先感谢!
Does anyone know if it is possible to get this information? Thanks in advance!
看看CreateConversationAsync.这是摘录自我们的
Take a look at CreateConversationAsync. Here's a code snippet taken from our C# complete sample:
try
{
var conversationResource = await connectorClient.Conversations.CreateConversationAsync(parameters);
IMessageActivity message = null;
if (conversationResource != null)
{
message = Activity.CreateMessageActivity();
message.From = new ChannelAccount(botId, botName);
message.Conversation = new ConversationAccount(id: conversationResource.Id.ToString());
message.Text = Strings.Send1on1Prompt;
}
await connectorClient.Conversations.SendToConversationAsync((Activity)message);
}
catch (Exception ex)
{
}