【问题标题】:AnimationCard works on emulator but not on MessengerAnimationCard 适用于模拟器但不适用于 Messenger
【发布时间】:2017-08-17 05:39:23
【问题描述】:

我正在尝试使用带有文本、GIF 和按钮的 Bot 框架显示动画卡。它可以在机器人模拟器上完美运行,但不会出现在 Messenger 上。有什么想法吗?

代码

/**Send the question with the level information if available, the index and the Math expression along with a countdown timer as GIF attachment */
let message = new builder.Message(session)
    .text(level ? level + '  \n' + strings.question : strings.question, dialogData.index + 1, question.expression)
    .addAttachment(
    new builder.AnimationCard(session)
        .media([{
            profile: "image/gif",
            url: "https://media.giphy.com/media/l3q2silev6exF53pu/200w.gif"
        }])
        .buttons(buttons)
    // .toAttachment()
    )
session.send(message)

在模拟器上

在信使上

任何想法可能会发生什么? 提前感谢您的建议

更新 1

这是我控制台上的错误

{"error":{"message":"(#100) 参数 [elements][0][title] 必须是非空的 UTF-8 编码字符串","type":"OAuthException","代码":100,"fbtrace_id":"CLEcx63w+4N"}}

【问题讨论】:

    标签: bots botframework chatbot facebook-messenger-bot


    【解决方案1】:

    您需要在动画卡片中包含title,Messenger 要求所有卡片都包含标题。此外,动画卡片在 Messenger 中的工作方式略有不同,它们发送带有 .gif 的消息,后跟带有标题和按钮的卡片,而不是像在模拟器中那样将它们全部放在一张漂亮的卡片中。

    在您的用例中,我会使用第一行来说明它的级别作为标题,问题作为副标题。不过,此文本将显示在 gif 下方而不是上方,因此它的布局与您现在的布局略有不同。

    let message = new builder.Message(session)
        .addAttachment(
        new builder.AnimationCard(session)
            .title(level ? level : 'Level 0')
            .subtitle(strings.question)
            .media([{
                profile: "image/gif",
                url: "https://media.giphy.com/media/l3q2silev6exF53pu/200w.gif"
            }])
            .buttons(buttons)
        )
    session.send(message)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-01
      • 2011-03-08
      • 2015-02-13
      • 2011-04-14
      • 2011-03-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多