Search code examples
javascriptnode.jsslackslack-apislack-block-kit

Slack Block-kit Multi_users_select Remove defaults app


I implemented a slack bot with um field of type input(multi_users_select). I would like to remove defaults apps from the list 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


Solution

  • Instead of type: 'multi_users_select' use "type": "multi_conversations_select" with filter as shown below to get only users in your workspace. You can copy and paste the below code in block-kit builder to test on your own. 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"
                }
            }
        ]
    }
    

    Update 05-Jul-21

    Included various other types of select users without bots/apps

    {
        "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
                }
            }
        ]
    }