Microsoft Bot Connector-发送消息后从响应获取活动ID [英] Microsoft Bot Connector - get activity id from response after sending message

查看:104
本文介绍了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);

connectorMicrosoft.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)
        {

        }

这篇关于Microsoft Bot Connector-发送消息后从响应获取活动ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆