Module Gen Index

block

class slack_blockkit.block.Block(btype: str)

Base block class.

Parameters

btype (str) – Synonymous with Slack’s type parameter.

class slack_blockkit.block.RenderMixin

Provides a render method for blocks and similar payload structures.

render() → dict

Renders the block in a dict format appropriate for using within message payloads.

Returns

The block as a dict.

Return type

dict

block_element

class slack_blockkit.block_element.BlockElement(btype: str, action_id: str = None)

Defines a basic block element. For more information, see: https://api.slack.com/reference/block-kit/block-elements

Parameters
  • btype (str) – Synonymous with Slack’s type parameter.

  • action_id (str) – The unique action ID.

class slack_blockkit.block_element.ButtonElement(text: slack_blockkit.composition_object.TextObject, action_id: str, url: str = None, value: str = None, style: str = 'default', confirm: slack_blockkit.composition_object.ConfirmObject = None)

An interactive component that inserts a button. The button can be a trigger for anything from opening a simple link to starting a complex workflow. For more information, see: https://api.slack.com/reference/block-kit/block-elements#button

Parameters
  • text (TextObject) – A text object that defines the button’s text. Can only be of type: plain_text. Maximum length for the text in this field is 75 characters.

  • action_id (str) – An identifier for this action. You can use this when you receive an interaction payload to identify the source of the action. Should be unique among all other action_ids used elsewhere by your app. Maximum length for this field is 255 characters.

  • url (str) – A URL to load in the user’s browser when the button is clicked. Maximum length for this field is 3000 characters. If you’re using url, you’ll still receive an interaction payload and will need to send an acknowledgement response.

  • value (str) – The value to send along with the interaction payload. Maximum length for this field is 2000 characters.

  • style (str) –

    Decorates buttons with alternative visual color schemes. Use this option with restraint.

    primary gives buttons a green outline and text, ideal for affirmation or confirmation actions. primary should only be used for one button within a set.

    danger gives buttons a red outline and text, and should be used when the action is destructive. Use danger even more sparingly than primary.

    If you don’t include this field, the default button style will be used.

class slack_blockkit.block_element.DangerButtonElement(text: slack_blockkit.composition_object.TextObject, action_id: str, url: str = None, value: str = None, confirm: slack_blockkit.composition_object.ConfirmObject = None)

A ButtonElement whose style is danger.

Parameters
  • text (TextObject) – A text object that defines the button’s text. Can only be of type: plain_text. Maximum length for the text in this field is 75 characters.

  • action_id (str) – An identifier for this action. You can use this when you receive an interaction payload to identify the source of the action. Should be unique among all other action_ids used elsewhere by your app. Maximum length for this field is 255 characters.

  • url (str) – A URL to load in the user’s browser when the button is clicked. Maximum length for this field is 3000 characters. If you’re using url, you’ll still receive an interaction payload and will need to send an acknowledgement response.

  • value (str) – The value to send along with the interaction payload. Maximum length for this field is 2000 characters.

class slack_blockkit.block_element.DatepickerElement(action_id: str, placeholder: slack_blockkit.composition_object.TextObject, initial_date: str = None, confirm: slack_blockkit.composition_object.ConfirmObject = None)

An element which lets users easily select a date from a calendar style UI. For more information, see: https://api.slack.com/reference/block-kit/block-elements#datepicker

Parameters
  • action_id (str) – An identifier for the action triggered when a menu option is selected. You can use this when you receive an interaction payload to identify the source of the action. Should be unique among all other action_ids used elsewhere by your app. Maximum length for this field is 255 characters.

  • placeholder (TextObject) – A plain_text only text object that defines the placeholder text shown on the datepicker. Maximum length for the text in this field is 150 characters.

  • initial_date (str) – The initial date that is selected when the element is loaded. This should be in the format YYYY-MM-DD.

  • confirm (ConfirmObject) – A ConfirmObject that defines an optional confirmation dialog that appears after a date is selected.

class slack_blockkit.block_element.DefaultButtonElement(text: slack_blockkit.composition_object.TextObject, action_id: str, url: str = None, value: str = None, confirm: slack_blockkit.composition_object.ConfirmObject = None)

A ButtonElement whose style is default.

Parameters
  • text (TextObject) – A text object that defines the button’s text. Can only be of type: plain_text. Maximum length for the text in this field is 75 characters.

  • action_id (str) – An identifier for this action. You can use this when you receive an interaction payload to identify the source of the action. Should be unique among all other action_ids used elsewhere by your app. Maximum length for this field is 255 characters.

  • url (str) – A URL to load in the user’s browser when the button is clicked. Maximum length for this field is 3000 characters. If you’re using url, you’ll still receive an interaction payload and will need to send an acknowledgement response.

  • value (str) – The value to send along with the interaction payload. Maximum length for this field is 2000 characters.

class slack_blockkit.block_element.ImageElement(image_url: str, alt_text: str)

An element to insert an image as part of a larger block of content. If you want a block with only an image in it, you’re looking for the image block. For more information, see: https://api.slack.com/reference/block-kit/block-elements#image

Parameters
  • image_url (str) – The URL of the image to be displayed.

  • alt_text (str) – A plain-text summary of the image. This should not contain any markup.

class slack_blockkit.block_element.OverflowElement(action_id: str, options: List[slack_blockkit.composition_object.OptionObject], confirm: slack_blockkit.composition_object.ConfirmObject = None)

This is like a cross between a button and a select menu - when a user clicks on this overflow button, they will be presented with a list of options to choose from. Unlike the select menu, there is no typeahead field, and the button always appears with an ellipsis (“…”) rather than customisable text. For more information, see: https://api.slack.com/reference/block-kit/block-elements#overflow

Parameters
  • action_id (str) – An identifier for the action triggered when a menu option is selected. You can use this when you receive an interaction payload to identify the source of the action. Should be unique among all other action_id used elsewhere by your app. Maximum length for this field is 255 characters.

  • options (List[OptionObject]) – An array of OptionObject to display in the menu. Maximum number of options is 5, minimum is 2.

  • confirm (ConfirmObject) – A ConfirmObject that defines an optional confirmation dialog that appears after a menu item is selected.

class slack_blockkit.block_element.PlainTextInputElement(action_id: str, placeholder: slack_blockkit.composition_object.TextObject = None, initial_value: str = None, multiline: bool = False, min_length: int = 0, max_length: int = 0)

A plain-text input, similar to the HTML <input> tag, creates a field where a user can enter freeform data. It can appear as a single-line field or a larger textarea using the multiline flag. For more information, see: https://api.slack.com/reference/block-kit/block-elements#input

Parameters
  • action_id (str) – An identifier for the action triggered when a menu option is selected. You can use this when you receive an interaction payload to identify the source of the action. Should be unique among all other action_id used elsewhere by your app. Maximum length for this field is 255 characters.

  • placeholder (TextObject) – Optionall A plain_text only text object that defines the placeholder text shown in the plain-text input. Maximum length for the text in this field is 150 characters.

  • initial_value (str) – Optional; The initial value in the plain-text input when it is loaded.

  • multiline (bool) – Optional; Indicates whether the input will be a single line (False) or a larger textarea (True). Defaults to False.

  • min_length (int) – The minimum length of input that the user must provide. If the user provides less, they will receive an error. Maximum value is 3000.

  • max_length (int) – The maximum length of input that the user can provide. If the user provides more, they will receive an error.

class slack_blockkit.block_element.PrimaryButtonElement(text: slack_blockkit.composition_object.TextObject, action_id: str, url: str = None, value: str = None, confirm: slack_blockkit.composition_object.ConfirmObject = None)

A ButtonElement whose style is primary.

Parameters
  • text (TextObject) – A text object that defines the button’s text. Can only be of type: plain_text. Maximum length for the text in this field is 75 characters.

  • action_id (str) – An identifier for this action. You can use this when you receive an interaction payload to identify the source of the action. Should be unique among all other action_ids used elsewhere by your app. Maximum length for this field is 255 characters.

  • url (str) – A URL to load in the user’s browser when the button is clicked. Maximum length for this field is 3000 characters. If you’re using url, you’ll still receive an interaction payload and will need to send an acknowledgement response.

  • value (str) – The value to send along with the interaction payload. Maximum length for this field is 2000 characters.

class slack_blockkit.block_element.RadioButtonGroupElement(action_id: str, options: List[slack_blockkit.composition_object.OptionObject], intitial_option: slack_blockkit.composition_object.OptionObject = None, confirm: slack_blockkit.composition_object.ConfirmObject = None)

A radio button group that allows a user to choose one item from a list of possible options. For more information, see: https://api.slack.com/reference/block-kit/block-elements#radio

Parameters
  • action_id (str) – An identifier for the action triggered when a menu option is selected. You can use this when you receive an interaction payload to identify the source of the action. Should be unique among all other action_id used elsewhere by your app. Maximum length for this field is 255 characters.

  • options (List[OptionObject]) – An array of OptionObject.

  • initial_option (OptionObject) – An OptionObject that exactly matches one of the options within options. This option will be selected when the radio button group initially loads.

  • confirm (ConfirmObject) – A ConfirmObject that defines an optional confirmation dialog that appears after clicking one of the radio buttons in this element.

composition_object

class slack_blockkit.composition_object.ConfirmObject(title: slack_blockkit.composition_object.TextObject, text: slack_blockkit.composition_object.TextObject, confirm: slack_blockkit.composition_object.TextObject, deny: slack_blockkit.composition_object.TextObject, style: str = 'primary')

An object that defines a dialog that provides a confirmation step to any interactive element. This dialog will ask the user to confirm their action by offering a confirm and deny buttons. For more information, see: https://api.slack.com/reference/block-kit/composition-objects#confirm

Parameters
  • title (TextObject) – A plain_text -only TextObject that defines the dialog’s title. Maximum length for this field is 100 characters.

  • text (TextObject) – A TextObject that defines the explanatory text that appears in the confirm dialog. Maximum length for the text in this field is 300 characters.

  • confirm (TextObject) – A plain_text -only TextObject to define the text of the button that confirms the action. Maximum length for the text in this field is 30 characters.

  • deny (TextObject) – A plain_text -only TextObject to define the text of the button that cancels the action. Maximum length for the text in this field is 30 characters.

  • style (str) – Defines the color scheme applied to the confirm button. A value of danger will display the button with a red background on desktop, or red text on mobile. A value of primary will display the button with a green background on desktop, or blue text on mobile. If this field is not provided, the default value will be primary.

class slack_blockkit.composition_object.MarkdownTextObject(text: str, emoji: bool = False, verbatim: bool = False)

Represents a markdown text object. This is a TextObject where btype is set to mrkdwn.

Parameters
  • text (str) – The text for the block. This field accepts any of the standard text formatting markup when btype is mrkdwn.

  • verbatim (bool) – When set to false (as is default) URLs will be auto-converted into links, conversation names will be link-ified, and certain mentions will be automatically parsed. Using a value of True will skip any preprocessing of this nature, although you can still include manual parsing strings.

class slack_blockkit.composition_object.OptionGroupObject(label: slack_blockkit.composition_object.TextObject, options: List[slack_blockkit.composition_object.OptionObject])

Provides a way to group options in a select menu or multi-select menu. For more information, see: https://api.slack.com/reference/block-kit/composition-objects#option_group

Parameters
  • label (TextObject) – A plain_text only TextObject that defines the label shown above this group of options. Maximum length for the text in this field is 75 characters.

  • options (List[OptionObject]) – An array of OptionObject that belong to this specific group. Maximum of 100 items.

class slack_blockkit.composition_object.OptionObject(text: slack_blockkit.composition_object.TextObject, value: str, description: slack_blockkit.composition_object.TextObject = None, url: str = None)

An object that represents a single selectable item in a select menu, multi-select menu, radio button group, or overflow menu. For more information, see: https://api.slack.com/reference/block-kit/composition-objects#option

Parameters
  • text (TextObject) – A TextObject that defines the text shown in the option on the menu. Overflow, select, and multi-select menus can only use plain_text objects, while radio buttons and checkboxes can use mrkdwn text objects. Maximum length for the text in this field is 75 characters.

  • value (str) – The string value that will be passed to your app when this option is chosen. Maximum length for this field is 75 characters.

  • description (TextObject) – Optional; A plain_text only TextObject that defines a line of descriptive text shown below the text field beside the radio button. Maximum length for the text object within this field is 75 characters.

  • url (str) – A URL to load in the user’s browser when the option is clicked. The url attribute is only available in overflow menus. Maximum length for this field is 3000 characters. If you’re using url, you’ll still receive an interaction payload and will need to send an acknowledgement response.

class slack_blockkit.composition_object.PlainTextObject(text: str, emoji: bool = False)

Represents a plain-text object. This is a TextObject where btype is set to plain_text.

Parameters
  • text (str) – The text for the block. This field accepts any of the standard text formatting markup when btype is mrkdwn.

  • emoji (bool) – Indicates whether emojis in a text field should be escaped into the colon emoji format.

class slack_blockkit.composition_object.TextObject(btype: str, text: str, emoji: bool = False, verbatim: bool = False)

An object containing some text, formatted either as plain_text or using mrkdwn, our proprietary textual markup that’s just different enough from Markdown to frustrate you. https://api.slack.com/reference/block-kit/composition-objects#text

Parameters
  • btype (str) – The text for the block. This field accepts any of the standard text formatting markup when btype is mrkdwn.

  • text (str) – The text for the block. This field accepts any of the standard text formatting markup when btype is mrkdwn.

  • emoji (bool) – Indicates whether emojis in a text field should be escaped into the colon emoji format. This field is only usable when type is plain_text.

  • verbatim (bool) – When set to false (as is default) URLs will be auto-converted into links, conversation names will be link-ified, and certain mentions will be automatically parsed. Using a value of True will skip any preprocessing of this nature, although you can still include manual parsing strings. This field is only usable when btype is mrkdwn.

layout_block

class slack_blockkit.layout_block.ActionsBlock(elements: List[slack_blockkit.block_element.BlockElement], block_id: str = None)

A block that is used to hold interactive elements. For more information, see: https://api.slack.com/reference/block-kit/blocks#actions

Parameters
  • elements (List[BlockElement]) – An array of interactive element objects - buttons, select menus, overflow menus, or date pickers. There is a maximum of 5 elements in each action block.

  • block_id (str) – A string acting as a unique identifier for a block. You can use this block_id when you receive an interaction payload to identify the source of the action. If not specified, a block_id will be generated. Maximum length for this field is 255 characters.

class slack_blockkit.layout_block.ContextBlock(elements: list, block_id: str = None)

Displays message context, which can include both images and text. For more information, see: https://api.slack.com/reference/block-kit/blocks#context

Parameters
  • elements (List[BlockElement]) – An array of ImageElement and TextObjects. Maximum number of items is 10.

  • block_id (str) – A string acting as a unique identifier for a block. You can use this block_id when you receive an interaction payload to identify the source of the action. If not specified, a block_id will be generated. Maximum length for this field is 255 characters.

class slack_blockkit.layout_block.DividerBlock(block_id: str = None)

A content divider, like an <hr>, to split up different blocks inside of a message. The divider block is nice and neat, requiring only a type.For more information, see: https://api.slack.com/reference/block-kit/blocks#divider

Parameters

block_id (str) – A string acting as a unique identifier for a block. You can use this block_id when you receive an interaction payload to identify the source of the action. If not specified, a block_id will be generated. Maximum length for this field is 255 characters.

class slack_blockkit.layout_block.FileBlock(external_id: str, source: str = 'remote', block_id: str = None)

Displays a remote file. For more information, see: https://api.slack.com/reference/block-kit/blocks#file

Parameters
  • external_id (str) – The external unique ID for this file.

  • source (str) – At the moment, source will always be remote for a remote file.

  • block_id (str) – A string acting as a unique identifier for a block. You can use this block_id when you receive an interaction payload to identify the source of the action. If not specified, a block_id will be generated. Maximum length for this field is 255 characters.

class slack_blockkit.layout_block.ImageBlock(image_url: str, alt_text: str, title: slack_blockkit.composition_object.TextObject = None, block_id: str = None)

A simple image block, designed to make those cat photos really pop. For more information, see: https://api.slack.com/reference/block-kit/blocks#image

Parameters
  • image_url (str) – The URL of the image to be displayed. Maximum length for this field is 3000 characters.

  • alt_text (str) – A plain-text summary of the image. This should not contain any markup. Maximum length for this field is 2000 characters.

  • title (TextObject) – An optional title for the image in the form of a TextObject that can only be of type: plain_text. Maximum length for the text in this field is 2000 characters.

  • block_id (str) – A string acting as a unique identifier for a block. You can use this block_id when you receive an interaction payload to identify the source of the action. If not specified, a block_id will be generated. Maximum length for this field is 255 characters.

class slack_blockkit.layout_block.InputBlock(label: slack_blockkit.composition_object.TextObject, element: slack_blockkit.block_element.BlockElement, block_id: str = None, hint: slack_blockkit.composition_object.TextObject = None, optional: bool = False)

A block that collects information from users - it can hold a plain-text input element, a select menu element, a multi-select menu element, or a datepicker. For more information, see: https://api.slack.com/reference/block-kit/blocks#input

Parameters
  • label (TextObject) – A label that appears above an input element in the form of a TextObject that must have type of plain_text. Maximum length for the text in this field is 2000 characters.

  • element (BlockElement) – An plain-text input element, a select menu element, a multi-select menu element, or a datepicker.

  • block_id (str) – A string acting as a unique identifier for a block. You can use this block_id when you receive an interaction payload to identify the source of the action. If not specified, a block_id will be generated. Maximum length for this field is 255 characters.

  • hint (TextObject) – An optional hint that appears below an input element in a lighter grey. It must be a TextObject with a type of plain_text. Maximum length for the text in this field is 2000 characters.

  • optional (bool) – A boolean that indicates whether the input element may be empty when a user submits the modal. Defaults to False.

class slack_blockkit.layout_block.LayoutBlock(btype: str, block_id: str = None)

Defines a basic layout block. For more information, see: https://api.slack.com/reference/block-kit/blocks

Parameters
  • btype (str) – Synonymous with Slack’s type parameter.

  • block_id (str) –

    A string acting as a unique identifier for a block. You can use this block_id when you receive an interaction payload to identify the source of the action. If not specified, a block_id will be generated. Maximum length for this field is 255 characters.

    If not block_id is specified, a block_id is set to a random UUID v4.

static generate_block_id() → str

Generates a UUID (v4) to be used as a block ID.

Returns

A random UUID (v4) as a string.

Return type

str

class slack_blockkit.layout_block.SectionBlock(text: slack_blockkit.composition_object.TextObject, block_id: str = None, fields: List[slack_blockkit.composition_object.TextObject] = None, accessory: slack_blockkit.block_element.BlockElement = None)

Basic section block. For more information, see: https://api.slack.com/reference/block-kit/blocks#section

Parameters
  • text (TextObject) – The text for the block, in the form of a TextObject. Maximum length for the text in this field is 3000 characters. This field is not required if a valid array of fields objects is provided instead.

  • block_id (str) – A string acting as a unique identifier for a block. You can use this block_id when you receive an interaction payload to identify the source of the action. If not specified, a block_id will be generated. Maximum length for this field is 255 characters.

  • fields (List[TextObject]) – An array of TextObject. Any text objects included with fields will be rendered in a compact format that allows for 2 columns of side-by-side text. Maximum number of items is 10. Maximum length for the text in each item is 2000 characters.

  • accessory (BlockElement) – One of the available ElementObject.

view_playload

class slack_blockkit.view_payload.HomeViewPayload(title: slack_blockkit.composition_object.TextObject, blocks: List[slack_blockkit.block.Block], close: slack_blockkit.composition_object.TextObject = None, submit: slack_blockkit.composition_object.TextObject = None, private_metadata: str = None, callback_id: str = None, clear_on_close: bool = False, notify_on_close: bool = False, external_id: str = None)

Defines a home view payload. Syntactic sugar for the ViewPayload class where the btype is set to home.

class slack_blockkit.view_payload.ModalViewPayload(title: slack_blockkit.composition_object.TextObject, blocks: List[slack_blockkit.block.Block], close: slack_blockkit.composition_object.TextObject = None, submit: slack_blockkit.composition_object.TextObject = None, private_metadata: str = None, callback_id: str = None, clear_on_close: bool = False, notify_on_close: bool = False, external_id: str = None)

Defines a modal view payload. Syntactic sugar for the ViewPayload class where the btype is set to modal.

class slack_blockkit.view_payload.ViewPayload(btype: str, title: slack_blockkit.composition_object.TextObject, blocks: List[slack_blockkit.block.Block], close: slack_blockkit.composition_object.TextObject = None, submit: slack_blockkit.composition_object.TextObject = None, private_metadata: str = None, callback_id: str = None, clear_on_close: bool = False, notify_on_close: bool = False, external_id: str = None)

Defines a view payload. For more information, see: https://api.slack.com/reference/surfaces/views

get_payload() → dict

Syntactic sugar to return the render() payload as a dict.

Returns

The result of the render() method.