javascript - Slack Block-kit Multi_users_select 删除默认应用程序

标签 javascript node.js slack slack-api slack-block-kit

我实现了一个 Slack 机器人,其 um 字段的类型为 input(multi_users_select)。我想从列表中删除默认应用程序选择?

{
            type: 'input',
            element: {
                type: 'multi_users_select',
                action_id: input.actionId,
                initial_users: input.initial_users,
            },
            label: {
                type: 'plain_text',
                text: input.text,
                emoji: input.emoji,
            },
        };

enter image description here

最佳答案

不要使用 type: 'multi_users_select',而是使用 "type": "multi_conversations_select"过滤器,如下所示,仅获取您的用户中的用户工作区。 您可以将以下代码复制并粘贴到 block-kit builder 中以自行测试。 https://app.slack.com/block-kit-builder/

{
    "title": {
        "type": "plain_text",
        "text": "Blocker-Bot"
    },
    "submit": {
        "type": "plain_text",
        "text": "Submit"
    },
    "type": "modal",
    "callback_id": "custom_time_select",
    "private_metadata": "private-data",
    "blocks": [
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "Test block with multi conversations select"
            },
            "accessory": {
                "type": "multi_conversations_select",
                "placeholder": {
                    "type": "plain_text",
                    "text": "Select conversations",
                    "emoji": true
                },
                "filter": {
                    "include": [
                        "im"
                    ],
                    "exclude_bot_users": true
                },
                "action_id": "multi_conversations_select-action"
            }
        }
    ]
}

21 年 7 月 5 日更新

包括各种其他类型的精选用户,没有机器人/应用程序

{
    "type": "modal",
    "title": {
        "type": "plain_text",
        "text": "My App",
        "emoji": true
    },
    "submit": {
        "type": "plain_text",
        "text": "Submit",
        "emoji": true
    },
    "close": {
        "type": "plain_text",
        "text": "Cancel",
        "emoji": true
    },
    "blocks": [
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "Conversations type Select user"
            },
            "accessory": {
                "type": "conversations_select",
                "placeholder": {
                    "type": "plain_text",
                    "text": "Select a user",
                    "emoji": true
                },
                "filter": {
                    "include": [
                        "im"
                    ],
                    "exclude_bot_users": true
                },
                "action_id": "users_select-action"
            }
        },
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "Multi Conversations type Select users"
            },
            "accessory": {
                "type": "multi_conversations_select",
                "placeholder": {
                    "type": "plain_text",
                    "text": "Select conversations",
                    "emoji": true
                },
                "filter": {
                    "include": [
                        "im"
                    ],
                    "exclude_bot_users": true
                },
                "action_id": "multi_conversations_select-action"
            }
        },
        {
            "type": "input",
            "element": {
                "type": "multi_conversations_select",
                "placeholder": {
                    "type": "plain_text",
                    "text": "Select users",
                    "emoji": true
                },
                "filter": {
                    "include": [
                        "im"
                    ],
                    "exclude_bot_users": true
                },
                "action_id": "multi_users_select-action"
            },
            "label": {
                "type": "plain_text",
                "text": "Input type Select users",
                "emoji": true
            }
        }
    ]
}

关于javascript - Slack Block-kit Multi_users_select 删除默认应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67975904/

相关文章:

javascript - 多次声明同一个变量是一种好的做法

javascript - 如何将 JSON 数据添加到 nvd3 图表

android - 进程 'command ' Node ''以非零退出值 1 结束

php - 如何通过 php 或 wget 从 Slack 下载图像

javascript - 使用 Javascript 将一个字符串分成两个

git - 如何向我的 package.json 添加非 npm 依赖项?

node.js - 如何从 gulp 调用执行 PowerShell 脚本?

slack - 是否可以在 Slack (Linux) 中加粗单词的一部分?

python - Slack Bot - Python slack 发送 markdown 消息

javascript - 根据浏览器加载不同版本的jquery