glados.message_blocks module

class glados.message_blocks.ModalBuilder[source]

Bases: slack.web.classes.JsonObject

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: List[slack.web.classes.blocks.InteractiveElement], block_id: Optional[str] = None)[source]

A block that is used to hold interactive elements.

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

Parameters
  • elements – Up to 5 InteractiveElement objects - buttons, date pickers, etc

  • block_id – 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: str) → glados.message_blocks.ModalBuilder[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 – must not exceed 255 characters

callback_id_max_length()[source]
clear_on_close(clear_on_close: bool) → glados.message_blocks.ModalBuilder[source]

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

Parameters

clear_on_close – Default is false.

close(close: str) → glados.message_blocks.ModalBuilder[source]

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

Max length of 24 characters.

Parameters

close – must not exceed 24 characters

close_length()[source]
close_max_length = 24
context(*, elements: List[slack.web.classes.blocks.InteractiveElement], block_id: Optional[str] = None)[source]

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

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

Parameters
  • elements – Up to 10 ImageElements and TextObjects

  • block_id – ID to be used for this block - autogenerated if left blank. Cannot exceed 255 characters.

divider(*, block_id: Optional[str] = None)[source]

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

Parameters

block_id – 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: str) → glados.message_blocks.ModalBuilder[source]

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

Parameters

external_id – A unique identifier.

image(*, image_url: str, alt_text: str, title: Optional[str] = None, block_id: Optional[str] = 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 – Publicly hosted URL to be displayed. Cannot exceed 3000 characters.

  • alt_text – Plain text summary of image. Cannot exceed 2000 characters.

  • title – A title to be displayed above the image. Cannot exceed 2000 characters.

  • block_id – ID to be used for this block - autogenerated if left blank. Cannot exceed 255 characters.

notify_on_close(notify_on_close: bool) → glados.message_blocks.ModalBuilder[source]

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

Parameters

notify_on_close – Default is false.

private_metadata(private_metadata: str) → glados.message_blocks.ModalBuilder[source]

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

Parameters

private_metadata – must not exceed 3000 characters

private_metadata_max_length()[source]
section(*, text: Union[str, slack.web.classes.objects.TextObject] = None, block_id: Optional[str] = None, fields: List[str] = None, accessory: Optional[slack.web.classes.blocks.BlockElement] = None) → glados.message_blocks.ModalBuilder[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 – 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 – 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: 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 – an optional BlockElement to attach to this SectionBlock as secondary content

submit(submit: str) → glados.message_blocks.ModalBuilder[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 – must not exceed 24 characters

submit_length()[source]
submit_max_length = 24
title(title: str) → glados.message_blocks.ModalBuilder[source]

Specify a title for this modal

Parameters

title – must not exceed 24 characters

title_length()[source]
title_max_length = 24
to_dict() → dict[source]