如何使用Bot Framework在团队中与自适应卡片一起添加提及 [英] How to add a mention in Teams alongside an adaptive card using Bot Framework

查看:137
本文介绍了如何使用Bot Framework在团队中与自适应卡片一起添加提及的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试发送带有自适应卡片附件的活动,并向创建该帖子的用户提及.通过在线阅读,我发现您当前无法在自适应卡中添加提及.发送活动时(例如在另一个附件中)是否有提及某人的方法?我试过设置activity.Text =提到,这有效,但是它创建了两个帖子,第一个带有提及,然后另一个带有自适应卡作为单独消息的帖子.我觉得一定有办法做到这一点,否则,如果您创建了一条帖子,并且有人回复了您,您将永远不会在回复时自动知道. 还请注意,我没有使用Flow. 代码 团队发布

I'm trying to send an activity with an adaptive card attachment and include a mention to the user who created the post. From reading online I found you can't currently include mentions in adaptive cards. Is there a way to mention someone when sending the activity, for example in another attachment?. I have tried setting the activity.Text = mention, this works however it creates two posts, the first with the mention and then another post with the adaptive card as a separate message. I feel there must be a way to do this, else if you created a post and someone responded to you, you'd never know automatically on reply. Also note I'm not using Flow. Code Teams Post

推荐答案

您是否考虑过(a)发送自适应卡和(b)向您发送的原始自适应卡发送答复"消息?我以前没有做过,但是我想从turnContext.SendActivityAsync(在ResourceResponse实例上)返回的ID是您可以用来回复"刚刚创建的消息的ID.

Have you thought about (a) sending the adaptive card and (b) sending a "Reply" message to the original Adaptive Card you sent? I haven't done this before, but I'm guessing the id that comes back from turnContext.SendActivityAsync (on the ResourceResponse instance) is the id you can use to "reply" to the message you just created.

更新:我知道了.这是非常粗糙的代码,但希望足以让您弄清楚/适应您的情况:

Update: I got it working. This is -very- rough code but hopefully enough that you can figure out/adjust to your scenario:

 var result = connector.Conversations.SendToConversationAsync([your conversation id], activity).Result;

// I'm re-using the same activity just as a test, you can do whatever (e.g. create a new one)
activity.Text = "Msg 2";
var conversationReference = activity.GetReplyConversationReference(result);
conversationReference.Conversation.Id = conversationReference.Conversation.Id + ";messageid=" + result.Id;
activity.ApplyConversationReference(conversationReference);

connector.Conversations.SendToConversationAsync(conversationReference.Conversation.Id, activity);

请注意,这一点非常重要,您需要更改您的会话ID,以在末尾添加; messageid =,并添加 ADD 引用您刚刚发布的消息

So note, really important, you need to change your conversation id to add ";messageid=" to the end, and ADD the reference the message you just posted.

以下是屏幕截图:

希望能有所帮助,并感谢您-给了我一次学习有用的东西的机会!

Hope that helps, and thanks for this - gave me a chance to learn something useful!

这篇关于如何使用Bot Framework在团队中与自适应卡片一起添加提及的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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