【问题标题】:How to change the notification text for a Teams bot posting a card?如何更改发布卡片的 Teams 机器人的通知文本?
【发布时间】:2020-09-12 22:53:50
【问题描述】:

我正在使用机器人通过以下代码将带有单个附件(自适应卡片)的消息发布到团队频道。这工作正常。但是,在移动设备和 Teams 活动源中,发布卡片时通知中不会显示一些有用的文本,通知文本只是“卡片”(见下图)。

我已经尝试在卡片上设置fallbackText 参数,它不会调整通知中的文本。我还尝试在Activity 实例上设置text 参数,但这会导致错误提示它导致多个Skype 活动。我怎样才能使通知中显示的上下文与“卡片”不同?

card = CardFactory.adaptive_card({
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "type": "AdaptiveCard",
    "version": "1.2",
    "fallbackText": "This is some notification text",
    "body": [ ... ]})

connector.conversations.create_conversation(ConversationParameters(
    is_group=True,
    channel_data={ "channel": { "id": "..." } },
    activity=Activity(
        type=ActivityTypes.message,
        attachments=[card])))

【问题讨论】:

    标签: botframework microsoft-teams


    【解决方案1】:

    @ajshort,您需要为其添加摘要。以下代码应为您提供修改后的文本,而不仅仅是卡片。

    var reply = MessageFactory.Text(string.Empty);
    reply.Attachments.Add(callAdaptiveCardhere());
    reply.Summary="Your message will go here!"
    await turnContext.SendActivityAsync(reply);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-23
      • 2011-09-29
      • 1970-01-01
      • 2018-05-07
      • 2017-08-24
      • 2017-11-19
      相关资源
      最近更新 更多