【问题标题】:Slack API: How to add user avatars in message when they click a button?Slack API:单击按钮时如何在消息中添加用户头像?
【发布时间】:2021-09-06 14:09:57
【问题描述】:

我认为我还没有阅读块工具包文档中的某些内容,但我很好奇如何在块中显示用户头像,如下面的示例图片所示?干杯。

【问题讨论】:

    标签: slack slack-api slack-block-kit


    【解决方案1】:

    这个模板在 Block Kit Builder 的 App Templates 中确实可用

    https://api.slack.com/tools/block-kit-builder?template=1
    打开应用模板后搜索投票

    头像图片
    需要使用https://api.slack.com/methods/users.info获取图片url。
    格式化
    这是您感兴趣的块:

    {
                "type": "context",
                "elements": [
                    {
                        "type": "image",
                        "image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_1.png",
                        "alt_text": "Michael Scott"
                    },
                    {
                        "type": "image",
                        "image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_2.png",
                        "alt_text": "Dwight Schrute"
                    },
                    {
                        "type": "image",
                        "image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_3.png",
                        "alt_text": "Pam Beasely"
                    },
                    {
                        "type": "plain_text",
                        "emoji": true,
                        "text": "3 votes"
                    }
                ]
            }
    

    截图

    【讨论】:

      猜你喜欢
      • 2019-09-28
      • 1970-01-01
      • 2020-10-03
      • 2021-05-09
      • 2019-04-17
      • 1970-01-01
      • 1970-01-01
      • 2021-07-30
      • 2018-05-02
      相关资源
      最近更新 更多