Skip to content

Modals & Views

Pumble's modals and views allow apps to create rich, interactive user interfaces beyond simple messages.

nametypeoptionaldescription
idStringtrueModal ID, output only.
typeStringfalseThe type on modal. In this case it is always MODAL.
blocksMainBlock[]falseDefinition of modal's content and layout. Can include rich_text, input, actions, section and divider blocks.
titleTextElementfalseA text object that defines the modal's title. Max length for the text field in this object is 75 characters.
stateStatetrueObject containing values of modal input fields (only input blocks contribute to state).
callbackIdStringfalseModal unique identifier that is used for routing submit and close events to the correct handlers. Handler names must match this value.
submitTextElementtrueA text object that defines the text of modal's submit button. Max length for the text field in this object is 75 characters. If omitted, a default submit button will be shown.
closeTextElementtrueA text object that defines the text of modal's close button. Max length for the text field in this object is 75 characters. If omitted, a default close button will be shown.
notifyOnCloseBooleanfalseSpecifies if the onClose handler should be triggered, when the modal is dismissed without submission.
parentViewIdStringtrueID of the parent modal in a modal stack, from which the current modal is spawned.
Modal example
json
{
    "type": "MODAL",
    "title": {
        "type": "plain_text",
        "text": "My First Modal"
    },
    "callbackId": "modal_callback",
    "submit": {
        "type": "text",
        "text": "Submit!"
    },
    "close": {
        "type": "text",
        "text": "Cancel"
    },
    "notifyOnClose": true,
    "blocks": [
        {
            "type": "rich_text",
            "elements": [
                {
                    "type": "rich_text_section",
                    "elements": [
                        {
                            "type": "text",
                            "text": "Welcome to this modal!"
                        }
                    ]
                }
            ]
        },
        {
            "type": "input",
            "blockId": "input_1",
            "label": {
                "text": "Select Menu Input field",
                "type": "plain_text"
            },
            "element": {
                "type": "static_select_menu",
                "placeholder": {
                    "text": "Select an option",
                    "type": "plain_text"
                },
                "onAction": "on_static_select_menu",
                "options": [
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "Option 1"
                        },
                        "value": "1"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "Option 2"
                        },
                        "value": "2"
                    }
                ]
            }
        },
        {
            "type": "input",
            "blockId": "input_2",
            "label": {
                "text": "Date Range Input field",
                "type": "plain_text"
            },
            "element": {
                "type": "date_range_picker",
                "onAction": "on_date_range_picked"
            }
        }
    ],
    "state": {
        "values": {
            "input_1": {
                "on_static_select_menu": {
                    "type": "static_select_menu",
                    "value": "2"
                }
            },
            "input_2": {
                "on_date_range_picked": {
                    "type": "date_range_picker",
                    "values": ["2026-01-01", "2026-01-01"]
                }
            }
        }
    }
}

Home view

nametypeoptionaldescription
idStringtrueHome view ID, output only.
typeStringfalseThe type of modal. In this case it is always HOME
blocksMainBlock[]falseDefinition of home view's content and layout. Can include rich_text, input, actions, section and divider blocks.
titleTextElementfalseA text object that defines the home view's title. Max length for the text field in this object is 75 characters.
stateStatetrueObject containing values of home view input fields (only input blocks contribute to state).
Home View example
json

{
    "title": {
        "type": "plain_text",
        "text": "My Home View"
    },
    "blocks": [
        {
            "type": "rich_text",
            "elements": [
                {
                    "type": "rich_text_section",
                    "elements": [
                        {
                            "type": "text",
                            "text": "Hello there "
                        },
                        {
                            "type": "emoji",
                            "name": "wave",
                            "skin_tone": 1
                        }
                    ]
                }
            ]
        },
        {
            "type": "actions",
            "elements": [
                {
                    "type": "button",
                    "onAction": "on_button_clicked",
                    "value": "test metadata",
                    "text": {
                        "type": "plain_text",
                        "text": "Click here!"
                    },
                    "style": "secondary"
                }
            ]
        }
    ]
}

Storage Integration

Storage integration modals are special modals that allow users to select externally stored files and send them in a Pumble channel. Currently, opening a Google Drive file picker modal in Pumble is supported. It will allow users to select a file from Google Drive, and send its link to a Pumble channel.

Google Drive integration modal

nametypeoptionaldescription
googleAccessTokenStringfasleUser's Google access token
googleAppIdStringfalseGoogle Cloud Project number
googleApiKeyStringfalseGoogle API Key
googleClientIdStringfalseGoogle OAuth 2.0 Client ID

State

Modal state is a nested object that maps input block's blockId and its element's onAction to the specified value(s):

typescript
values: {
    [key: string]: {  // input element's blockId value
        [key: string]: {  // actionable element's onAction value
            type: "button" | "static_select_menu" | "dynamic_select_menu" | "plain_text_input" | "date_picker";
            value: string;
        } | {
            type: "checkboxes" | "date_range_picker";
            values: string[];
        }
    }
}

ViewBuilder

ViewBuilder is a utility class, that helps with modification of View objects (modals and home views).

BlockInteractionContext and ViewActionContext contain a method that creates a ViewBuilder instance, from a given view. Then, it is possible to call methods on the ViewBuilder instance to modify view properties (blocks, state, title...), and to build the final view object.

ViewBuilder contains the following methods:

nametypedescription
updateBlocks(blocks: MainBlock[]) => ViewBuilderReplaces the existing view blocks with the new ones.
appendBlocks(blocks: MainBlock[]) => ViewBuilderAppends the new blocks to the existing view blocks.
prependBlocks(blocks: MainBlock[]) => ViewBuilderPrepends the new blocks to the existing view blocks.
insertBlocksAt(index: Number, blocks: MainBlock[]) => ViewBuilderInserts the new blocks starting from the specified index into the existing blocks.
removeBlockAt(index: Number) => ViewBuilderRemoves a block at the specified index from the existing view blocks.
removeBlocksAt(index: Number, deleteCount: Number) => ViewBuilderRemoves the specified number of blocks, starting at the specified index from the existing view blocks.
updateState(state: State) => ViewBuilderReplaces the existing view state with the new one.
updateTitle(title: TextElement) => ViewBuilderReplaces the existing view title with the new one.
updateCallbackId(callbackId: String) => ViewBuilderChanges the value of view's callback ID.
updateNotifyOnClose(notifyOnClose: Boolean) => ViewBuilderChanges the value that indicates if an action should be displatched when the view is closed.
updateSubmit(submit: TextElement) => ViewBuilderChanges the content of view's submit button.
removeSubmit() => ViewBuilderRemoves submit button from the view.
updateClose(close: TextElement) => ViewBuilderChanges the content of view's close button.
removeClose() => ViewBuilderRemoves submit close from the view.
build() => Modal | HomeViewReturns the final view object.

For more information about modals and views, visit Modals & Views guide and take a look at interactivity-examples.