Microsoft Bot在Facebook上为HeroCard返回错误

问题描述 投票:2回答:1

使用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
        }
    }
};
botframework facebook-messenger facebook-messenger-bot
1个回答
0
投票

您缺少卡片操作中的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"
        }
    }
};
© www.soinside.com 2019 - 2024. All rights reserved.