【问题标题】:Slack API chat.postMessage URL UnfurlingSlack API chat.postMessage URL 展开
【发布时间】:2020-10-09 13:45:40
【问题描述】:

我有一个向 slack 频道发送消息的机器人应用程序。我正在使用https://api.slack.com/methods/chat.postMessage/ 向slack 频道发送消息。

我的消息有时有几个链接 (GIF),这些链接在频道中呈现为纯链接。

我希望它们展开,以便它可以在频道本身上显示动画 GIF。

我尝试将 unfurl_links: true 传递给 API 参数,但它不起作用。

这是我的 JSON 负载

{
    "text": "Anniversary Alert :confetti_ball:",
    "channel": "C01AGGP63ST",
    "blocks": [
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "Anniversary Alert :confetti_ball:\n\nLet's all take a moment to congratulate <@U024FCGPW> on their 10 year anniversary!\n\nWe wish you a very happy anniversary and many more great years ahead with us.\n\nhttps://media0.giphy.com/media/1yjpDZgvGkb6nTynq3/giphy.gif?cid=cbd9d2f95475c686b1a293a6cf43de5f3f640e4eb012f714&rid=giphy.gif"
            }
        }
    ],
    unfurl_links: true
}

有人可以帮忙吗?

【问题讨论】:

    标签: slack-api


    【解决方案1】:

    使用 API 有效负载的“附件”属性并展开链接

    {
        "text": "Anniversary Alert :confetti_ball:",
        "channel": "C01AGGP63ST",
        "blocks": [
            {
                "type": "section",
                "text": {
                    "type": "mrkdwn",
                    "text": "Anniversary Alert :confetti_ball:\n\nLet's all take a moment to congratulate <@U024FCGPW> on their 10 year anniversary!\n\nWe wish you a very happy anniversary and many more great years ahead with us.\n\nhttps://media0.giphy.com/media/1yjpDZgvGkb6nTynq3/giphy.gif?cid=cbd9d2f95475c686b1a293a6cf43de5f3f640e4eb012f714&rid=giphy.gif"
                }
            }
        ],
        "attachments": [
         {
            "text": "",
            "image_url": "https://media0.giphy.com/media/1yjpDZgvGkb6nTynq3/giphy.gif?cid=cbd9d2f95475c686b1a293a6cf43de5f3f640e4eb012f714&rid=giphy.gif"
         }
    ]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-17
      • 1970-01-01
      • 2016-09-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多