Skip to main content

Composition objects

AlertLevel

Function

AlertLevel(*args, **kwargs)

No public documentation is available.

AreaChart

Class

AreaChart(series: 'list[DataSeries]', axis_config: 'AxisConfig') -> 'None'

A layered area chart, for use in a DataVisualizationBlock.

See: https://docs.slack.dev/reference/block-kit/blocks/data-visualization-block.

Arguments

ArgumentTypeDescription
serieslist[DataSeries]a list of between 1 and 12 uniquely named DataSeries
objects.
axis_configAxisConfigan AxisConfig defining the chart's category labels
and optional axis titles.

Errors

ErrorWhen
InvalidUsageErrorif any of the provided arguments fail validation.

AxisConfig

Class

AxisConfig(categories: 'list[str]', x_label: 'str | None' = None, y_label: 'str | None' = None) -> 'None'

Category labels and optional axis titles for a bar, area, or line chart.

See: https://docs.slack.dev/reference/block-kit/blocks/data-visualization-block.

Arguments

ArgumentTypeDescription
categorieslist[str]a list of between 1 and 20 unique category labels
(max 20 chars each).
x_labelstr | Nonean optional title for the x-axis (max 50 chars).
y_labelstr | Nonean optional title for the y-axis (max 50 chars).

Errors

ErrorWhen
InvalidUsageErrorif any of the provided arguments fail validation.

BarChart

Class

BarChart(series: 'list[DataSeries]', axis_config: 'AxisConfig') -> 'None'

A grouped bar chart, for use in a DataVisualizationBlock.

See: https://docs.slack.dev/reference/block-kit/blocks/data-visualization-block.

Arguments

ArgumentTypeDescription
serieslist[DataSeries]a list of between 1 and 12 uniquely named DataSeries
objects.
axis_configAxisConfigan AxisConfig defining the chart's category labels
and optional axis titles.

Errors

ErrorWhen
InvalidUsageErrorif any of the provided arguments fail validation.

Chart

Value

Chart

Represent a union type

E.g. for int | str

ChartSegment

Class

ChartSegment(label: 'str', value: 'int | float') -> 'None'

A labelled, positive-valued slice in a PieChart.

See: https://docs.slack.dev/reference/block-kit/blocks/data-visualization-block.

Arguments

ArgumentTypeDescription
labelstrthe label for the segment (max 20 chars).
valueint | floatthe numeric value of the segment; must be greater than 0.

Errors

ErrorWhen
InvalidUsageErrorif any of the provided arguments fail validation.

ColumnSettings

Class

ColumnSettings(align: 'ColumnAlignment | None' = None, is_wrapped: 'bool | None' = None) -> 'None'

An object that defines the settings for a column in a Table block.

Arguments

ArgumentTypeDescription
alignColumnAlignment | Nonethe alignment of the column, one of left, center, or right.
is_wrappedbool | Nonewhether the text in the column should be wrapped.

Confirm

Class

Confirm(*args, **kwargs) -> 'None'

Alias for ConfirmationDialogue to retain backwards compatibility.

See: ConfirmationDialogue.

from_dict

from_dict(data: 'dict[str, Any]') -> 'ConfirmationDialogue'

Parse a Slack confirm composition object back into an instance.

Errors

ErrorWhen
MissingRequiredErrorif any of title, text, confirm,
deny is absent.

ConfirmationDialogue

Class

ConfirmationDialogue(title: 'TextLike', text: 'TextLike', confirm: 'TextLike', deny: 'TextLike') -> 'None'

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 confirm and deny buttons.

Arguments

ArgumentTypeDescription
titleTextLikethe text heading presented at the top of the dialogue box (max 100 chars).
textTextLikethe text explaining the decision being made by the user through
the dialogue box (max 300 chars).
confirmTextLikethe text inside the confirmation button of the dialogue box (max 30 chars).
denyTextLikethe text inside the deny button of the dialogue box (max 30 chars).

Errors

ErrorWhen
InvalidUsageErrorif any of the arguments fail to pass validation checks.

from_dict

from_dict(data: 'dict[str, Any]') -> 'ConfirmationDialogue'

Parse a Slack confirm composition object back into an instance.

Errors

ErrorWhen
MissingRequiredErrorif any of title, text, confirm,
deny is absent.

ContainerWidth

Function

ContainerWidth(*args, **kwargs)

No public documentation is available.

ConversationFilter

Class

ConversationFilter(include: 'ConversationType | list[ConversationType] | None' = None, exclude_external_shared_channels: 'bool | None' = None, exclude_bot_users: 'bool | None' = None) -> 'None'

Provides a way to filter the list of options in a conversations select menu or conversations multi-select menu.

See: https://api.slack.com/reference/block-kit/composition-objects#filter_conversations.

At least one of the available arguments must be provided.

Arguments

ArgumentTypeDescription
includeConversationType | list[ConversationType] | NoneWhich types of conversations to include in the list.
One of more of im, mpim, private, public.
exclude_external_shared_channelsbool | Nonewhether to remove shared public channels
from the list. See https://api.slack.com/enterprise/shared-channels.
exclude_bot_usersbool | Nonewhether to remove bot users from the list of conversations.

Errors

ErrorWhen
InvalidUsageExceptionin the event that the user provides none of include,
exclude_external_shared_channels, or exclude_bot_users arguments.

from_dict

from_dict(data: 'dict[str, Any]') -> 'ConversationFilter'

Parse a Slack filter composition object.

At least one of include, exclude_external_shared_channels, or exclude_bot_users must be present; otherwise the underlying constructor raises MissingRequiredError.

DataPoint

Class

DataPoint(label: 'str', value: 'int | float') -> 'None'

One labelled numeric point in an axis-based chart (a BarChart, AreaChart, or LineChart).

See: https://docs.slack.dev/reference/block-kit/blocks/data-visualization-block.

Arguments

ArgumentTypeDescription
labelstrthe label for the data point (max 20 chars); must match one
of the categories in the chart's AxisConfig.
valueint | floatthe numeric value of the data point.

Errors

ErrorWhen
InvalidUsageErrorif any of the provided arguments fail validation.

DataSeries

Class

DataSeries(name: 'str', data: 'list[DataPoint]') -> 'None'

A named series containing between 1 and 20 chart data points.

See: https://docs.slack.dev/reference/block-kit/blocks/data-visualization-block.

Arguments

ArgumentTypeDescription
namestrthe name of the series (max 20 chars).
datalist[DataPoint]a list of between 1 and 20 DataPoint objects; there must
be exactly one point for every category in the chart's
AxisConfig.

Errors

ErrorWhen
InvalidUsageErrorif any of the provided arguments fail validation.

DispatchActionConfiguration

Class

DispatchActionConfiguration(trigger_actions_on: 'str | list[str] | None' = None) -> 'None'

Determines when a plain-text input element will return a block_actions interaction payload.

Arguments

ArgumentTypeDescription
trigger_actions_onstr | list[str] | Nonea list of strings representing interaction types that should return
a block_actions payload. One or both of on_enter_pressed, on_character_entered.

Errors

ErrorWhen
InvalidUsageErrorif an invalid value is provided amongst the options for
trigger_actions_on.

from_dict

from_dict(data: 'dict[str, Any]') -> 'DispatchActionConfiguration'

Parse a Slack dispatch_action_config composition object.

InputParameter

Class

InputParameter(name: 'str', value: 'str') -> 'None'

Contains information about an input parameter.

See https://api.slack.com/automation/workflows#defining-input-parameters.

Arguments

ArgumentTypeDescription
namestrthe name of the input parameter.
valuestrthe value associated with the input parameter.

from_dict

from_dict(data: 'dict[str, Any]') -> 'InputParameter'

Parse a Slack input_parameter composition object.

LineChart

Class

LineChart(series: 'list[DataSeries]', axis_config: 'AxisConfig') -> 'None'

A line chart, for use in a DataVisualizationBlock.

See: https://docs.slack.dev/reference/block-kit/blocks/data-visualization-block.

Arguments

ArgumentTypeDescription
serieslist[DataSeries]a list of between 1 and 12 uniquely named DataSeries
objects.
axis_configAxisConfigan AxisConfig defining the chart's category labels
and optional axis titles.

Errors

ErrorWhen
InvalidUsageErrorif any of the provided arguments fail validation.

Markdown

Class

Markdown(text: 'str', verbatim: 'bool' = False) -> 'None'

Convenience wrapper for Text with type_=TextType.MARKDOWN.

Markdown("_italic_", verbatim=True) is equivalent to Text("_italic_", type_=TextType.MARKDOWN, verbatim=True). Anywhere a Text or TextLike is accepted, a Markdown works because Markdown is a subclass of Text. The rendered JSON is identical to the equivalent Text call.

Arguments

ArgumentTypeDescription
textstrthe markdown-formatted text to render (1-3000 characters).
verbatimboolif True, links, channel names, and user names are
rendered verbatim rather than as Slack-style references.

Errors

ErrorWhen
LengthErrorif the provided text is empty or too long.

from_dict

from_dict(data: 'dict[str, Any]') -> 'Text'

Parse a Slack-shaped text composition object back into a Text.

Unknown fields are ignored so that future Slack additions do not break round-tripping.

Arguments

ArgumentTypeDescription
dataNonea dict matching the Slack text composition-object shape,
e.g. {"type": "mrkdwn", "text": "hi", "verbatim": True}.

Returns

TypeDescription
NoneA Text instance.

Errors

ErrorWhen
MissingRequiredErrorif data["text"] is absent.
TypeMismatchErrorif data["type"] is not one of the
allowable TextType values.

to_text

to_text(text: 'str | Text | None', force_plaintext: 'bool' = False, max_length: 'int | None' = None, allow_none: 'bool' = False) -> 'Text | None'

Coerces str or Text objects into Text objects.

Arguments

ArgumentTypeDescription
textNonethe str or Text object to ensure is in Text format.
force_plaintextNoneif True, forces the str or Text object
into a Text object with the type TextType.PLAINTEXT.
max_lengthNonetext will be checked against this length in addition
to the standard Text limit of 3000 characters.
allow_noneNonewhether to accept None as a valid value for text.
The return type narrows based on this value:

- allow_none=False (the default) -> always returns Text.
- allow_none=True -> returns Text | None.

to_text_nonnull

to_text_nonnull(text: 'str | Text', force_plaintext: 'bool' = False, max_length: 'int | None' = None) -> 'Text'

Coerces str or Text objects into Text objects, but does not allow None values.

Arguments

ArgumentTypeDescription
textNonethe str or Text object to ensure is in Text format.
force_plaintextNoneif True, forces the str or Text object
into a Text object with the type TextType.PLAINTEXT.
max_lengthNonetext will be checked against this length in addition
to the standard Text limit of 3000 characters.

Returns

TypeDescription
NoneA Text object created from the input.

Errors

ErrorWhen
InvalidUsageErrorif the text length exceeds the specified max_length.

Option

Class

Option(text: 'TextLike', value: 'str', description: 'TextLike | None' = None, url: 'str | None' = None) -> 'None'

An object that represents a single selectable item in a select menu, multi-select menu, checkbox group, radio button group, or overflow menu.

See https://api.slack.com/reference/block-kit/composition-objects#option.

Arguments

ArgumentTypeDescription
textTextLikethe text identifying the option (that the user will see).
valuestrthe underlying value of that option (not seen by the user).
descriptionTextLike | Nonea more detailed explanation of what the option means (user-facing).
urlstr | Nonea URL to load in the user's browser when the option is clicked.
Only available in OverflowMenus.

Errors

ErrorWhen
InvalidUsageErrorwhen any of the provided arguments fail validation.

from_dict

from_dict(data: 'dict[str, Any]') -> 'Option'

Parse a Slack option composition object back into an Option.

Errors

ErrorWhen
MissingRequiredErrorif text or value is absent.

OptionGroup

Class

OptionGroup(label: 'TextLike', options: 'list[Option]') -> 'None'

Provides a way to group options in a select menu or multi-select menu.

See https://api.slack.com/reference/block-kit/composition-objects#option_group.

Arguments

ArgumentTypeDescription
labelTextLikea label shown above the group of options.
optionslist[Option]a list of Option objects that will form the contents of the group (max 100).

Errors

ErrorWhen
InvalidUsageErrorif no options are provided or the label is not valid.

from_dict

from_dict(data: 'dict[str, Any]') -> 'OptionGroup'

Parse a Slack option_group composition object.

Errors

ErrorWhen
MissingRequiredErrorif label or options is absent.

PieChart

Class

PieChart(segments: 'list[ChartSegment]') -> 'None'

A pie chart containing between 1 and 12 segments, for use in a DataVisualizationBlock.

See: https://docs.slack.dev/reference/block-kit/blocks/data-visualization-block.

Arguments

ArgumentTypeDescription
segmentslist[ChartSegment]a list of between 1 and 12 ChartSegment objects.

Errors

ErrorWhen
InvalidUsageErrorif any of the provided arguments fail validation.

PlainText

Class

PlainText(text: 'str', emoji: 'bool' = False) -> 'None'

Convenience wrapper for Text with type_=TextType.PLAINTEXT.

PlainText("Hi", emoji=True) is equivalent to Text("Hi", type_=TextType.PLAINTEXT, emoji=True). Anywhere a Text or TextLike is accepted, a PlainText works because PlainText is a subclass of Text. The rendered JSON is identical to the equivalent Text call.

Arguments

ArgumentTypeDescription
textstrthe text to render (1-3000 characters).
emojiboolif True, emoji (e.g. :smile:) are escaped into Unicode.

Errors

ErrorWhen
LengthErrorif the provided text is empty or too long.

from_dict

from_dict(data: 'dict[str, Any]') -> 'Text'

Parse a Slack-shaped text composition object back into a Text.

Unknown fields are ignored so that future Slack additions do not break round-tripping.

Arguments

ArgumentTypeDescription
dataNonea dict matching the Slack text composition-object shape,
e.g. {"type": "mrkdwn", "text": "hi", "verbatim": True}.

Returns

TypeDescription
NoneA Text instance.

Errors

ErrorWhen
MissingRequiredErrorif data["text"] is absent.
TypeMismatchErrorif data["type"] is not one of the
allowable TextType values.

to_text

to_text(text: 'str | Text | None', force_plaintext: 'bool' = False, max_length: 'int | None' = None, allow_none: 'bool' = False) -> 'Text | None'

Coerces str or Text objects into Text objects.

Arguments

ArgumentTypeDescription
textNonethe str or Text object to ensure is in Text format.
force_plaintextNoneif True, forces the str or Text object
into a Text object with the type TextType.PLAINTEXT.
max_lengthNonetext will be checked against this length in addition
to the standard Text limit of 3000 characters.
allow_noneNonewhether to accept None as a valid value for text.
The return type narrows based on this value:

- allow_none=False (the default) -> always returns Text.
- allow_none=True -> returns Text | None.

to_text_nonnull

to_text_nonnull(text: 'str | Text', force_plaintext: 'bool' = False, max_length: 'int | None' = None) -> 'Text'

Coerces str or Text objects into Text objects, but does not allow None values.

Arguments

ArgumentTypeDescription
textNonethe str or Text object to ensure is in Text format.
force_plaintextNoneif True, forces the str or Text object
into a Text object with the type TextType.PLAINTEXT.
max_lengthNonetext will be checked against this length in addition
to the standard Text limit of 3000 characters.

Returns

TypeDescription
NoneA Text object created from the input.

Errors

ErrorWhen
InvalidUsageErrorif the text length exceeds the specified max_length.

RawNumber

Class

RawNumber(value: 'int | float', text: 'str') -> 'None'

A numeric cell for a DataTableBlock.

See: https://docs.slack.dev/reference/block-kit/blocks/data-table-block.

Arguments

ArgumentTypeDescription
valueint | floatthe numeric value Slack uses for sorting and display.
textstrthe non-empty text Slack displays in the cell.

Errors

ErrorWhen
InvalidUsageErrorif any of the provided arguments fail validation.

RawText

Class

RawText(text: 'str', emoji: 'bool' = False) -> 'None'

An object containing some text, formatted as raw_text for use in Table blocks.

Arguments

ArgumentTypeDescription
textstrthe text to be rendered in a message.
emojiboolonly usable with TextType.PLAINTEXT, if True: emoji will be
escaped into text format (e.g. :smile:).

Errors

ErrorWhen
InvalidUsageExceptionif the provided text fails validation.

SlackFile

Class

SlackFile(url: 'str | None', id: 'str | None') -> 'None'

Defines an object containing Slack file information to be used in an image block or image element.

This file must be an image and you must provide either the URL or ID (not both).

See: https://api.slack.com/reference/block-kit/composition-objects#slack_file.

Arguments

ArgumentTypeDescription
urlstr | Nonethe URL can be the url_private or the permalink of the Slack file
(only one of url or id can be provided).
idstr | Nonethe Slack ID of the file
(only one of url or id can be provided).

Errors

ErrorWhen
InvalidUsageErrorif both url and id are provided

from_dict

from_dict(data: 'dict[str, Any]') -> 'SlackFile'

Parse a Slack slack_file composition object.

SlackIcon

Class

SlackIcon(name: 'SlackIconName') -> 'None'

A named Slack-provided icon for a CardBlock.

See: https://docs.slack.dev/reference/block-kit/blocks/card-block.

Arguments

ArgumentTypeDescription
nameSlackIconNamethe name of a Slack-provided icon, e.g. bot or rocket
(see SlackIconName for the full list of valid names).

Errors

ErrorWhen
TypeMismatchErrorif name is not a recognised Slack icon name.

SlackIconName

Function

SlackIconName(*args, **kwargs)

No public documentation is available.

TaskStatus

Function

TaskStatus(*args, **kwargs)

No public documentation is available.

Text

Class

Text(text: 'str', type_: 'TextType' = <TextType.MARKDOWN: 'mrkdwn'>, emoji: 'bool' = False, verbatim: 'bool' = False) -> 'None'

An object containing some text, formatted either as plain_text or using Slack's mrkdwn.

Arguments

ArgumentTypeDescription
textstrthe text to be rendered in a message (max 3000 characters).
type_TextTypeeither TextType.MARKDOWN or TextType.PLAINTEXT.
emojiboolonly usable with TextType.PLAINTEXT, if True: emoji will be
escaped into text format (e.g. :smile:).
verbatimboolonly usable with TextType.MARKDOWN, if True: links, channel
names, user names will not automatically be rendered as links.

Errors

ErrorWhen
InvalidUsageExceptionif the provided text fails validation.

from_dict

from_dict(data: 'dict[str, Any]') -> 'Text'

Parse a Slack-shaped text composition object back into a Text.

Unknown fields are ignored so that future Slack additions do not break round-tripping.

Arguments

ArgumentTypeDescription
datadict[str, Any]a dict matching the Slack text composition-object shape,
e.g. {"type": "mrkdwn", "text": "hi", "verbatim": True}.

Returns

TypeDescription
TextA Text instance.

Errors

ErrorWhen
MissingRequiredErrorif data["text"] is absent.
TypeMismatchErrorif data["type"] is not one of the
allowable TextType values.

to_text

to_text(text: 'str | Text | None', force_plaintext: 'bool' = False, max_length: 'int | None' = None, allow_none: 'bool' = False) -> 'Text | None'

Coerces str or Text objects into Text objects.

Arguments

ArgumentTypeDescription
textstr | Text | Nonethe str or Text object to ensure is in Text format.
force_plaintextboolif True, forces the str or Text object
into a Text object with the type TextType.PLAINTEXT.
max_lengthint | Nonetext will be checked against this length in addition
to the standard Text limit of 3000 characters.
allow_noneboolwhether to accept None as a valid value for text.
The return type narrows based on this value:

- allow_none=False (the default) -> always returns Text.
- allow_none=True -> returns Text | None.

to_text_nonnull

to_text_nonnull(text: 'str | Text', force_plaintext: 'bool' = False, max_length: 'int | None' = None) -> 'Text'

Coerces str or Text objects into Text objects, but does not allow None values.

Arguments

ArgumentTypeDescription
textstr | Textthe str or Text object to ensure is in Text format.
force_plaintextboolif True, forces the str or Text object
into a Text object with the type TextType.PLAINTEXT.
max_lengthint | Nonetext will be checked against this length in addition
to the standard Text limit of 3000 characters.

Returns

TypeDescription
TextA Text object created from the input.

Errors

ErrorWhen
InvalidUsageErrorif the text length exceeds the specified max_length.

TextType

Class

TextType(*values)

Allowable types for Slack Text objects.

MARKDOWN: traditional markdown formatting, see https://api.slack.com/reference/surfaces/formatting#basic-formatting PLAINTEXT: simple Unicode text with no formatting (e.g. bold) features.

N.B: some usages of Text objects only allow the PLAINTEXT variety.

Trigger

Class

Trigger(url: 'str', customizable_input_parameters: 'InputParameter | list[InputParameter] | None') -> 'None'

Contains information about a trigger.

See: https://api.slack.com/automation/triggers.

Arguments

ArgumentTypeDescription
urlstra link trigger URL, see
https://api.slack.com/automation/triggers/link
customizable_input_parametersInputParameter | list[InputParameter] | Nonea list of InputParameter objects
which map to those parameters defined on the Workflow in
which they are provided.

Errors

ErrorWhen
InvalidUsageErrorwhen any of the items in
customizable_input_parameters is not a valid InputParameter.

from_dict

from_dict(data: 'dict[str, Any]') -> 'Trigger'

Parse a Slack trigger composition object.

Workflow

Class

Workflow(trigger: 'Trigger') -> 'None'

Contains information about a workflow.

See https://api.slack.com/automation/workflows.

Arguments

ArgumentTypeDescription
triggerTriggera Trigger object that will initiate the workflow.

from_dict

from_dict(data: 'dict[str, Any]') -> 'Workflow'

Parse a Slack workflow composition object.

from_url

from_url(url: 'str', **input_parameters: 'str') -> 'Workflow'

Build a Workflow from a trigger URL and input parameters in one call.

Workflow.from_url(url, a='1', b='2') is equivalent to::

Workflow( trigger=Trigger( url=url, customizable_input_parameters=[ InputParameter(name='a', value='1'), InputParameter(name='b', value='2'), ], ), )

When no input parameters are supplied, the resulting trigger has customizable_input_parameters=None (the key is omitted from JSON).

Arguments

ArgumentTypeDescription
urlstrthe link trigger URL.
**input_parametersstrzero or more name=value pairs that become
InputParameter entries on the trigger.

Returns

TypeDescription
WorkflowA new Workflow instance.