我已经发送了包含捕获详细信息和按钮的卡片。从任务模块单击提交后,该模块将通过 http API 保存详细信息,此处的活动类型为“调用”。
现在我必须更新现有的自适应卡。
我有更新消息的代码,但如何更新卡或再次重新发送卡。
connector = new ConnectorClient(new Uri(activity.ServiceUrl));
reply = activity.CreateReply($"You sent {activity.Text} which was {activity.Text.Length} characters");
var msgToUpdate = await connector.Conversations.ReplyToActivityAsync(reply);
Activity updatedReply = activity.CreateReply($"This is an updated message");
await connector.Conversations.UpdateActivityAsync(reply.Conversation.Id, msgToUpdate.Id, updatedReply);
这涉及几个步骤。
-
创建自适应卡并在自适应卡操作中添加唯一 ID (GUID)。
var Card = new AdaptiveCard()
{
Body = new List<AdaptiveElement>()
{
new AdaptiveTextBlock(){Text="This is a test adaptive card"}
},
Actions = new List<AdaptiveAction>()
{
new AdaptiveSubmitAction()
{
Title="UpdateMe",
DataJson= @"{'id':'uniqueId'}"
}
}
};
-
发送消息后保持自适应卡 uniqueId 和消息 id 的映射。
connector = new ConnectorClient(new Uri(activity.ServiceUrl));
reply = activity.CreateReply();
reply.Attachments.Add(Card.ToAttachment());
var msgToUpdate = await connector.Conversations.ReplyToActivityAsync(reply);
// Keep mapping of uniqueId and messageToUpdate.Id
// UniqueId1 => messageId1
// UniqueId2 => messageId2
当用户单击 UpdateMe 操作按钮时,检查映射uniqueId
(这将在activity.Value
).
- 创建新卡并拨打电话
connector.Conversations.UpdateActivityAsync
与更新的代码。
如果您需要更多详细信息,请告诉我们。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)