Microsoft Bot在Facebook上为HeroCard返回错误

时间:2018-02-27 16:55:43

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

使用C#创建机器人并使用按钮发送herocard,它可以在网络聊天和模拟器上正常工作但在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
        }
    }
};

1 个答案:

答案 0 :(得分:0)

您错过了卡片操作中的Value字段。以下代码有效。您需要值字段为您的ImBack提供&#34;值&#34;(缺少更好的词)

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"
        }
    }
};