Message Blocks

class glados.message_blocks.ModalBuilder[source]

Bases: sphinx.ext.autodoc.importer._MockObject

The ModalBuilder enables you to more easily construct the JSON required to create a modal in Slack.

Modals are a focused surface to collect data from users or display dynamic and interactive information.

To learn how modals are invoked, how to compose their contents, and how to enable and handle complex interactivity read this guide:

https://api.slack.com/block-kit/surfaces/modals

actions(*, elements, block_id=None)[source]

A block that is used to hold interactive elements.

https://api.slack.com/reference/block-kit/blocks#actions

Parameters:
  • elements (List[MockObject]) – Up to 5 InteractiveElement objects - buttons, date pickers, etc
  • block_id (Optional[str]) – ID to be used for this block - autogenerated if left blank. Cannot exceed 255 characters.
attributes = {'_blocks', '_callback_id', '_clear_on_close', '_close', '_external_id', '_notify_on_close', '_private_metadata', '_submit', '_title'}
blocks_length()[source]
blocks_max_length = 100
callback_id(callback_id)[source]

An identifier to recognize interactions and submissions of this particular modal. Don’t use this to store sensitive information (use private_metadata instead).

Parameters:callback_id (str) – must not exceed 255 characters
Return type:ModalBuilder
callback_id_max_length()[source]
clear_on_close(clear_on_close)[source]

When set to true, clicking on the close button will clear all views in a modal and close it.

Parameters:clear_on_close (bool) – Default is false.
Return type:ModalBuilder
close(close)[source]

Specify the text displayed in the close button at the bottom-right of the view.

Max length of 24 characters.

Parameters:close (str) – must not exceed 24 characters
Return type:ModalBuilder
close_length()[source]
close_max_length = 24
context(*, elements, block_id=None)[source]

Displays message context, which can include both images and text.

https://api.slack.com/reference/block-kit/blocks#context

Parameters:
  • elements (List[MockObject]) – Up to 10 ImageElements and TextObjects
  • block_id (Optional[str]) – ID to be used for this block - autogenerated if left blank. Cannot exceed 255 characters.
divider(*, block_id=None)[source]

A content divider, like an <hr>, to split up different blocks inside of a message.

Parameters:block_id (Optional[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 docs-src of the action. If not specified, one will be generated. Maximum length for this field is 255 characters. block_id should be unique for each message and each iteration of a message. If a message is updated, use a new block_id.

https://api.slack.com/reference/block-kit/blocks#divider

external_id(external_id)[source]

A custom identifier that must be unique for all views on a per-team basis.

Parameters:external_id (str) – A unique identifier.
Return type:ModalBuilder
image(*, image_url, alt_text, title=None, block_id=None)[source]

A simple image block, designed to make those cat photos really pop.

https://api.slack.com/reference/block-kit/blocks#image

Parameters:
  • image_url (str) – Publicly hosted URL to be displayed. Cannot exceed 3000 characters.
  • alt_text (str) – Plain text summary of image. Cannot exceed 2000 characters.
  • title (Optional[str]) – A title to be displayed above the image. Cannot exceed 2000 characters.
  • block_id (Optional[str]) – ID to be used for this block - autogenerated if left blank. Cannot exceed 255 characters.
notify_on_close(notify_on_close)[source]

Indicates whether Slack will send your request URL a view_closed event when a user clicks the close button.

Parameters:notify_on_close (bool) – Default is false.
Return type:ModalBuilder
private_metadata(private_metadata)[source]

An optional string that will be sent to your app in view_submission and block_actions events.

Parameters:private_metadata (str) – must not exceed 3000 characters
Return type:ModalBuilder
private_metadata_max_length()[source]
section(*, text=None, block_id=None, fields=None, accessory=None)[source]

A section is one of the most flexible blocks available. It can be used as a simple text block, in combination with text fields, or side-by-side with any of the available block elements.

https://api.slack.com/reference/block-kit/blocks#section

Parameters:
  • text (Union[str, MockObject, None]) – The text for the block, in the form of string or a text object. Maximum length for the text in this field is 3000 characters.
  • block_id (Optional[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 docs-src of the action. If not specified, one will be generated. Maximum length for this field is 255 characters. block_id should be unique for each message and each iteration of a message. If a message is updated, use a new block_id.
  • fields (Optional[List[str]]) – optional: a sequence of strings that will be rendered using MarkdownTextObjects. Any strings 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 (Optional[MockObject]) – an optional BlockElement to attach to this SectionBlock as secondary content
Return type:

ModalBuilder

submit(submit)[source]

Specify the text displayed in the submit button at the bottom-right of the view.

Important Note: submit is required when an input block is within the blocks array.

Max length of 24 characters.

Parameters:submit (str) – must not exceed 24 characters
Return type:ModalBuilder
submit_length()[source]
submit_max_length = 24
title(title)[source]

Specify a title for this modal

Parameters:title (str) – must not exceed 24 characters
Return type:ModalBuilder
title_length()[source]
title_max_length = 24
to_dict()[source]
Return type:dict