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
| Argument | Type | Description |
|---|---|---|
series | list[DataSeries] | a list of between 1 and 12 uniquely named DataSeriesobjects. |
axis_config | AxisConfig | an AxisConfig defining the chart's category labelsand optional axis titles. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Argument | Type | Description |
|---|---|---|
categories | list[str] | a list of between 1 and 20 unique category labels (max 20 chars each). |
x_label | str | None | an optional title for the x-axis (max 50 chars). |
y_label | str | None | an optional title for the y-axis (max 50 chars). |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Argument | Type | Description |
|---|---|---|
series | list[DataSeries] | a list of between 1 and 12 uniquely named DataSeriesobjects. |
axis_config | AxisConfig | an AxisConfig defining the chart's category labelsand optional axis titles. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Argument | Type | Description |
|---|---|---|
label | str | the label for the segment (max 20 chars). |
value | int | float | the numeric value of the segment; must be greater than 0. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Argument | Type | Description |
|---|---|---|
align | ColumnAlignment | None | the alignment of the column, one of left, center, or right. |
is_wrapped | bool | None | whether 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
| Error | When |
|---|---|
MissingRequiredError | if 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
| Argument | Type | Description |
|---|---|---|
title | TextLike | the text heading presented at the top of the dialogue box (max 100 chars). |
text | TextLike | the text explaining the decision being made by the user through the dialogue box (max 300 chars). |
confirm | TextLike | the text inside the confirmation button of the dialogue box (max 30 chars). |
deny | TextLike | the text inside the deny button of the dialogue box (max 30 chars). |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Error | When |
|---|---|
MissingRequiredError | if 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
| Argument | Type | Description |
|---|---|---|
include | ConversationType | list[ConversationType] | None | Which types of conversations to include in the list. One of more of im, mpim, private, public. |
exclude_external_shared_channels | bool | None | whether to remove shared public channels from the list. See https://api.slack.com/enterprise/shared-channels. |
exclude_bot_users | bool | None | whether to remove bot users from the list of conversations. |
Errors
| Error | When |
|---|---|
InvalidUsageException | in 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
| Argument | Type | Description |
|---|---|---|
label | str | the label for the data point (max 20 chars); must match one of the categories in the chart's AxisConfig. |
value | int | float | the numeric value of the data point. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Argument | Type | Description |
|---|---|---|
name | str | the name of the series (max 20 chars). |
data | list[DataPoint] | a list of between 1 and 20 DataPoint objects; there mustbe exactly one point for every category in the chart's AxisConfig. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Argument | Type | Description |
|---|---|---|
trigger_actions_on | str | list[str] | None | a list of strings representing interaction types that should return a block_actions payload. One or both of on_enter_pressed, on_character_entered. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if an invalid value is provided amongst the options fortrigger_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
| Argument | Type | Description |
|---|---|---|
name | str | the name of the input parameter. |
value | str | the 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
| Argument | Type | Description |
|---|---|---|
series | list[DataSeries] | a list of between 1 and 12 uniquely named DataSeriesobjects. |
axis_config | AxisConfig | an AxisConfig defining the chart's category labelsand optional axis titles. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Argument | Type | Description |
|---|---|---|
text | str | the markdown-formatted text to render (1-3000 characters). |
verbatim | bool | if True, links, channel names, and user names arerendered verbatim rather than as Slack-style references. |
Errors
| Error | When |
|---|---|
LengthError | if 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
| Argument | Type | Description |
|---|---|---|
data | None | a dict matching the Slack text composition-object shape,e.g. {"type": "mrkdwn", "text": "hi", "verbatim": True}. |
Returns
| Type | Description |
|---|---|
None | A Text instance. |
Errors
| Error | When |
|---|---|
MissingRequiredError | if data["text"] is absent. |
TypeMismatchError | if data["type"] is not one of theallowable 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
| Argument | Type | Description |
|---|---|---|
text | None | the str or Text object to ensure is in Text format. |
force_plaintext | None | if True, forces the str or Text objectinto a Text object with the type TextType.PLAINTEXT. |
max_length | None | text will be checked against this length in additionto the standard Text limit of 3000 characters. |
allow_none | None | whether 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
| Argument | Type | Description |
|---|---|---|
text | None | the str or Text object to ensure is in Text format. |
force_plaintext | None | if True, forces the str or Text objectinto a Text object with the type TextType.PLAINTEXT. |
max_length | None | text will be checked against this length in additionto the standard Text limit of 3000 characters. |
Returns
| Type | Description |
|---|---|
None | A Text object created from the input. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Argument | Type | Description |
|---|---|---|
text | TextLike | the text identifying the option (that the user will see). |
value | str | the underlying value of that option (not seen by the user). |
description | TextLike | None | a more detailed explanation of what the option means (user-facing). |
url | str | None | a URL to load in the user's browser when the option is clicked. Only available in OverflowMenus. |
Errors
| Error | When |
|---|---|
InvalidUsageError | when 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
| Error | When |
|---|---|
MissingRequiredError | if 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
| Argument | Type | Description |
|---|---|---|
label | TextLike | a label shown above the group of options. |
options | list[Option] | a list of Option objects that will form the contents of the group (max 100). |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Error | When |
|---|---|
MissingRequiredError | if 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
| Argument | Type | Description |
|---|---|---|
segments | list[ChartSegment] | a list of between 1 and 12 ChartSegment objects. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Argument | Type | Description |
|---|---|---|
text | str | the text to render (1-3000 characters). |
emoji | bool | if True, emoji (e.g. :smile:) are escaped into Unicode. |
Errors
| Error | When |
|---|---|
LengthError | if 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
| Argument | Type | Description |
|---|---|---|
data | None | a dict matching the Slack text composition-object shape,e.g. {"type": "mrkdwn", "text": "hi", "verbatim": True}. |
Returns
| Type | Description |
|---|---|
None | A Text instance. |
Errors
| Error | When |
|---|---|
MissingRequiredError | if data["text"] is absent. |
TypeMismatchError | if data["type"] is not one of theallowable 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
| Argument | Type | Description |
|---|---|---|
text | None | the str or Text object to ensure is in Text format. |
force_plaintext | None | if True, forces the str or Text objectinto a Text object with the type TextType.PLAINTEXT. |
max_length | None | text will be checked against this length in additionto the standard Text limit of 3000 characters. |
allow_none | None | whether 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
| Argument | Type | Description |
|---|---|---|
text | None | the str or Text object to ensure is in Text format. |
force_plaintext | None | if True, forces the str or Text objectinto a Text object with the type TextType.PLAINTEXT. |
max_length | None | text will be checked against this length in additionto the standard Text limit of 3000 characters. |
Returns
| Type | Description |
|---|---|
None | A Text object created from the input. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Argument | Type | Description |
|---|---|---|
value | int | float | the numeric value Slack uses for sorting and display. |
text | str | the non-empty text Slack displays in the cell. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Argument | Type | Description |
|---|---|---|
text | str | the text to be rendered in a message. |
emoji | bool | only usable with TextType.PLAINTEXT, if True: emoji will beescaped into text format (e.g. :smile:). |
Errors
| Error | When |
|---|---|
InvalidUsageException | if 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
| Argument | Type | Description |
|---|---|---|
url | str | None | the URL can be the url_private or the permalink of the Slack file(only one of url or id can be provided). |
id | str | None | the Slack ID of the file (only one of url or id can be provided). |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Argument | Type | Description |
|---|---|---|
name | SlackIconName | the name of a Slack-provided icon, e.g. bot or rocket(see SlackIconName for the full list of valid names). |
Errors
| Error | When |
|---|---|
TypeMismatchError | if 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
| Argument | Type | Description |
|---|---|---|
text | str | the text to be rendered in a message (max 3000 characters). |
type_ | TextType | either TextType.MARKDOWN or TextType.PLAINTEXT. |
emoji | bool | only usable with TextType.PLAINTEXT, if True: emoji will beescaped into text format (e.g. :smile:). |
verbatim | bool | only usable with TextType.MARKDOWN, if True: links, channelnames, user names will not automatically be rendered as links. |
Errors
| Error | When |
|---|---|
InvalidUsageException | if 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
| Argument | Type | Description |
|---|---|---|
data | dict[str, Any] | a dict matching the Slack text composition-object shape,e.g. {"type": "mrkdwn", "text": "hi", "verbatim": True}. |
Returns
| Type | Description |
|---|---|
Text | A Text instance. |
Errors
| Error | When |
|---|---|
MissingRequiredError | if data["text"] is absent. |
TypeMismatchError | if data["type"] is not one of theallowable 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
| Argument | Type | Description |
|---|---|---|
text | str | Text | None | the str or Text object to ensure is in Text format. |
force_plaintext | bool | if True, forces the str or Text objectinto a Text object with the type TextType.PLAINTEXT. |
max_length | int | None | text will be checked against this length in additionto the standard Text limit of 3000 characters. |
allow_none | bool | whether 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
| Argument | Type | Description |
|---|---|---|
text | str | Text | the str or Text object to ensure is in Text format. |
force_plaintext | bool | if True, forces the str or Text objectinto a Text object with the type TextType.PLAINTEXT. |
max_length | int | None | text will be checked against this length in additionto the standard Text limit of 3000 characters. |
Returns
| Type | Description |
|---|---|
Text | A Text object created from the input. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Argument | Type | Description |
|---|---|---|
url | str | a link trigger URL, see https://api.slack.com/automation/triggers/link |
customizable_input_parameters | InputParameter | list[InputParameter] | None | a list of InputParameter objectswhich map to those parameters defined on the Workflow in which they are provided. |
Errors
| Error | When |
|---|---|
InvalidUsageError | when any of the items incustomizable_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
| Argument | Type | Description |
|---|---|---|
trigger | Trigger | a 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
| Argument | Type | Description |
|---|---|---|
url | str | the link trigger URL. |
**input_parameters | str | zero or more name=value pairs that becomeInputParameter entries on the trigger. |
Returns
| Type | Description |
|---|---|
Workflow | A new Workflow instance. |