首页 > 解决方案 > 从 Microsoft Bot Framework 发送 slack 附件

问题描述

我正在尝试从 Microsoft Bot 框架像这样发送带有附件 ( ref ) 的松弛消息。

    var message={
    "text": "I hope the tour went well, Mr. Wonka.",
    "response_type": "in_channel",
    "attachments": [
    {
        "text": "Who wins the lifetime supply of chocolate?",
        "fallback": "You could be telling the computer exactly what it can do with a lifetime supply of chocolate.",
        "color": "#3AA3E3",
        "attachment_type": "default",
        "callback_id": "select_simple_1234",
        "actions": [
            {
                "name": "winners_list",
                "text": "Who should win?",
                "type": "select",
                "data_source": "users"
            }
            ]
        }
    ]
};


session.send(message);

但它只呈现这个

I hope the tour went well, Mr. Wonka.

我不明白这里有什么问题。

标签: botframeworkbotsslack-api

解决方案


终于找到了这样做的方法,我的 JSON 中缺少“channelData”。

    var message={"channelData":{
"text": "I hope the tour went well, Mr. Wonka.",
"response_type": "in_channel",
"attachments": [
{
    "text": "Who wins the lifetime supply of chocolate?",
    "fallback": "You could be telling the computer exactly what it can do with a lifetime supply of chocolate.",
    "color": "#3AA3E3",
    "attachment_type": "default",
    "callback_id": "select_simple_1234",
    "actions": [
        {
            "name": "winners_list",
            "text": "Who should win?",
            "type": "select",
            "data_source": "users"
        }
        ]
    }
]
}

};


推荐阅读