【问题标题】:Microsoft Bot returns error on facebook for HeroCardMicrosoft Bot 在 Facebook 上为 HeroCard 返回错误
【发布时间】:2018-03-01 06:54:37
【问题描述】:

使用 C# 创建了一个机器人并发送带有按钮的 herocard,它可以在网络聊天和模拟器上正常工作,但在 facebook 上。每当我将带有附件的消息发送到 Facebook 时,我都会收到以下错误。

SendActivityToUserAsync FAILED: 
{
    "error": {
        "message": "(#100) Web url cannot be empty for url type button",
        "type": "OAuthException",
        "code": 100,
        "error_subcode": 2018041,
        "fbtrace_id": "C0s4Cxs3g+s"
    }
}

操作返回了无效的状态代码“BadRequest”

//附件代码。

var heroCard = new HeroCard
{
    // title of the card  
    Title = "",
    //subtitle of the card  
    Subtitle = "",
    // list of buttons   
    Buttons = new List<CardAction> {
        new CardAction() {
            Title = "Show my calendar",
            Text = "Show my calendar",
            Type = ActionTypes.ImBack
        },
        new CardAction() {
            Title = "Show my day",
            Text = "Show my day",
            Type = ActionTypes.ImBack
        }
    }
};

【问题讨论】:

    标签: botframework facebook-messenger facebook-messenger-bot


    【解决方案1】:

    您的卡片操作中缺少Value 字段。以下代码有效。您需要 value 字段为您的 ImBack 提供“价值”(因为缺少更好的词)

    var heroCard = new HeroCard
    {
        // title of the card  
        Title = "",
        //subtitle of the card  
        Subtitle = "",
        // list of buttons   
        Buttons = new List<CardAction> {
            new CardAction() {
                Title = "Show my calendar",
                Text = "Show my calendar",
                Type = ActionTypes.ImBack,
                Value = "123"
    
            },
            new CardAction() {
                Title = "Show my day",
                Text = "Show my day",
                Type = ActionTypes.ImBack,
                Value = "456"
            }
        }
    };
    

    【讨论】:

      猜你喜欢
      • 2021-02-19
      • 1970-01-01
      • 1970-01-01
      • 2021-09-05
      • 2020-12-17
      • 2013-06-14
      • 2018-11-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多