Home

Awesome

Screenshot

Build status PyPI version Downloads


Blockkit is a Python library for building UI interfaces for Slack apps. It allows you to compose the interface from Python classes, so you type less, and your code becomes more maintainable.

Blockkit performs validation at runtime and provides user-friendly errors when data is invalid.

Generate

You don't even need to write code yourself. Go to https://blockkit.botsignals.co paste your JSON payload from Block Kit Builder and get corresponding Python code!

Screenshot

Installation

pip install blockkit

Usage

Start with one of the Home, Modal, or Message surface classes and follow the structure as you would follow it in JSON.

The library supports all types of surfaces, blocks, block elements, and composition objects Slack provides.

Once UI is ready, call the build() method to render components to dictionary:

from blockkit import Section, MarkdownText

Section(text=MarkdownText(text="hello world")).build()

{"type": "section", "text": {"text": "hello world", "type": "mrkdwn"}}

Here's the list of types of components and corresponding classes:

Surfaces

TypeClass
homeHome
modalModal
Message
workflow_stepWorkflowStep

Blocks

TypeClass
actionsActions
contextContext
dividerDivider
headerHeader
imageImageBlock
inputInput
rich_textRichText
sectionSection

Block elements

TypeClass
buttonButton
checkboxesCheckboxes
datepickerDatePicker
datetimepickerDatetimePicker
typeImage
multi_static_selectMultiStaticSelect
multi_users_selectMultiUsersSelect
multi_channels_selectMultiChannelsSelect
multi_conversations_selectMultiConversationsSelect
multi_external_selectMultiExternalSelect
overflowOverflow
plain_text_inputPlainTextInput
radio_buttonsRadioButtons
static_selectStaticSelect
users_selectUsersSelect
channels_selectChannelsSelect
conversations_selectConversationsSelect
external_selectExternalSelect
timepickerTimePicker
rich_text_listRichTextList
rich_text_preformattedRichTextPreformatted
rich_text_quoteRichTextQuote
rich_text_sectionRichTextSection
file_inputFileInput

Composition objects

TypeClass
plain_textPlainText
mrkdwnMarkdownText
textText
emojiEmoji
Style
Confirm
PlainOption
MarkdownOption
OptionGroup
Filter
DispatchActionConfig

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT