diff --git a/1.0.9/reference/blocks/index.html b/1.0.9/reference/blocks/index.html index a15d905..bdca5d4 100644 --- a/1.0.9/reference/blocks/index.html +++ b/1.0.9/reference/blocks/index.html @@ -931,7 +931,8 @@

-

a list of Elements (up to a maximum of 25).

+

a list of Elements +(up to a maximum of 25).

@@ -986,12 +987,14 @@

134 135 136 -137
class ActionsBlock(Block):
+137
+138
class ActionsBlock(Block):
     """
     A `Block` that is used to hold interactive elements (normally for users to interface with).
 
     Args:
-        elements: a list of [Elements](/slackblocks/latest/reference/elements) (up to a maximum of 25).
+        elements: a list of [Elements](/slackblocks/latest/reference/elements)
+            (up to a maximum of 25).
         block_id: you can use this field to provide a deterministic identifier for the block.
 
     Throws:
@@ -1102,8 +1105,7 @@ 

Source code in slackblocks/blocks.py -
140
-141
+              
141
 142
 143
 144
@@ -1137,7 +1139,8 @@ 

172 173 174 -175

class ContextBlock(Block):
+175
+176
class ContextBlock(Block):
     """
     A `ContextBlock` displays contextul message info, including both images and text.
 
@@ -1246,8 +1249,7 @@ 

Source code in slackblocks/blocks.py -
178
-179
+              
179
 180
 181
 182
@@ -1259,7 +1261,8 @@ 

188 189 190 -191

class DividerBlock(Block):
+191
+192
class DividerBlock(Block):
     """
     A content divider, like an `<hr>` in HTML, to split up different blocks inside of
     a message.
@@ -1375,8 +1378,7 @@ 

Source code in slackblocks/blocks.py -
194
-195
+              
195
 196
 197
 198
@@ -1399,7 +1401,8 @@ 

215 216 217 -218

class FileBlock(Block):
+218
+219
class FileBlock(Block):
     """
     Displays a remote file (e.g. a PDF).
 
@@ -1510,8 +1513,7 @@ 

Source code in slackblocks/blocks.py -
221
-222
+              
222
 223
 224
 225
@@ -1531,7 +1533,8 @@ 

239 240 241 -242

class HeaderBlock(Block):
+242
+243
class HeaderBlock(Block):
     """
     A Header Block is a plain-text block that displays in a larger, bold font.
 
@@ -1671,8 +1674,7 @@ 

Source code in slackblocks/blocks.py -
245
-246
+              
246
 247
 248
 249
@@ -1722,7 +1724,8 @@ 

293 294 295 -296

class ImageBlock(Block):
+296
+297
class ImageBlock(Block):
     """
     An Image Block contains a single graphic, accessed by URL.
 
@@ -1850,7 +1853,8 @@ 

-

an interactive Element (e.g. a text field).

+

an interactive Element +(e.g. a text field).

@@ -1864,8 +1868,8 @@

-

whether the Element should trigger the -sending of a block_actions payload.

+

whether the Element +should trigger the sending of a block_actions payload.

@@ -1923,8 +1927,7 @@

Source code in slackblocks/blocks.py -
299
-300
+              
300
 301
 302
 303
@@ -1974,7 +1977,9 @@ 

347 348 349 -350

class InputBlock(Block):
+350
+351
+352
class InputBlock(Block):
     """
     A block that collects information from users - it can hold a plain-text
     input element, a checkbox element, a radio button element, a select
@@ -1982,9 +1987,10 @@ 

Args: label: the name which identifies the input field. - element: an interactive [Element](/slackblocks/latest/reference/elements) (e.g. a text field). - dispatch_action: whether the [Element](/slackblocks/latest/reference/elements) should trigger the - sending of a `block_actions` payload. + element: an interactive [Element](/slackblocks/latest/reference/elements) + (e.g. a text field). + dispatch_action: whether the [Element](/slackblocks/latest/reference/elements) + should trigger the sending of a `block_actions` payload. block_id: you can use this field to provide a deterministic identifier for the block. hint: an optional additional guide on what input the user should prodive. optional: whether this input field may be empty when the user submits e.g. the modal. @@ -2124,9 +2130,7 @@

Source code in slackblocks/blocks.py -
353
-354
-355
+              
355
 356
 357
 358
@@ -2164,7 +2168,9 @@ 

390 391 392 -393

class RichTextBlock(Block):
+393
+394
+395
class RichTextBlock(Block):
     """
     A RichTextBlock is used to provide easier rich text formatting
         than standard markdown text (e.g. in a
@@ -2247,7 +2253,8 @@ 

it can be used as a simple text block, or with any of the available block elements.

Section blocks can also optionally be given an "accessory," -which is typically one of the interactive Elements.

+which is typically one of the interactive +Elements.

@@ -2313,8 +2320,9 @@

-

an optional Element object that will take a -secondary place in the block (after or to the side of text or fields).

+

an optional Element object that +will take a secondary place in the block (after or to the side of text or +fields).

@@ -2330,9 +2338,7 @@

Source code in slackblocks/blocks.py -
396
-397
-398
+              
398
 399
 400
 401
@@ -2391,14 +2397,19 @@ 

454 455 456 -457

class SectionBlock(Block):
+457
+458
+459
+460
+461
class SectionBlock(Block):
     """
     A section is one of the most flexible blocks available -
     it can be used as a simple text block, or with any of the
     available block elements.
 
     Section blocks can also optionally be given an "accessory,"
-    which is typically one of the interactive [Elements](/slackblocks/latest/reference/elements).
+    which is typically one of the interactive
+    [Elements](/slackblocks/latest/reference/elements).
 
     Args:
         text: text to include in the block. Can be a string or `Text` object (of either
@@ -2406,8 +2417,9 @@ 

`text` or `fields` must be provided. block_id: you can use this field to provide a deterministic identifier for the block. fields: a list of text objects. One of either `text` or `fields` must be provided. - accessory: an optional [Element](/slackblocks/latest/reference/elements) object that will take a - secondary place in the block (after or to the side of `text` or `fields`). + accessory: an optional [Element](/slackblocks/latest/reference/elements) object that + will take a secondary place in the block (after or to the side of `text` or + `fields`). Throws: InvalidUsageError: if any of the provided arguments fail validation checks. diff --git a/1.0.9/reference/elements/index.html b/1.0.9/reference/elements/index.html index 26519f2..fd4f212 100644 --- a/1.0.9/reference/elements/index.html +++ b/1.0.9/reference/elements/index.html @@ -1516,9 +1516,7 @@

Source code in slackblocks/elements.py -
1596
-1597
-1598
+              
1598
 1599
 1600
 1601
@@ -1533,7 +1531,9 @@ 

1610 1611 1612 -1613

class ButtonStyle(Enum):
+1613
+1614
+1615
class ButtonStyle(Enum):
     """
     Utility class for determining the style of `Buttons` and `WorkflowButtons`.
     """
@@ -1704,8 +1704,7 @@ 

Source code in slackblocks/elements.py -
793
-794
+              
794
 795
 796
 797
@@ -1764,7 +1763,8 @@ 

850 851 852 -853

class ChannelMultiSelectMenu(Element):
+853
+854
class ChannelMultiSelectMenu(Element):
     """
     This interactive UI element allows users to select multiple channels visible
         to the current user in the active workspace.
@@ -1979,9 +1979,7 @@ 

Source code in slackblocks/elements.py -
1418
-1419
-1420
+              
1420
 1421
 1422
 1423
@@ -2039,7 +2037,9 @@ 

1475 1476 1477 -1478

class ChannelSelectMenu(Element):
+1478
+1479
+1480
class ChannelSelectMenu(Element):
     """
     A select menu interactive UI element, sourced with a list of public channels visible
         to the current user.
@@ -2177,8 +2177,8 @@ 

a list of -Option objects that will form -the content of the checkbox group.

+Option objects that will +form the content of the checkbox group.

@@ -2193,8 +2193,8 @@

a list of -Option objects that will be -initially selected when first presented to the user.

+Option objects that will +be initially selected when first presented to the user.

@@ -2301,11 +2301,11 @@

Args: action_id: an identifier so the source of the action can be known. options: a list of - [`Option`](/slackblocks/latest/reference/objects/#objects.Option) objects that will form - the content of the checkbox group. + [`Option`](/slackblocks/latest/reference/objects/#objects.Option) objects that will + form the content of the checkbox group. initial_options: a list of - [`Option`](/slackblocks/latest/reference/objects/#objects.Option) objects that will be - initially selected when first presented to the user. + [`Option`](/slackblocks/latest/reference/objects/#objects.Option) objects that will + be initially selected when first presented to the user. confirm: a `ConfirmationDialogue` object that will be presented when the checkbox group is used. focus_on_load: whether or not the checkbox group will be set to autofocus @@ -2528,8 +2528,7 @@

Source code in slackblocks/elements.py -
714
-715
+              
715
 716
 717
 718
@@ -2604,7 +2603,8 @@ 

787 788 789 -790

class ConversationMultiSelectMenu(Element):
+790
+791
class ConversationMultiSelectMenu(Element):
     """
     This interactive UI element allows users to select multiple conversations visible
         to the current user in the active workspace.
@@ -2867,9 +2867,7 @@ 

Source code in slackblocks/elements.py -
1339
-1340
-1341
+              
1341
 1342
 1343
 1344
@@ -2943,7 +2941,9 @@ 

1412 1413 1414 -1415

class ConversationSelectMenu(Element):
+1415
+1416
+1417
class ConversationSelectMenu(Element):
     """
     A select menu interactive UI element, sourced with a list of public and private channels,
         DMs, and MPIMs visible to the current user.
@@ -3878,8 +3878,7 @@ 

Source code in slackblocks/elements.py -
584
-585
+              
585
 586
 587
 588
@@ -3946,7 +3945,8 @@ 

649 650 651 -652

class ExternalMultiSelectMenu(Element):
+652
+653
class ExternalMultiSelectMenu(Element):
     """
     An interactive UI element that loads its options from an external data source,
         allowing for a dynamic list of options.
@@ -4054,8 +4054,11 @@ 

A select menu interactive UI element, sourced with externally provided options.

-

See: https://api.slack.com/slackblocks/latest/reference/block-kit/block-elements#external_select.

+
+ See +

https://api.slack.com/slackblocks/latest/reference/block-kit/block-elements#external_select. # noqa: E501

+

Parameters:

@@ -4168,8 +4171,7 @@

Source code in slackblocks/elements.py -
1224
-1225
+              
@@ -4634,7 +4640,8 @@

453 454 455 -456

1225
 1226
 1227
 1228
@@ -4227,11 +4229,14 @@ 

1280 1281 1282 -1283

class ExternalSelectMenu(Element):
+1283
+1284
+1285
class ExternalSelectMenu(Element):
     """
     A select menu interactive UI element, sourced with externally provided options.
 
-    See: <https://api.slack.com/slackblocks/latest/reference/block-kit/block-elements#external_select>.
+    See:
+        <https://api.slack.com/slackblocks/latest/reference/block-kit/block-elements#external_select>. # noqa: E501
 
     Args:
         action_id: an identifier so the source of the action can be known.
@@ -4572,7 +4577,8 @@ 

-

a SlackFile +

a +SlackFile (the user must provide either image_url or slack_file).

class Image(Element):
+456
+457
class Image(Element):
     """
     An element to insert an image - this element can be used in section
     and context blocks only. If you want a block with only an image in it,
@@ -4648,7 +4655,8 @@ 

alt_text: a plain-text-only summary of the content of the image. image_url: a URL for a publicly hosted image (the user must provide either `image_url` or `slack_file`). - slack_file: a [`SlackFile`](/slackblocks/latest/reference/objects/#objects.SlackFile) + slack_file: a + [`SlackFile`](/slackblocks/latest/reference/objects/#objects.SlackFile) (the user must provide either `image_url` or `slack_file`). Throws: @@ -4859,8 +4867,7 @@

Source code in slackblocks/elements.py -
856
-857
+              
857
 858
 859
 860
@@ -4946,7 +4953,8 @@ 

940 941 942 -943

class NumberInput(Element):
+943
+944
class NumberInput(Element):
     """
     This input elements accepts both integer and decimal numbers. For example,
     0.25, 5.5, and -10 are all valid input values.
@@ -5142,8 +5150,7 @@ 

Source code in slackblocks/elements.py -
946
-947
+              
947
 948
 949
 950
@@ -5177,7 +5184,8 @@ 

978 979 980 -981

class OverflowMenu(Element):
+981
+982
class OverflowMenu(Element):
     """
     Context menu for additional options (think '...').
 
@@ -5394,8 +5402,7 @@ 

Source code in slackblocks/elements.py -
 984
- 985
+              
 985
  986
  987
  988
@@ -5465,7 +5472,8 @@ 

1052 1053 1054 -1055

class PlainTextInput(Element):
+1055
+1056
class PlainTextInput(Element):
     """
     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 text
@@ -5676,8 +5684,7 @@ 

Source code in slackblocks/elements.py -
1058
-1059
+              
1059
 1060
 1061
 1062
@@ -5730,7 +5737,8 @@ 

1109 1110 1111 -1112

class RadioButtonGroup(Element):
+1112
+1113
class RadioButtonGroup(Element):
     """
     A radio button group that allows a user to choose one item from a list of possible options.
 
@@ -5923,9 +5931,7 @@ 

Source code in slackblocks/elements.py -
1666
-1667
-1668
+              
1668
 1669
 1670
 1671
@@ -5971,7 +5977,9 @@ 

1711 1712 1713 -1714

class RichTextInput(Element):
+1714
+1715
+1716
class RichTextInput(Element):
     """
     Allows users to enter formatted text in a WYSIWYG editor, similar to the Slack
         messaging experience.
@@ -6205,8 +6213,7 @@ 

Source code in slackblocks/elements.py -
459
-460
+              
460
 461
 462
 463
@@ -6327,7 +6334,8 @@ 

578 579 580 -581

class StaticMultiSelectMenu(Element):
+581
+582
class StaticMultiSelectMenu(Element):
     """
     The most basic form of select menu containing a static list of options
     passed in when defining the element.
@@ -6622,8 +6630,7 @@ 

Source code in slackblocks/elements.py -
1115
-1116
+              
1116
 1117
 1118
 1119
@@ -6728,7 +6735,8 @@ 

1218 1219 1220 -1221

class StaticSelectMenu(Element):
+1221
+1222
class StaticSelectMenu(Element):
     """
     A simple select menu interactive UI element, with a static list of options passed in when
         defining the element.
@@ -6985,9 +6993,7 @@ 

Source code in slackblocks/elements.py -
1481
-1482
-1483
+              
1483
 1484
 1485
 1486
@@ -7041,7 +7047,9 @@ 

1534 1535 1536 -1537

class TimePicker(Element):
+1537
+1538
+1539
class TimePicker(Element):
     """
     An interactive UI element that allows users to select a time of day.
 
@@ -7236,9 +7244,7 @@ 

Source code in slackblocks/elements.py -
1540
-1541
-1542
+              
1542
 1543
 1544
 1545
@@ -7289,7 +7295,9 @@ 

1590 1591 1592 -1593

class URLInput(Element):
+1593
+1594
+1595
class URLInput(Element):
     """
     An interactive UI element for collecting URL input from users.
 
@@ -7496,8 +7504,7 @@ 

Source code in slackblocks/elements.py -
655
-656
+              
656
 657
 658
 659
@@ -7552,7 +7559,8 @@ 

708 709 710 -711

class UserMultiSelectMenu(Element):
+711
+712
class UserMultiSelectMenu(Element):
     """
     This interactive UI element allows users to select multiple users visible
         to the current user in the active workspace.
@@ -7747,9 +7755,7 @@ 

Source code in slackblocks/elements.py -
1286
-1287
-1288
+              
1288
 1289
 1290
 1291
@@ -7797,7 +7803,9 @@ 

1333 1334 1335 -1336

class UserSelectMenu(Element):
+1336
+1337
+1338
class UserSelectMenu(Element):
     """
     A select menu interactive UI element, sourced automatically with Slack users from the
         current workspace visible to the current user.
@@ -7973,9 +7981,7 @@ 

Source code in slackblocks/elements.py -
1619
-1620
-1621
+              
1621
 1622
 1623
 1624
@@ -8017,7 +8023,9 @@ 

1660 1661 1662 -1663

class WorkflowButton(Element):
+1663
+1664
+1665
class WorkflowButton(Element):
     """
     An interactive component that allows users to run a link trigger with
         customizable inputs.
diff --git a/1.0.9/reference/modals/index.html b/1.0.9/reference/modals/index.html
index 2417a21..851c9d1 100644
--- a/1.0.9/reference/modals/index.html
+++ b/1.0.9/reference/modals/index.html
@@ -769,7 +769,8 @@ 

Bases: ModalView

-

Kept for backwards compatibility - see ModalView

+

Kept for backwards compatibility - see + ModalView

Source code in slackblocks/modals.py @@ -785,9 +786,11 @@

26 27 28 -29

class Modal(ModalView):
+29
+30
class Modal(ModalView):
     """
-    Kept for backwards compatibility - see [`ModalView`](/slackblocks/latest/reference/views/#views.ModalView)
+    Kept for backwards compatibility - see
+        [`ModalView`](/slackblocks/latest/reference/views/#views.ModalView)
     """
 
     def __repr__(self) -> str:
diff --git a/1.0.9/reference/objects/index.html b/1.0.9/reference/objects/index.html
index 93a5d76..128bc88 100644
--- a/1.0.9/reference/objects/index.html
+++ b/1.0.9/reference/objects/index.html
@@ -993,8 +993,11 @@ 

Alias for ConfirmationDialogue to retain backwards compatibility.

-

See: ConfirmationDialogue.

+
+ See +

ConfirmationDialogue. # noqa: E501

+
Source code in slackblocks/objects.py
220
@@ -1005,11 +1008,13 @@ 

225 226 227 -228

class Confirm(ConfirmationDialogue):
+228
+229
class Confirm(ConfirmationDialogue):
     """
     Alias for `ConfirmationDialogue` to retain backwards compatibility.
 
-    See: [`ConfirmationDialogue`](/slackblocks/latest/reference/objects/#objects.ConfirmationDialogue).
+    See:
+        [`ConfirmationDialogue`](/slackblocks/latest/reference/objects/#objects.ConfirmationDialogue).  # noqa: E501
     """
 
     def __init__(self, *args, **kwargs):
@@ -1318,8 +1323,7 @@ 

Source code in slackblocks/objects.py -
350
-351
+              
351
 352
 353
 354
@@ -1369,7 +1373,8 @@ 

398 399 400 -401

class ConversationFilter(CompositionObject):
+401
+402
class ConversationFilter(CompositionObject):
     """
     Provides a way to filter the list of options in a conversations select menu or
     conversations multi-select menu.
@@ -1499,8 +1504,7 @@ 

Source code in slackblocks/objects.py -
321
-322
+              
322
 323
 324
 325
@@ -1525,7 +1529,8 @@ 

344 345 346 -347

class DispatchActionConfiguration(CompositionObject):
+347
+348
class DispatchActionConfiguration(CompositionObject):
     """
     Determines when a plain-text input element will return a `block_action`s interaction payload.
 
@@ -1639,8 +1644,7 @@ 

Source code in slackblocks/objects.py -
404
-405
+              
405
 406
 407
 408
@@ -1659,7 +1663,8 @@ 

421 422 423 -424

class InputParameter(CompositionObject):
+424
+425
class InputParameter(CompositionObject):
     """
     Contains information about an input parameter.
 
@@ -1801,8 +1806,7 @@ 

Source code in slackblocks/objects.py -
231
-232
+              
232
 233
 234
 235
@@ -1853,7 +1857,8 @@ 

280 281 282 -283

class Option(CompositionObject):
+283
+284
class Option(CompositionObject):
     """
     An object that represents a single selectable item in a select menu, multi-select
     menu, checkbox group, radio button group, or overflow menu.
@@ -1997,8 +2002,7 @@ 

Source code in slackblocks/objects.py -
286
-287
+              
287
 288
 289
 290
@@ -2026,7 +2030,8 @@ 

312 313 314 -315

class OptionGroup(CompositionObject):
+315
+316
class OptionGroup(CompositionObject):
     """
     Provides a way to group options in a select menu or multi-select menu.
 
@@ -2151,8 +2156,7 @@ 

Source code in slackblocks/objects.py -
427
-428
+              
428
 429
 430
 431
@@ -2187,7 +2191,8 @@ 

460 461 462 -463

class SlackFile(CompositionObject):
+463
+464
class SlackFile(CompositionObject):
     """
     Defines an object containing Slack file information to be used in an image
         block or image element.
@@ -2911,8 +2916,7 @@ 

Source code in slackblocks/objects.py -
466
-467
+              
467
 468
 469
 470
@@ -2949,7 +2953,8 @@ 

501 502 503 -504

class Trigger(CompositionObject):
+504
+505
class Trigger(CompositionObject):
     """
     Contains information about a trigger.
 
@@ -3061,8 +3066,7 @@ 

Source code in slackblocks/objects.py -
507
-508
+              
508
 509
 510
 511
@@ -3078,7 +3082,8 @@ 

521 522 523 -524

class Workflow(CompositionObject):
+524
+525
class Workflow(CompositionObject):
     """
     Contains information about a workflow.
 
diff --git a/1.0.9/search/search_index.json b/1.0.9/search/search_index.json
index e797576..cb08349 100644
--- a/1.0.9/search/search_index.json
+++ b/1.0.9/search/search_index.json
@@ -1 +1 @@
-{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Welcome to slackblocks!","text":"

slackblocks is Python package for creating complex Slack messages using the Slack BlockKit API.

It exists so you don't have to define block-based Slack messages by hand-writing JSON.

"},{"location":"#components","title":"Components","text":"

The Slack BlockKit API defines a number of different resource types (all defined in JSON) which work together to define Block-based messages.

slackblocks makes using this API easier by providing a hierarchy of Python classes that represent these resources.

"},{"location":"#objects","title":"Objects","text":"

Objects (e.g. Text) are the lowest level pimitives that are used to populate Elements and Blocks.

"},{"location":"#elements","title":"Elements","text":"

Elements are typically interactive UI elements that take in Object to define their content. For example, the CheckboxGroup element takes in one or more Option items and presents a checkbox menu to the user with those options.

"},{"location":"#blocks","title":"Blocks","text":"

Blocks are the core element of the API, with different Blocks used to create different types of visual elements. For example, the DividerBlock, when rendered, will show a visual element similar to a <hr> HTML element. The RichTextBlock on the other hand allows for the display of text elements with visual styling like italics, block quotes, lists and code blocks.

"},{"location":"#messages","title":"Messages","text":"

Messages are a convenience wrapper around Blocks that can be unpacked as arguments straight into the official Slack Python SDK (or its legacy slackclient counterpart).

"},{"location":"#views","title":"Views","text":"

Views are an alternative usage for Blocks that allow for the creation of custom UI \"surfaces\" within Slack, e.g. for third-party apps.

"},{"location":"#guides","title":"Guides","text":"

In addition to a complete reference of all classes and functions provided by the slackblocks library, this documentation contains guides on:

  • Installing slackblocks
  • Using Blocks
  • Sending Block-based Messages
"},{"location":"reference/attachments/","title":"Attachments","text":"

Warning: Deprecated Feature

Attachments, while still accepted by the Slack API, have long (for years now) been considered a deprecated feature.

That said, there is currently no other way to achieve the vertical, colored bars next to content.

Secondary (less important) content can be attached using the deprecated attachments API.

See: https://api.slack.com/slackblocks/latest/reference/messaging/attachments.

"},{"location":"reference/attachments/#attachments.Attachment","title":"Attachment","text":"

Lower priority content can be attached to messages using Attachments. This is content that doesn't necessarily need to be seen to appreciate the intent of the message, but perhaps adds further context or additional information.

See https://api.slack.com/reference/messaging/attachments.

N.B: fields is a deprecated field, included only for legacy purposes. Other legacy fields, e.g. author_name are deliberately omitted as they were never implemented in slackblocks.

Parameters:

Name Type Description Default blocks Optional[Union[Block, List[Block]]]

an array of Blocks that define the content of the attachment.

None color Optional[Union[str, Color]]

the color (in hex format, e.g. #ffffff) of the vertical bar to the left of the attachment content. Consider using the Color enum from this module.

None fields Optional[Union[Field, List[Field]]]

a list of Field objects to be included in what's rendered in the attachment.

None Throws

InvalidUsageError: if the color code provided is invalid.

Source code in slackblocks/attachments.py
class Attachment:\n    \"\"\"\n    Lower priority content can be attached to messages using Attachments.\n    This is content that doesn't necessarily need to be seen to appreciate\n    the intent of the message, but perhaps adds further context or additional information.\n\n    See <https://api.slack.com/reference/messaging/attachments>.\n\n    N.B: `fields` is a deprecated field, included only for legacy purposes. Other legacy\n    fields, e.g. `author_name` are deliberately omitted as they were never implemented in\n    `slackblocks`.\n\n    Args:\n        blocks: an array of Blocks that define the content of the attachment.\n        color: the color (in hex format, e.g. #ffffff) of the vertical bar to the left of the\n            attachment content. Consider using the `Color` enum from this module.\n        fields: a list of `Field` objects to be included in what's rendered in the attachment.\n\n    Throws:\n        InvalidUsageError: if the `color` code provided is invalid.\n    \"\"\"\n\n    def __init__(\n        self,\n        blocks: Optional[Union[Block, List[Block]]] = None,\n        color: Optional[Union[str, Color]] = None,\n        fields: Optional[Union[Field, List[Field]]] = None,\n    ):\n        self.blocks = coerce_to_list(blocks, Block, allow_none=True)\n        self.fields = coerce_to_list(fields, Field, allow_none=True)\n        if type(color) is Color:\n            self.color = color.value\n        elif type(color) is str:\n            if len(color) == 7 and color.startswith(\"#\") and is_hex(color[1:]):\n                self.color = color\n            elif len(color) == 6 and is_hex(color):\n                self.color = f\"#{color}\"\n            else:\n                raise InvalidUsageError(\n                    \"Color must be a valid hex code (e.g. `#ffffff`)\"\n                )\n        else:\n            self.color = None\n\n    def _resolve(self) -> Dict[str, Any]:\n        attachment = dict()\n        if self.blocks:\n            attachment[\"blocks\"] = [block._resolve() for block in self.blocks]\n        if self.color:\n            attachment[\"color\"] = self.color\n        return attachment\n\n    def __repr__(self) -> str:\n        return dumps(self._resolve(), indent=4)\n
"},{"location":"reference/attachments/#attachments.Color","title":"Color","text":"

Color is a utility class for use with the Slack secondary attachments API.

Pass these to the color argument of Attachment.

Color.GOOD Color.WARNING Color.DANGER Color.RED Color.BLUE Color.YELLOW Color.GREEN Color.ORANGE Color.PURPLE Color.BLACK Source code in slackblocks/attachments.py
class Color(Enum):\n    \"\"\"\n    Color is a utility class for use with the Slack secondary attachments API.\n\n    Pass these to the `color` argument of\n        [`Attachment`](/slackblocks/latest/reference/attachments/#attachments.Attachment).\n\n    <table style=\"width:50%\">\n    <tr>\n    <td><code>Color.GOOD</code></td>\n    <td>\n    <img valign='middle' alt='good' src='https://readme-swatches.vercel.app/4CAF50?style=round'/>\n    </td>\n    </tr>\n    <tr>\n    <td><code>Color.WARNING</code></td>\n    <td>\n    <img valign='middle' alt='warning' src='https://readme-swatches.vercel.app/FFEB3B?style=round'/>\n    </td>\n    </tr>\n    <tr>\n    <td><code>Color.DANGER</code></td>\n    <td>\n    <img valign='middle' alt='danger' src='https://readme-swatches.vercel.app/F44336?style=round'/>\n    </td>\n    </tr>\n    <tr>\n    <td><code>Color.RED</code></td>\n    <td>\n    <img valign='middle' alt='red' src='https://readme-swatches.vercel.app/ff0000?style=round'/>\n    </td>\n    </tr>\n    <tr>\n    <td><code>Color.BLUE</code></td>\n    <td>\n    <img valign='middle' alt='blue' src='https://readme-swatches.vercel.app/0000ff?style=round'/>\n    </td>\n    </tr>\n    <tr>\n    <td><code>Color.YELLOW</code></td>\n    <td>\n    <img valign='middle' alt='yellow' src='https://readme-swatches.vercel.app/ffff00?style=round'/>\n    </td>\n    </tr>\n    <tr>\n    <td><code>Color.GREEN</code></td>\n    <td>\n    <img valign='middle' alt='green' src='https://readme-swatches.vercel.app/00ff00?style=round'/>\n    </td>\n    </tr>\n    <tr>\n    <td><code>Color.ORANGE</code></td>\n    <td>\n    <img valign='middle' alt='orange' src='https://readme-swatches.vercel.app/ff8800?style=round'/>\n    </td>\n    </tr>\n    <tr>\n    <td><code>Color.PURPLE</code></td>\n    <td>\n    <img valign='middle' alt='purple' src='https://readme-swatches.vercel.app/8800ff?style=round'/>\n    </td>\n    </tr>\n    <tr>\n    <td><code>Color.BLACK</code></td>\n    <td>\n    <img valign='middle' alt='black' src='https://readme-swatches.vercel.app/000000?style=round'/>\n    </td>\n    </tr>\n    </table>\n    \"\"\"\n\n    GOOD = \"good\"\n    WARNING = \"warning\"\n    DANGER = \"danger\"\n    RED = \"#ff0000\"\n    BLUE = \"#0000ff\"\n    YELLOW = \"#ffff00\"\n    GREEN = \"#00ff00\"\n    ORANGE = \"#ff8800\"\n    PURPLE = \"#8800ff\"\n    BLACK = \"#000000\"\n\n    def __repr__(self) -> str:\n        return f\"<slackblocks Color {self.name}: {self.value}>\"\n
"},{"location":"reference/attachments/#attachments.Field","title":"Field","text":"

Field text objects for use with Slack's secondary attachment API.

See https://api.slack.com/reference/messaging/attachments#fields.

Parameters:

Name Type Description Default title Optional[str]

text shown as a bold heading on the field.

None value Optional[str]

text (mrkdwn or plaintext) representing the value of the field.

None short Optional[bool]

whether the contents of the field is short enough to be presented in multipe columns.

False Source code in slackblocks/attachments.py
class Field:\n    \"\"\"\n    Field text objects for use with Slack's secondary attachment API.\n\n    See <https://api.slack.com/reference/messaging/attachments#fields>.\n\n    Args:\n        title: text shown as a bold heading on the field.\n        value: text (`mrkdwn` or `plaintext`) representing the value of the field.\n        short: whether the contents of the field is short enough to be presented in\n            multipe columns.\n    \"\"\"\n\n    def __init__(\n        self,\n        title: Optional[str] = None,\n        value: Optional[str] = None,\n        short: Optional[bool] = False,\n    ):\n        self.title = title\n        self.value = value\n        self.short = short\n\n    def _resolve(self):\n        field = dict()\n        field[\"short\"] = self.short\n        if self.title:\n            field[\"title\"] = self.title\n        if self.value:\n            field[\"value\"] = self.value\n        return dumps(field)\n
"},{"location":"reference/blocks/","title":"Blocks","text":"

Blocks are a series of container components that can be combined to create rich and interactive messages.

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

"},{"location":"reference/blocks/#blocks.ActionsBlock","title":"ActionsBlock","text":"

A Block that is used to hold interactive elements (normally for users to interface with).

Parameters:

Name Type Description Default elements Optional[List[Element]]

a list of Elements (up to a maximum of 25).

None block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None Throws

InvalidUsageError: if any of the items in elements are invalid.

Source code in slackblocks/blocks.py
class ActionsBlock(Block):\n    \"\"\"\n    A `Block` that is used to hold interactive elements (normally for users to interface with).\n\n    Args:\n        elements: a list of [Elements](/slackblocks/latest/reference/elements) (up to a maximum of 25).\n        block_id: you can use this field to provide a deterministic identifier for the block.\n\n    Throws:\n        InvalidUsageError: if any of the items in `elements` are invalid.\n    \"\"\"\n\n    def __init__(\n        self,\n        elements: Optional[List[Element]] = None,\n        block_id: Optional[str] = None,\n    ) -> \"ActionsBlock\":\n        super().__init__(type_=BlockType.ACTIONS, block_id=block_id)\n        self.elements = coerce_to_list(\n            elements, (Element), allow_none=True, max_size=25\n        )\n\n    def _resolve(self):\n        actions = self._attributes()\n        actions[\"elements\"] = [element._resolve() for element in self.elements]\n        return actions\n
"},{"location":"reference/blocks/#blocks.ContextBlock","title":"ContextBlock","text":"

A ContextBlock displays contextul message info, including both images and text.

Parameters:

Name Type Description Default elements Optional[List[Union[Element, CompositionObject]]]

a list of Text objects and Image elements.

None block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None Throws

InvalidUsageError: when items in elements are not Text or Image or exceed 10 items.

Source code in slackblocks/blocks.py
class ContextBlock(Block):\n    \"\"\"\n    A `ContextBlock` displays contextul message info, including both images and text.\n\n    Args:\n        elements: a list of `Text` objects and `Image` elements.\n        block_id: you can use this field to provide a deterministic identifier for the block.\n\n    Throws:\n        InvalidUsageError: when items in `elements` are not `Text` or `Image` or exceed 10 items.\n    \"\"\"\n\n    def __init__(\n        self,\n        elements: Optional[List[Union[Element, CompositionObject]]] = None,\n        block_id: Optional[str] = None,\n    ) -> \"ContextBlock\":\n        super().__init__(type_=BlockType.CONTEXT, block_id=block_id)\n        self.elements = []\n        for element in elements:\n            if (\n                element.type == CompositionObjectType.TEXT\n                or element.type == ElementType.IMAGE\n            ):\n                self.elements.append(element)\n            else:\n                raise InvalidUsageError(\n                    f\"Context blocks can only hold image and text elements, not {element.type}\"\n                )\n        if len(self.elements) > 10:\n            raise InvalidUsageError(\"Context blocks can hold a maximum of ten elements\")\n\n    def _resolve(self) -> Dict[str, any]:\n        context = self._attributes()\n        context[\"elements\"] = [element._resolve() for element in self.elements]\n        return context\n
"},{"location":"reference/blocks/#blocks.DividerBlock","title":"DividerBlock","text":"

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

Parameters:

Name Type Description Default block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None Source code in slackblocks/blocks.py
class DividerBlock(Block):\n    \"\"\"\n    A content divider, like an `<hr>` in HTML, to split up different blocks inside of\n    a message.\n\n    Args:\n        block_id: you can use this field to provide a deterministic identifier for the block.\n    \"\"\"\n\n    def __init__(self, block_id: Optional[str] = None) -> \"DividerBlock\":\n        super().__init__(type_=BlockType.DIVIDER, block_id=block_id)\n\n    def _resolve(self):\n        return self._attributes()\n
"},{"location":"reference/blocks/#blocks.FileBlock","title":"FileBlock","text":"

Displays a remote file (e.g. a PDF).

For details on how remote files are exposed to Slack, see https://api.slack.com/messaging/files#adding.

Parameters:

Name Type Description Default external_id str

the ID assigned to the remote file when it was added to Slack.

required block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

required source str

always \"remote\" as per the Slack API (may change in the future).

'remote' Source code in slackblocks/blocks.py
class FileBlock(Block):\n    \"\"\"\n    Displays a remote file (e.g. a PDF).\n\n    For details on how remote files are exposed to Slack, see\n    <https://api.slack.com/messaging/files#adding>.\n\n    Args:\n        external_id: the ID assigned to the remote file when it was added to Slack.\n        block_id: you can use this field to provide a deterministic identifier for the block.\n        source: always \"remote\" as per the Slack API (may change in the future).\n    \"\"\"\n\n    def __init__(\n        self, external_id: str, block_id: Optional[str], source: str = \"remote\"\n    ) -> \"FileBlock\":\n        super().__init__(type_=BlockType.FILE, block_id=block_id)\n        self.external_id = external_id\n        self.source = source\n\n    def _resolve(self) -> Dict[str, any]:\n        file = self._attributes()\n        file[\"external_id\"] = self.external_id\n        file[\"source\"] = self.source\n        return file\n
"},{"location":"reference/blocks/#blocks.HeaderBlock","title":"HeaderBlock","text":"

A Header Block is a plain-text block that displays in a larger, bold font.

Parameters:

Name Type Description Default text Union[str, Text]

the text that will be rendered as a heading.

required block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None Source code in slackblocks/blocks.py
class HeaderBlock(Block):\n    \"\"\"\n    A Header Block is a plain-text block that displays in a larger, bold font.\n\n    Args:\n        text: the text that will be rendered as a heading.\n        block_id: you can use this field to provide a deterministic identifier for the block.\n    \"\"\"\n\n    def __init__(\n        self, text: Union[str, Text], block_id: Optional[str] = None\n    ) -> \"HeaderBlock\":\n        super().__init__(type_=BlockType.HEADER, block_id=block_id)\n        if type(text) is Text:\n            self.text = text\n        else:\n            self.text = Text(text, type_=TextType.PLAINTEXT, verbatim=False)\n\n    def _resolve(self) -> Dict[str, any]:\n        header = self._attributes()\n        header[\"text\"] = self.text._resolve()\n        return header\n
"},{"location":"reference/blocks/#blocks.ImageBlock","title":"ImageBlock","text":"

An Image Block contains a single graphic, accessed by URL.

Parameters:

Name Type Description Default image_url str

the URL pointing to the image file you want to display.

required alt_text Optional[str]

alternative text for accessibility purposes and when the image fails to load.

' ' title Optional[Union[Text, str]]

an optional text title to be presented with the image.

None block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None Throws

InvalidUsageError: when one or more of the provided args fails validation.

Source code in slackblocks/blocks.py
class ImageBlock(Block):\n    \"\"\"\n    An Image Block contains a single graphic, accessed by URL.\n\n    Args:\n        image_url: the URL pointing to the image file you want to display.\n        alt_text: alternative text for accessibility purposes and when the image fails to load.\n        title: an optional text title to be presented with the image.\n        block_id: you can use this field to provide a deterministic identifier for the block.\n\n    Throws:\n        InvalidUsageError: when one or more of the provided args fails validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        image_url: str,\n        alt_text: Optional[str] = \" \",\n        title: Optional[Union[Text, str]] = None,\n        block_id: Optional[str] = None,\n    ) -> \"ImageBlock\":\n        super().__init__(type_=BlockType.IMAGE, block_id=block_id)\n        self.image_url = validate_string(\n            string=image_url,\n            field_name=\"title\",\n            max_length=3000,\n        )\n        self.alt_text = validate_string(\n            alt_text, field_name=\"alt_text\", max_length=2000\n        )\n        if title and isinstance(title, Text):\n            if title.text_type == TextType.MARKDOWN:\n                # Coerce title into plaintext\n                self.title = Text(\n                    text=title.text,\n                    type_=TextType.PLAINTEXT,\n                    emoji=title.emoji,\n                    verbatim=title.verbatim,\n                )\n            else:\n                self.title = title\n        elif isinstance(title, str):\n            self.title = Text(text=title, type_=TextType.PLAINTEXT)\n\n    def _resolve(self) -> Dict[str, Any]:\n        image = self._attributes()\n        image[\"image_url\"] = self.image_url\n        if self.alt_text:\n            image[\"alt_text\"] = self.alt_text\n        if self.title:\n            image[\"title\"] = self.title._resolve()\n        return image\n
"},{"location":"reference/blocks/#blocks.InputBlock","title":"InputBlock","text":"

A block that collects information from users - it can hold a plain-text input element, a checkbox element, a radio button element, a select menu element, a multi-select menu element, or a datepicker.

Parameters:

Name Type Description Default label TextLike

the name which identifies the input field.

required element Element

an interactive Element (e.g. a text field).

required dispatch_action bool

whether the Element should trigger the sending of a block_actions payload.

False block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None hint Optional[TextLike]

an optional additional guide on what input the user should prodive.

None optional bool

whether this input field may be empty when the user submits e.g. the modal.

False Throws

InvalidUsageError: when any of the provided arguments fail validation.

Source code in slackblocks/blocks.py
class InputBlock(Block):\n    \"\"\"\n    A block that collects information from users - it can hold a plain-text\n    input element, a checkbox element, a radio button element, a select\n    menu element, a multi-select menu element, or a datepicker.\n\n    Args:\n        label: the name which identifies the input field.\n        element: an interactive [Element](/slackblocks/latest/reference/elements) (e.g. a text field).\n        dispatch_action: whether the [Element](/slackblocks/latest/reference/elements) should trigger the\n            sending of a `block_actions` payload.\n        block_id: you can use this field to provide a deterministic identifier for the block.\n        hint: an optional additional guide on what input the user should prodive.\n        optional: whether this input field may be empty when the user submits e.g. the modal.\n\n    Throws:\n        InvalidUsageError: when any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        label: TextLike,\n        element: Element,\n        dispatch_action: bool = False,\n        block_id: Optional[str] = None,\n        hint: Optional[TextLike] = None,\n        optional: bool = False,\n    ) -> \"InputBlock\":\n        super().__init__(type_=BlockType.INPUT, block_id=block_id)\n        self.label = Text.to_text(\n            label, force_plaintext=True, max_length=2000, allow_none=False\n        )\n        if not isinstance(element, ALLOWED_INPUT_ELEMENTS):\n            raise InvalidUsageError(\"\")\n        self.element = element\n        self.dispatch_action = dispatch_action\n        self.hint = Text.to_text(\n            hint, force_plaintext=True, max_length=2000, allow_none=True\n        )\n        self.optional = optional\n\n    def _resolve(self) -> Dict[str, Any]:\n        input_block = self._attributes()\n        input_block[\"label\"] = self.label._resolve()\n        input_block[\"element\"] = self.element._resolve()\n        if self.hint:\n            input_block[\"hint\"] = self.hint._resolve()\n        if self.dispatch_action:\n            input_block[\"dispatch_action\"] = self.dispatch_action\n        if self.optional:\n            input_block[\"optional\"] = self.optional\n        return input_block\n
"},{"location":"reference/blocks/#blocks.RichTextBlock","title":"RichTextBlock","text":"

A RichTextBlock is used to provide easier rich text formatting than standard markdown text (e.g. in a SectionBlock) and access to text formatting features not available in traditional markdown (e.g. strikethrough). See the various rich text elements you can include here.

Parameters:

Name Type Description Default elements Union[RichTextObject, List[RichTextObject]]

a single rich text element or a list of those elements.

required block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None Throws

InvalidUsageError: if the elements in elements are not valid rich text elements.

Source code in slackblocks/blocks.py
class RichTextBlock(Block):\n    \"\"\"\n    A RichTextBlock is used to provide easier rich text formatting\n        than standard markdown text (e.g. in a\n        [`SectionBlock`](/slackblocks/latest/reference/blocks/#blocks.SectionBlock))\n        and access to text formatting features not available in traditional\n        markdown (e.g. strikethrough). See the various rich text elements\n        you can include [here](/slackblocks/latest/reference/rich_text).\n\n    Args:\n        elements: a single [rich text element](rich_text)\n            or a list of those elements.\n        block_id: you can use this field to provide a deterministic identifier\n            for the block.\n\n    Throws:\n        InvalidUsageError: if the elements in `elements` are not valid rich\n            text elements.\n    \"\"\"\n\n    def __init__(\n        self,\n        elements: Union[RichTextObject, List[RichTextObject]],\n        block_id: Optional[str] = None,\n    ) -> \"RichTextBlock\":\n        super().__init__(type_=BlockType.RICH_TEXT, block_id=block_id)\n        self.elements = coerce_to_list(\n            elements,\n            (\n                RichTextList,\n                RichTextCodeBlock,\n                RichTextQuote,\n                RichTextSection,\n            ),\n            min_size=1,\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        rich_text_block = self._attributes()\n        rich_text_block[\"elements\"] = [element._resolve() for element in self.elements]\n        return rich_text_block\n
"},{"location":"reference/blocks/#blocks.SectionBlock","title":"SectionBlock","text":"

A section is one of the most flexible blocks available - it can be used as a simple text block, or with any of the available block elements.

Section blocks can also optionally be given an \"accessory,\" which is typically one of the interactive Elements.

Parameters:

Name Type Description Default text Optional[TextLike]

text to include in the block. Can be a string or Text object (of either mrkdwn or plaintext variety). Defaults to markdown if unspecified. One of either text or fields must be provided.

None block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None fields Optional[Union[TextLike, List[TextLike]]]

a list of text objects. One of either text or fields must be provided.

None accessory Optional[Element]

an optional Element object that will take a secondary place in the block (after or to the side of text or fields).

None Throws

InvalidUsageError: if any of the provided arguments fail validation checks.

Source code in slackblocks/blocks.py
class SectionBlock(Block):\n    \"\"\"\n    A section is one of the most flexible blocks available -\n    it can be used as a simple text block, or with any of the\n    available block elements.\n\n    Section blocks can also optionally be given an \"accessory,\"\n    which is typically one of the interactive [Elements](/slackblocks/latest/reference/elements).\n\n    Args:\n        text: text to include in the block. Can be a string or `Text` object (of either\n            `mrkdwn` or `plaintext` variety). Defaults to markdown if unspecified. One of either\n            `text` or `fields` must be provided.\n        block_id: you can use this field to provide a deterministic identifier for the block.\n        fields: a list of text objects. One of either `text` or `fields` must be provided.\n        accessory: an optional [Element](/slackblocks/latest/reference/elements) object that will take a\n            secondary place in the block (after or to the side of  `text` or `fields`).\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation checks.\n    \"\"\"\n\n    def __init__(\n        self,\n        text: Optional[TextLike] = None,\n        block_id: Optional[str] = None,\n        fields: Optional[Union[TextLike, List[TextLike]]] = None,\n        accessory: Optional[Element] = None,\n    ) -> \"SectionBlock\":\n        super().__init__(type_=BlockType.SECTION, block_id=block_id)\n        if not text and not fields:\n            raise InvalidUsageError(\n                \"Must supply either `text` or `fields` or `both` to SectionBlock.\"\n            )\n        self.text = Text.to_text(text, max_length=3000, allow_none=True)\n        self.fields = coerce_to_list(\n            (\n                [\n                    Text.to_text(field, max_length=2000, allow_none=False)\n                    for field in coerce_to_list(\n                        fields, class_=(str, Text), allow_none=True\n                    )\n                ]\n                if fields\n                else None\n            ),\n            class_=Text,\n            allow_none=True,\n            max_size=10,\n        )\n\n        self.accessory = accessory\n\n    def _resolve(self) -> Dict[str, Any]:\n        section = self._attributes()\n        if self.text:\n            section[\"text\"] = self.text._resolve()\n        if self.fields:\n            section[\"fields\"] = [field._resolve() for field in self.fields]\n        if self.accessory:\n            section[\"accessory\"] = self.accessory._resolve()\n        return section\n
"},{"location":"reference/elements/","title":"Elements","text":"

Block elements can be used inside of section, context, input, and actions layout blocks.

See: https://api.slack.com/reference/block-kit/block-elements

"},{"location":"reference/elements/#elements.Button","title":"Button","text":"

An interactive element that inserts a button. The button can be a trigger for anything from opening a simple link to starting a complex workflow.

See: https://api.slack.com/reference/block-kit/block-elements#button.

Parameters:

Name Type Description Default text TextLike

text on the button (plaintext only; max 75 chars).

required action_id str

an identifier so the source of the action can be known.

required url Optional[str]

a URL to load in the user's browser when the button is clicked.

None value Optional[str]

the value sent with the interaction payload.

None style Optional[str]

the visual style of the button, one of primary, danger.

None confirm Optional[ConfirmationDialogue]

a ConfirmationDialogue object that will be presented when the button is clicked.

None accessibility_label Optional[str]

a string label for longer descriptive text about a button element. Used by screen readers (max 75 chars).

None

Throws: InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class Button(Element):\n    \"\"\"\n    An interactive element that inserts a button. The button can be a\n    trigger for anything from opening a simple link to starting a complex\n    workflow.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#button>.\n\n    Args:\n        text: text on the button (plaintext only; max 75 chars).\n        action_id: an identifier so the source of the action can be known.\n        url: a URL to load in the user's browser when the button is clicked.\n        value: the value sent with the interaction payload.\n        style: the visual style of the button, one of `primary`, `danger`.\n        confirm: a `ConfirmationDialogue` object that will be presented when\n            the button is clicked.\n        accessibility_label: a string label for longer descriptive text about\n            a button element. Used by screen readers (max 75 chars).\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        text: TextLike,\n        action_id: str,\n        url: Optional[str] = None,\n        value: Optional[str] = None,\n        style: Optional[str] = None,\n        confirm: Optional[ConfirmationDialogue] = None,\n        accessibility_label: Optional[str] = None,\n    ) -> \"Button\":\n        super().__init__(type_=ElementType.BUTTON)\n        self.text = Text.to_text(text, max_length=75, force_plaintext=True)\n        self.action_id = validate_action_id(action_id)\n        self.url = validate_string(\n            url, field_name=\"url\", max_length=3000, allow_none=True\n        )\n        self.value = validate_string(\n            value,\n            field_name=\"value\",\n            max_length=2000,\n            allow_none=True,\n        )\n        self.style = style.value if isinstance(style, ButtonStyle) else style\n        self.confirm = confirm\n        self.accessibility_label = validate_string(\n            accessibility_label,\n            \"accessibility_label\",\n            max_length=75,\n            allow_none=True,\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        button = self._attributes()\n        button[\"text\"] = self.text._resolve()\n        button[\"action_id\"] = self.action_id\n        if self.style:\n            button[\"style\"] = self.style\n        if self.url:\n            button[\"url\"] = self.url\n        if self.value:\n            button[\"value\"] = self.value\n        if self.confirm:\n            button[\"confirm\"] = self.confirm._resolve()\n        if self.accessibility_label:\n            button[\"accessibility_label\"] = self.accessibility_label\n        return button\n
"},{"location":"reference/elements/#elements.ButtonStyle","title":"ButtonStyle","text":"

Utility class for determining the style of Buttons and WorkflowButtons.

Source code in slackblocks/elements.py
class ButtonStyle(Enum):\n    \"\"\"\n    Utility class for determining the style of `Buttons` and `WorkflowButtons`.\n    \"\"\"\n\n    DEFAULT = None\n    PRIMARY = \"primary\"\n    DANGER = \"danger\"\n\n    @staticmethod\n    def to_button_style(style: Optional[Union[\"ButtonStyle\", str]]) -> \"ButtonStyle\":\n        if isinstance(style, ButtonStyle):\n            return style\n        if isinstance(style, (str, None)):\n            return ButtonStyle[style]\n        raise InvalidUsageError(\n            f\"Can only coerce to ButtonStyle from ButtonStyle or string, not {type(style)}.\"\n        )\n
"},{"location":"reference/elements/#elements.ChannelMultiSelectMenu","title":"ChannelMultiSelectMenu","text":"

This interactive UI element allows users to select multiple channels visible to the current user in the active workspace.

See: https://api.slack.com/reference/block-kit/block-elements#channel_multi_select.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_channels Optional[List[str]]

a list of conversation IDs as strings that will already be selected when the menu renders.

None confirm ConfirmationDialogue

a ConfirmationDialogue object that will be presented when the menu is used.

None max_selected_items Optional[int]

the maximum number of items that can be selected in the menu.

None focus_on_load bool

whether or not the menu will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the menu when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class ChannelMultiSelectMenu(Element):\n    \"\"\"\n    This interactive UI element allows users to select multiple channels visible\n        to the current user in the active workspace.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#channel_multi_select>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_channels: a list of conversation IDs as strings that will\n            already be selected when the menu renders.\n        confirm: a `ConfirmationDialogue` object that will be presented when\n            the menu is used.\n        max_selected_items: the maximum number of items that can be selected\n            in the menu.\n        focus_on_load: whether or not the menu will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the menu when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_channels: Optional[List[str]] = None,\n        confirm: ConfirmationDialogue = None,\n        max_selected_items: Optional[int] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.MULTI_SELECT_CHANNELS)\n        self.action_id = validate_action_id(action_id)\n        self.initial_channels = coerce_to_list(\n            initial_channels, class_=str, allow_none=True\n        )\n        self.confirm = confirm\n        self.max_selected_items = max_selected_items\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, force_plaintext=True, max_length=150, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        channel_multi_select = self._attributes()\n        channel_multi_select[\"action_id\"] = self.action_id\n        if self.initial_channels:\n            channel_multi_select[\"initial_channels\"] = [\n                initial_option._resolve() for initial_option in self.initial_channels\n            ]\n        if self.confirm:\n            channel_multi_select[\"confirm\"] = self.confirm._resolve()\n        if self.max_selected_items:\n            channel_multi_select[\"max_selected_items\"] = self.max_selected_items\n        if self.focus_on_load:\n            channel_multi_select[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            channel_multi_select[\"placeholder\"] = self.placeholder._resolve()\n        return channel_multi_select\n
"},{"location":"reference/elements/#elements.ChannelSelectMenu","title":"ChannelSelectMenu","text":"

A select menu interactive UI element, sourced with a list of public channels visible to the current user.

See: https://api.slack.com/reference/block-kit/block-elements#channels_select.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_channel Optional[str]

the single (string) user ID that will be initially selected when first presented to the user.

None confirm Optional[ConfirmationDialogue]

a ConfirmationDialogue object that will be presented when an option in the overflow menu is selected.

None response_url_enabled Optional[bool]

When set to true, the view_submission payload from the menu's parent view will contain a response_url. (This response_url can be used for message responses).

False focus_on_load bool

whether or not the input will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the input when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class ChannelSelectMenu(Element):\n    \"\"\"\n    A select menu interactive UI element, sourced with a list of public channels visible\n        to the current user.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#channels_select>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_channel: the single (string) user ID that will be initially selected\n            when first presented to the user.\n        confirm: a `ConfirmationDialogue` object that will be presented when an\n            option in the overflow menu is selected.\n        response_url_enabled: When set to true, the view_submission payload from the\n            menu's parent view will contain a response_url. (This response_url can be\n            used for message responses).\n        focus_on_load: whether or not the input will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the input when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_channel: Optional[str] = None,\n        confirm: Optional[ConfirmationDialogue] = None,\n        response_url_enabled: Optional[bool] = False,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.CHANNELS_SELECT_MENU)\n        self.action_id = validate_action_id(action_id)\n        self.initial_channel = initial_channel\n        self.confirm = confirm\n        self.response_url_enabled = response_url_enabled\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder,\n            max_length=150,\n            force_plaintext=True,\n            allow_none=True,\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        channel_select_menu = self._attributes()\n        channel_select_menu[\"action_id\"] = self.action_id\n        if self.initial_channel:\n            channel_select_menu[\"initial_channel\"] = self.initial_channel\n        if self.confirm:\n            channel_select_menu[\"confirm\"] = self.confirm._resolve()\n        if self.response_url_enabled:\n            channel_select_menu[\"response_url_enabled\"] = self.response_url_enabled\n        if self.focus_on_load:\n            channel_select_menu[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            channel_select_menu[\"placeholder\"] = self.placeholder._resolve()\n        return channel_select_menu\n
"},{"location":"reference/elements/#elements.CheckboxGroup","title":"CheckboxGroup","text":"

A checkbox group that allows a user to choose multiple items from a list of possible options.

See: https://api.slack.com/reference/block-kit/block-elements#checkboxes.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required options Union[Option, List[Option]]

a list of Option objects that will form the content of the checkbox group.

required initial_options Optional[Union[Option, List[Option]]]

a list of Option objects that will be initially selected when first presented to the user.

None confirm ConfirmationDialogue

a ConfirmationDialogue object that will be presented when the checkbox group is used.

None focus_on_load bool

whether or not the checkbox group will be set to autofocus within the view object.

False Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class CheckboxGroup(Element):\n    \"\"\"\n    A checkbox group that allows a user to choose multiple items from a list\n    of possible options.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#checkboxes>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        options: a list of\n            [`Option`](/slackblocks/latest/reference/objects/#objects.Option) objects that will form\n            the content of the checkbox group.\n        initial_options: a list of\n            [`Option`](/slackblocks/latest/reference/objects/#objects.Option) objects that will be\n            initially selected when first presented to the user.\n        confirm: a `ConfirmationDialogue` object that will be presented when\n            the checkbox group is used.\n        focus_on_load: whether or not the checkbox group will be set to autofocus\n            within the view object.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        options: Union[Option, List[Option]],\n        initial_options: Optional[Union[Option, List[Option]]] = None,\n        confirm: ConfirmationDialogue = None,\n        focus_on_load: bool = False,\n    ) -> \"CheckboxGroup\":\n        super().__init__(type_=ElementType.CHECKBOXES)\n        self.action_id = validate_action_id(action_id)\n        self.options = coerce_to_list(options, Option)\n        self.initial_options = coerce_to_list(initial_options, Option, allow_none=True)\n        self.confirm = confirm\n        self.focus_on_load = focus_on_load\n\n    def _resolve(self) -> Dict[str, Any]:\n        checkbox_group = self._attributes()\n        checkbox_group[\"action_id\"] = self.action_id\n        checkbox_group[\"options\"] = [option._resolve() for option in self.options]\n        if self.initial_options:\n            checkbox_group[\"initial_options\"] = [\n                option._resolve() for option in self.initial_options\n            ]\n        if self.confirm:\n            checkbox_group[\"confirm\"] = self.confirm._resolve()\n        if self.focus_on_load:\n            checkbox_group[\"focus_on_load\"] = self.focus_on_load\n        return checkbox_group\n
"},{"location":"reference/elements/#elements.ConversationMultiSelectMenu","title":"ConversationMultiSelectMenu","text":"

This interactive UI element allows users to select multiple conversations visible to the current user in the active workspace.

See: https://api.slack.com/reference/block-kit/block-elements#conversation_multi_select.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_conversations Optional[List[str]]

a list of conversation IDs as strings that will already be selected when the menu renders.

None default_to_current_conversation Optional[bool]

Pre-populates the select menu with the conversation that the user was viewing when they opened the modal (defaults to False).

False confirm ConfirmationDialogue

a ConfirmationDialogue object that will be presented when the menu is used.

None max_selected_items Optional[int]

the maximum number of items that can be selected in the menu.

None filter Optional[ConversationFilter]

a Filter object that filters out conversations that don't match the settings of the filter.

None focus_on_load Optional[bool]

whether or not the menu will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the menu when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class ConversationMultiSelectMenu(Element):\n    \"\"\"\n    This interactive UI element allows users to select multiple conversations visible\n        to the current user in the active workspace.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#conversation_multi_select>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_conversations: a list of conversation IDs as strings that will\n            already be selected when the menu renders.\n        default_to_current_conversation: Pre-populates the select menu with the\n            conversation that the user was viewing when they opened the modal\n            (defaults to `False`).\n        confirm: a `ConfirmationDialogue` object that will be presented when\n            the menu is used.\n        max_selected_items: the maximum number of items that can be selected\n            in the menu.\n        filter: a [`Filter`](/slackblocks/latest/reference/objects/#objects.ConversationFilter)\n            object that filters out conversations that don't match the settings\n            of the filter.\n        focus_on_load: whether or not the menu will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the menu when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_conversations: Optional[List[str]] = None,\n        default_to_current_conversation: Optional[bool] = False,\n        confirm: ConfirmationDialogue = None,\n        max_selected_items: Optional[int] = None,\n        filter: Optional[ConversationFilter] = None,\n        focus_on_load: Optional[bool] = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.MULTI_SELECT_CONVERSATIONS)\n        self.action_id = validate_action_id(action_id)\n        self.initial_conversations = coerce_to_list(\n            initial_conversations, str, allow_none=True\n        )\n        self.default_to_current_conversation = default_to_current_conversation\n        self.confirm = confirm\n        self.max_selected_items = max_selected_items\n        self.filter = filter\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, force_plaintext=True, max_length=150, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        conversation_multi_select = self._attributes()\n        conversation_multi_select[\"action_id\"] = self.action_id\n        if self.initial_conversations:\n            conversation_multi_select[\"intial_conversations\"] = (\n                self.initial_conversations\n            )\n        if self.default_to_current_conversation:\n            conversation_multi_select[\"default_to_current_conversation\"] = (\n                self.default_to_current_conversation\n            )\n        if self.confirm:\n            conversation_multi_select[\"confirm\"] = self.confirm._resolve()\n        if self.max_selected_items:\n            conversation_multi_select[\"max_selected_items\"] = self.max_selected_items\n        if self.filter:\n            conversation_multi_select[\"filter\"] = self.filter._resolve()\n        if self.focus_on_load:\n            conversation_multi_select[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            conversation_multi_select[\"placeholder\"] = self.placeholder._resolve()\n        return conversation_multi_select\n
"},{"location":"reference/elements/#elements.ConversationSelectMenu","title":"ConversationSelectMenu","text":"

A select menu interactive UI element, sourced with a list of public and private channels, DMs, and MPIMs visible to the current user.

See: https://api.slack.com/reference/block-kit/block-elements#conversations_select.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_conversation Optional[str]

the single (string) coversation ID that will be initially selected when first presented to the user.

None default_to_current_conversation Optional[bool]

Pre-populates the select menu with the conversation that the user was viewing when they opened the modal (defaults to False).

False confirm Optional[ConfirmationDialogue]

a ConfirmationDialogue object that will be presented when an option in the overflow menu is selected.

None response_url_enabled Optional[bool]

When set to true, the view_submission payload from the menu's parent view will contain a response_url. (This response_url can be used for message responses).

False filter Optional[ConversationFilter]

a Filter object that filters out conversations that don't match the settings of the filter.

None focus_on_load bool

whether or not the input will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the input when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class ConversationSelectMenu(Element):\n    \"\"\"\n    A select menu interactive UI element, sourced with a list of public and private channels,\n        DMs, and MPIMs visible to the current user.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#conversations_select>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_conversation: the single (string) coversation ID that will be initially\n            selected when first presented to the user.\n        default_to_current_conversation: Pre-populates the select menu with the\n            conversation that the user was viewing when they opened the modal\n            (defaults to `False`).\n        confirm: a `ConfirmationDialogue` object that will be presented when an\n            option in the overflow menu is selected.\n        response_url_enabled: When set to true, the view_submission payload from the\n            menu's parent view will contain a response_url. (This response_url can be\n            used for message responses).\n        filter: a [`Filter`](/slackblocks/latest/reference/objects/#objects.ConversationFilter)\n            object that filters out conversations that don't match the settings\n            of the filter.\n        focus_on_load: whether or not the input will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the input when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_conversation: Optional[str] = None,\n        default_to_current_conversation: Optional[bool] = False,\n        confirm: Optional[ConfirmationDialogue] = None,\n        response_url_enabled: Optional[bool] = False,\n        filter: Optional[ConversationFilter] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.CONVERSATIONS_SELECT_MENU)\n        self.action_id = validate_action_id(action_id)\n        self.initial_conversation = initial_conversation\n        self.default_to_current_conversation = default_to_current_conversation\n        self.confirm = confirm\n        self.response_url_enabled = response_url_enabled\n        self.filter = filter\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder,\n            max_length=150,\n            force_plaintext=True,\n            allow_none=True,\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        conversation_select_menu = self._attributes()\n        conversation_select_menu[\"action_id\"] = self.action_id\n        if self.initial_conversation:\n            conversation_select_menu[\"initial_conversation\"] = self.initial_conversation\n        if self.default_to_current_conversation:\n            conversation_select_menu[\"default_to_current_conversation\"] = (\n                self.default_to_current_conversation\n            )\n        if self.confirm:\n            conversation_select_menu[\"confirm\"] = self.confirm._resolve()\n        if self.response_url_enabled:\n            conversation_select_menu[\"response_url_enabled\"] = self.response_url_enabled\n        if self.filter:\n            conversation_select_menu[\"filter\"] = self.filter\n        if self.focus_on_load:\n            conversation_select_menu[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            conversation_select_menu[\"placeholder\"] = self.placeholder._resolve()\n        return conversation_select_menu\n
"},{"location":"reference/elements/#elements.DatePicker","title":"DatePicker","text":"

Interactive element that allows users to select a date from a calendar.

See: https://api.slack.com/reference/block-kit/block-elements#datepicker.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_date Optional[str]

the date (in YYYY-MM-DD format) that will appear on the picker when it first renders.

None confirm ConfirmationDialogue

a ConfirmationDialogue object that will be presented when the date picker is clicked.

None focus_on_load bool

whether or not the date picker will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a TextType.PLAINTEXT Text object that defines what text will initially appear on the picker.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class DatePicker(Element):\n    \"\"\"\n    Interactive element that allows users to select a date from a calendar.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#datepicker>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_date: the date (in `YYYY-MM-DD` format) that will appear on the\n            picker when it first renders.\n        confirm: a `ConfirmationDialogue` object that will be presented when\n            the date picker is clicked.\n        focus_on_load: whether or not the date picker will be set to autofocus\n            within the view object.\n        placeholder: a `TextType.PLAINTEXT` `Text` object that defines what text\n            will initially appear on the picker.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_date: Optional[str] = None,\n        confirm: ConfirmationDialogue = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ) -> \"DatePicker\":\n        super().__init__(type_=ElementType.DATE_PICKER)\n        self.action_id = validate_action_id(action_id)\n        if initial_date:\n            self.initial_date = datetime.strptime(initial_date, \"%Y-%m-%d\").strftime(\n                \"%Y-%m-%d\"\n            )\n        self.confirm = confirm\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, force_plaintext=True, max_length=150, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        date_picker = self._attributes()\n        date_picker[\"action_id\"] = self.action_id\n        if self.initial_date is not None:\n            date_picker[\"initial_date\"] = self.initial_date\n        if self.confirm:\n            date_picker[\"confirm\"] = self.confirm\n        if self.focus_on_load:\n            date_picker[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            date_picker[\"placeholder\"] = self.placeholder._resolve()\n        return date_picker\n
"},{"location":"reference/elements/#elements.DateTimePicker","title":"DateTimePicker","text":"

Allows users to select both a date and a time of day.

Provides the date-time formatted as a Unix timestamp.

See: https://api.slack.com/reference/block-kit/block-elements#datetimepicker.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_datetime Optional[int]

the initial value the date-time picker will be set to when it first renders.

None confirm ConfirmationDialogue

a ConfirmationDialogue object that will be presented when the button is date-time picker is used.

None focus_on_load bool

whether or not the datetime picker will be set to autofocus within the view object.

False

Throws: InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class DateTimePicker(Element):\n    \"\"\"\n    Allows users to select both a date and a time of day.\n\n    Provides the date-time formatted as a Unix timestamp.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#datetimepicker>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_datetime: the initial value the date-time picker will be set to\n            when it first renders.\n        confirm: a `ConfirmationDialogue` object that will be presented when\n            the button is date-time picker is used.\n        focus_on_load: whether or not the datetime picker will be set to autofocus\n            within the view object.\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_datetime: Optional[int] = None,\n        confirm: ConfirmationDialogue = None,\n        focus_on_load: bool = False,\n    ) -> \"DateTimePicker\":\n        super().__init__(type_=ElementType.DATETIME_PICKER)\n        self.action_id = validate_action_id(action_id)\n        if initial_datetime:\n            self.initial_datetime = initial_datetime\n        self.confirm = confirm\n        self.focus_on_load = focus_on_load\n\n    def _resolve(self) -> Dict[str, Any]:\n        datetime_picker = self._attributes()\n        datetime_picker[\"action_id\"] = self.action_id\n        if self.initial_datetime:\n            datetime_picker[\"initial_date_time\"] = self.initial_datetime\n        if self.confirm:\n            datetime_picker[\"confirm\"] = self.confirm\n        if self.focus_on_load:\n            datetime_picker[\"focus_on_load\"] = self.focus_on_load\n        return datetime_picker\n
"},{"location":"reference/elements/#elements.EmailInput","title":"EmailInput","text":"

Allows user to enter an email into a single-line text field.

See: https://api.slack.com/reference/block-kit/block-elements#email.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_value Optional[str]

The initial value in the email input when it is loaded.

None dispatch_action_config Optional[DispatchActionConfiguration]

a DispatchActionConfiguration object that determines when during text input the element returns a block_actions payload.

None focus_on_load bool

whether or not the email input will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a TextType.PLAINTEXT Text object that defines what text will initially appear in the input field.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class EmailInput(Element):\n    \"\"\"\n    Allows user to enter an email into a single-line text field.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#email>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_value: The initial value in the email input when it is loaded.\n        dispatch_action_config: a `DispatchActionConfiguration` object that\n            determines when during text input the element returns a\n            `block_actions` payload.\n        focus_on_load: whether or not the email input will be set to autofocus\n            within the view object.\n        placeholder: a `TextType.PLAINTEXT` `Text` object that defines what text\n            will initially appear in the input field.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_value: Optional[str] = None,\n        dispatch_action_config: Optional[DispatchActionConfiguration] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.EMAIL_INPUT)\n        self.action_id = validate_action_id(action_id)\n        self.initial_value = initial_value\n        self.dispatch_action_config = dispatch_action_config\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, max_length=150, force_plaintext=True, allow_none=True\n        )\n\n    def _resolve(self):\n        email_input = self._attributes()\n        email_input[\"action_id\"] = self.action_id\n        if self.initial_value:\n            email_input[\"initial_value\"] = self.initial_value\n        if self.dispatch_action_config:\n            email_input[\"dispatch_action_config\"] = (\n                self.dispatch_action_config._resolve()\n            )\n        if self.focus_on_load:\n            email_input[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            email_input[\"placeholder\"] = self.placeholder._resolve()\n        return email_input\n
"},{"location":"reference/elements/#elements.ExternalMultiSelectMenu","title":"ExternalMultiSelectMenu","text":"

An interactive UI element that loads its options from an external data source, allowing for a dynamic list of options.

See: https://api.slack.com/reference/block-kit/block-elements#external_multi_select.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required min_query_length Optional[int]

minimum number of characters entered before the query is dispactched (defaults to 3 if not provided).

None initial_options Optional[Union[Option, List[Option], OptionGroup, List[OptionGroup]]]

the Options to be intially selected when the element is first rendered.

None confirm ConfirmationDialogue

a ConfirmationDialogue object that will be presented when the menu is used.

None max_selected_items Optional[int]

the highest number of items from the list that can be selected at one time.

None focus_on_load bool

whether or not the menu will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the menu when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class ExternalMultiSelectMenu(Element):\n    \"\"\"\n    An interactive UI element that loads its options from an external data source,\n        allowing for a dynamic list of options.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#external_multi_select>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        min_query_length: minimum number of characters entered before the query\n            is dispactched (defaults to 3 if not provided).\n        initial_options: the [`Options`](/slackblocks/latest/reference/objects/#objects.Option)\n            to be intially selected when the element is first rendered.\n        confirm: a `ConfirmationDialogue` object that will be presented when\n            the menu is used.\n        max_selected_items: the highest number of items from the list that\n            can be selected at one time.\n        focus_on_load: whether or not the menu will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the menu when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        min_query_length: Optional[int] = None,\n        initial_options: Optional[\n            Union[Option, List[Option], OptionGroup, List[OptionGroup]]\n        ] = None,\n        confirm: ConfirmationDialogue = None,\n        max_selected_items: Optional[int] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.MULTI_SELECT_EXTERNAL)\n        self.action_id = validate_action_id(action_id)\n        self.min_query_length = min_query_length\n        self.initial_options = coerce_to_list(\n            initial_options, class_=(Option, OptionGroup), allow_none=True, max_size=100\n        )\n        self.confirm = confirm\n        self.max_selected_items = max_selected_items\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, force_plaintext=True, max_length=150, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        external_select_menu = self._attributes()\n        external_select_menu[\"action_id\"] = self.action_id\n        if self.min_query_length:\n            external_select_menu[\"min_query_length\"] = self.min_query_length\n        if self.initial_options:\n            external_select_menu[\"initial_options\"] = [\n                initial_option._resolve() for initial_option in self.initial_options\n            ]\n        if self.confirm:\n            external_select_menu[\"confirm\"] = self.confirm._resolve()\n        if self.max_selected_items:\n            external_select_menu[\"max_selected_items\"] = self.max_selected_items\n        if self.focus_on_load:\n            external_select_menu[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            external_select_menu[\"placeholder\"] = self.placeholder._resolve()\n        return external_select_menu\n
"},{"location":"reference/elements/#elements.ExternalSelectMenu","title":"ExternalSelectMenu","text":"

A select menu interactive UI element, sourced with externally provided options.

See: https://api.slack.com/slackblocks/latest/reference/block-kit/block-elements#external_select.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_option Union[Option, OptionGroup]

an Option object that will be initially selected when first presented to the user.

None min_query_length Optional[int]

minimum number of characters entered before the query is dispactched (defaults to 3 if not provided).

None confirm Optional[ConfirmationDialogue]

a ConfirmationDialogue object that will be presented when an option in the overflow menu is selected.

None focus_on_load bool

whether or not the input will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the input when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class ExternalSelectMenu(Element):\n    \"\"\"\n    A select menu interactive UI element, sourced with externally provided options.\n\n    See: <https://api.slack.com/slackblocks/latest/reference/block-kit/block-elements#external_select>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_option: an\n            [`Option`](/slackblocks/latest/reference/objects/#objects.Option) object that will be\n            initially selected when first presented to the user.\n        min_query_length: minimum number of characters entered before the query\n            is dispactched (defaults to 3 if not provided).\n        confirm: a `ConfirmationDialogue` object that will be presented when an\n            option in the overflow menu is selected.\n        focus_on_load: whether or not the input will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the input when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_option: Union[Option, OptionGroup] = None,\n        min_query_length: Optional[int] = None,\n        confirm: Optional[ConfirmationDialogue] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.EXTERNAL_SELECT_MENU)\n        self.action_id = validate_action_id(action_id)\n        self.initial_option = initial_option\n        self.min_query_length = min_query_length\n        self.confirm = confirm\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder,\n            max_length=150,\n            force_plaintext=True,\n            allow_none=True,\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        external_select_menu = self._attributes()\n        external_select_menu[\"action_id\"] = self.action_id\n        if self.initial_option:\n            external_select_menu[\"initial_option\"] = self.initial_option._resolve()\n        if self.min_query_length is not None:\n            external_select_menu[\"min_query_length\"] = self.min_query_length\n        if self.confirm:\n            external_select_menu[\"confirm\"] = self.confirm._resolve()\n        if self.focus_on_load:\n            external_select_menu[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            external_select_menu[\"placeholder\"] = self.placeholder._resolve()\n        return external_select_menu\n
"},{"location":"reference/elements/#elements.FileInput","title":"FileInput","text":"

An interactive element that allows users to upload files.

See: https://api.slack.com/reference/block-kit/block-elements#file_input.

Parameters:

Name Type Description Default action_id Optional[str]

an identifier so the source of the action can be known.

None filetypes Optional[Union[str, List[str]]]

a list of file extensions (as strings) that will be accepted for upload.

None max_files Optional[int]

the maximum number of files that can be uploaded (between 1 and 10).

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class FileInput(Element):\n    \"\"\"\n    An interactive element that allows users to upload files.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#file_input>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        filetypes: a list of file extensions (as strings) that will be accepted\n            for upload.\n        max_files: the maximum number of files that can be uploaded (between 1\n            and 10).\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: Optional[str] = None,\n        filetypes: Optional[Union[str, List[str]]] = None,\n        max_files: Optional[int] = None,\n    ) -> \"FileInput\":\n        super().__init__(ElementType.FILE_INPUT)\n        self.action_id = validate_action_id(action_id)\n        self.filetypes = coerce_to_list(\n            filetypes,\n            (str),\n            allow_none=True,\n        )\n        self.max_files = validate_int(\n            max_files, min_value=1, max_value=10, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        file_input = super()._resolve()\n        if self.action_id is not None:\n            file_input[\"action_id\"] = self.action_id\n        if self.filetypes is not None:\n            file_input[\"filetypes\"] = self.filetypes\n        if self.max_files is not None:\n            file_input[\"max_files\"] = self.max_files\n        return file_input\n
"},{"location":"reference/elements/#elements.Image","title":"Image","text":"

An element to insert an image - this element can be used in section and context blocks only. If you want a block with only an image in it, you're looking for the Image block.

You must provide either one of image_url or slack_file

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

Parameters:

Name Type Description Default alt_text str

a plain-text-only summary of the content of the image.

' ' image_url Optional[str]

a URL for a publicly hosted image (the user must provide either image_url or slack_file).

None slack_file Optional[SlackFile]

a SlackFile (the user must provide either image_url or slack_file).

None Throws

InvalidUsageError: if any of the provided arguments fail validation, or both/neither of image_url and slack_file are provided.

Source code in slackblocks/elements.py
class Image(Element):\n    \"\"\"\n    An element to insert an image - this element can be used in section\n    and context blocks only. If you want a block with only an image in it,\n    you're looking for the Image block.\n\n    You must provide either one of `image_url` or `slack_file`\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#image>.\n\n    Args:\n        alt_text: a plain-text-only summary of the content of the image.\n        image_url: a URL for a publicly hosted image (the user must provide\n            either `image_url` or `slack_file`).\n        slack_file: a [`SlackFile`](/slackblocks/latest/reference/objects/#objects.SlackFile)\n            (the user must provide either `image_url` or `slack_file`).\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation,\n            or both/neither of `image_url` and `slack_file` are provided.\n    \"\"\"\n\n    def __init__(\n        self,\n        alt_text: str = \" \",\n        image_url: Optional[str] = None,\n        slack_file: Optional[SlackFile] = None,\n    ):\n        super().__init__(type_=ElementType.IMAGE)\n        if image_url is None and slack_file is None:\n            raise InvalidUsageError(\"Must provide one of `image_url` or `slack_file`\")\n        if image_url and slack_file:\n            raise InvalidUsageError(\"Cannot provide both `image_url` or `slack_file`\")\n        self.image_url = image_url\n        self.alt_text = alt_text\n        self.slack_file = slack_file\n\n    def _resolve(self) -> Dict[str, Any]:\n        image = self._attributes()\n        if self.image_url is not None:\n            image[\"image_url\"] = self.image_url\n        image[\"alt_text\"] = self.alt_text\n        if self.slack_file is not None:\n            image[\"slack_file\"] = self.slack_file\n        return image\n
"},{"location":"reference/elements/#elements.NumberInput","title":"NumberInput","text":"

This input elements accepts both integer and decimal numbers. For example, 0.25, 5.5, and -10 are all valid input values.

See https://api.slack.com/reference/block-kit/block-elements#number.

Parameters:

Name Type Description Default is_decimal_allowed bool

whether to accept decimal values as input.

required action_id Optional[str]

an identifier so the source of the action can be known.

None initial_value Optional[str]

the initial value in the number input when it is loaded.

None min_value Optional[Union[float, int]]

minimum accepted value for the input field.

None max_value Optional[Union[float, int]]

maximum accepted value for the input field.

None dispatch_action_config Optional[DispatchActionConfiguration]

a DispatchActionConfiguration object that determines when during text input the element returns a block_actions payload.

None focus_on_load bool

whether or not the menu will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the input when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class NumberInput(Element):\n    \"\"\"\n    This input elements accepts both integer and decimal numbers. For example,\n    0.25, 5.5, and -10 are all valid input values.\n\n    See <https://api.slack.com/reference/block-kit/block-elements#number>.\n\n    Args:\n        is_decimal_allowed: whether to accept decimal values as input.\n        action_id: an identifier so the source of the action can be known.\n        initial_value: the initial value in the number input when it is loaded.\n        min_value: minimum accepted value for the input field.\n        max_value: maximum accepted value for the input field.\n        dispatch_action_config: a `DispatchActionConfiguration` object that\n            determines when during text input the element returns a\n            `block_actions` payload.\n        focus_on_load: whether or not the menu will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the input when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        is_decimal_allowed: bool,\n        action_id: Optional[str] = None,\n        initial_value: Optional[str] = None,\n        min_value: Optional[Union[float, int]] = None,\n        max_value: Optional[Union[float, int]] = None,\n        dispatch_action_config: Optional[DispatchActionConfiguration] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.NUMBER_INPUT)\n        self.is_decimal_allowed = is_decimal_allowed\n        self.action_id = validate_action_id(action_id, allow_none=True)\n        self.initial_value = initial_value\n        self.min_value = min_value\n        self.max_value = max_value\n        if min_value:\n            if not is_decimal_allowed:\n                if isinstance(min_value, float):\n                    raise InvalidUsageError(\n                        f\"`min_value` ({min_value}) cannot be a float when \"\n                        \"`is_decimal_allowed` is `False`\"\n                    )\n        if max_value:\n            if not is_decimal_allowed:\n                if isinstance(max_value, float):\n                    raise InvalidUsageError(\n                        f\"`max_value` ({max_value}) cannot be a float when \"\n                        \"`is_decimal_allowed` is `False`\"\n                    )\n        if (min_value or min_value == 0) and (max_value or max_value == 0):\n            if min_value > max_value:\n                raise InvalidUsageError(\n                    f\"`min_value` ({min_value}) cannot be greater than \"\n                    \"`max_value` ({min_value})\"\n                )\n        self.dispatch_action_config = dispatch_action_config\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, max_length=150, force_plaintext=True, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        number_input = self._attributes()\n        number_input[\"is_decimal_allowed\"] = self.is_decimal_allowed\n        if self.action_id:\n            number_input[\"action_id\"] = self.action_id\n        if self.initial_value:\n            number_input[\"initial_value\"] = self.initial_value\n        if self.min_value:\n            number_input[\"min_value\"] = self.min_value\n        if self.max_value:\n            number_input[\"max_value\"] = self.max_value\n        if self.dispatch_action_config:\n            number_input[\"dispatch_action_config\"] = (\n                self.dispatch_action_config._resolve()\n            )\n        if self.focus_on_load:\n            number_input[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            number_input[\"placeholder\"] = self.placeholder._resolve()\n        return number_input\n
"},{"location":"reference/elements/#elements.OverflowMenu","title":"OverflowMenu","text":"

Context menu for additional options (think '...').

See https://api.slack.com/reference/block-kit/block-elements#overflow.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required options Union[Option, List[Option]]

a list of Option objects that will form the content of the overflow menu.

required confirm ConfirmationDialogue

a ConfirmationDialogue object that will be presented when an option in the overflow menu is selected.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class OverflowMenu(Element):\n    \"\"\"\n    Context menu for additional options (think '...').\n\n    See <https://api.slack.com/reference/block-kit/block-elements#overflow>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        options: a list of\n            [`Option`](/slackblocks/latest/reference/objects/#objects.Option) objects that will form\n            the content of the overflow menu.\n        confirm: a `ConfirmationDialogue` object that will be presented when an\n            option in the overflow menu is selected.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        options: Union[Option, List[Option]],\n        confirm: ConfirmationDialogue = None,\n    ):\n        super().__init__(type_=ElementType.OVERFLOW_MENU)\n        self.action_id = validate_action_id(action_id)\n        self.options = coerce_to_list(options, Option, min_size=1, max_size=5)\n        self.confirm = confirm\n\n    def _resolve(self) -> Dict[str, Any]:\n        overflow_menu = self._attributes()\n        overflow_menu[\"action_id\"] = self.action_id\n        overflow_menu[\"options\"] = [option._resolve() for option in self.options]\n        if self.confirm:\n            overflow_menu[\"confirm\"] = self.confirm._resolve()\n        return overflow_menu\n
"},{"location":"reference/elements/#elements.PlainTextInput","title":"PlainTextInput","text":"

A plain-text input, similar to the HTML tag, creates a field where a user can enter freeform data. It can appear as a single-line field or a larger text area using the multiline flag.

See: https://api.slack.com/reference/block-kit/block-elements#input.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_value Optional[str]

the initial value in the plain-text input when it is loaded.

None multiline bool

whether to accept multiple lines of input(defaults to false).

False min_length Optional[int]

minimum number of characters to accept as input.

None max_length Optional[int]

maximum number of characters to accept as input.

None dispatch_action_config Optional[DispatchActionConfiguration]

a DispatchActionConfiguration object that determines when during text input the element returns a block_actions payload.

None focus_on_load bool

whether or not the input will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the input when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class PlainTextInput(Element):\n    \"\"\"\n    A plain-text input, similar to the HTML <input> tag, creates a field where a user\n    can enter freeform data. It can appear as a single-line field or a larger text\n    area using the multiline flag.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#input>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_value: the initial value in the plain-text input when it is loaded.\n        multiline: whether to accept multiple lines of input(defaults to false).\n        min_length: minimum number of characters to accept as input.\n        max_length: maximum number of characters to accept as input.\n        dispatch_action_config: a `DispatchActionConfiguration` object that\n            determines when during text input the element returns a\n            `block_actions` payload.\n        focus_on_load: whether or not the input will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the input when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_value: Optional[str] = None,\n        multiline: bool = False,\n        min_length: Optional[int] = None,\n        max_length: Optional[int] = None,\n        dispatch_action_config: Optional[DispatchActionConfiguration] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.PLAIN_TEXT_INPUT)\n        self.action_id = validate_action_id(action_id)\n        self.multiline = multiline\n        self.initial_value = initial_value\n        self.min_length = min_length\n        if max_length and max_length > 3000:\n            raise InvalidUsageError(\"`max_length` value cannot exceed 3000 characters\")\n        self.max_length = max_length\n        self.dispatch_action_config = dispatch_action_config\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, max_length=150, force_plaintext=True, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        plain_text_input = self._attributes()\n        if self.multiline:\n            plain_text_input[\"multiline\"] = self.multiline\n        if self.action_id:\n            plain_text_input[\"action_id\"] = self.action_id\n        if self.initial_value:\n            plain_text_input[\"initial_value\"] = self.initial_value\n        if self.min_length:\n            plain_text_input[\"min_length\"] = self.min_length\n        if self.max_length:\n            plain_text_input[\"max_length\"] = self.max_length\n        if self.dispatch_action_config:\n            plain_text_input[\"dispatch_action_config\"] = (\n                self.dispatch_action_config._resolve()\n            )\n        if self.focus_on_load:\n            plain_text_input[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            plain_text_input[\"placeholder\"] = self.placeholder._resolve()\n        return plain_text_input\n
"},{"location":"reference/elements/#elements.RadioButtonGroup","title":"RadioButtonGroup","text":"

A radio button group that allows a user to choose one item from a list of possible options.

See: https://api.slack.com/reference/block-kit/block-elements#radio.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required options List[Option]

a list of Option objects that will form the content of the radio button group.

required initial_option Optional[Option]

an Option object that will be initially selected when first presented to the user.

None confirm Optional[ConfirmationDialogue]

a ConfirmationDialogue object that will be presented when an option in the overflow menu is selected.

None focus_on_load bool

whether or not the input will be set to autofocus within the view object.

False Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class RadioButtonGroup(Element):\n    \"\"\"\n    A radio button group that allows a user to choose one item from a list of possible options.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#radio>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        options: a list of\n            [`Option`](/slackblocks/latest/reference/objects/#objects.Option) objects that will form\n            the content of the radio button group.\n        initial_option: an\n            [`Option`](/slackblocks/latest/reference/objects/#objects.Option) object that will be\n            initially selected when first presented to the user.\n        confirm: a `ConfirmationDialogue` object that will be presented when an\n            option in the overflow menu is selected.\n        focus_on_load: whether or not the input will be set to autofocus\n            within the view object.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        options: List[Option],\n        initial_option: Optional[Option] = None,\n        confirm: Optional[ConfirmationDialogue] = None,\n        focus_on_load: bool = False,\n    ):\n        super().__init__(type_=ElementType.RADIO_BUTTON_GROUP)\n        self.action_id = validate_action_id(action_id)\n        if len(options) < 1 or len(options) > 10:\n            raise InvalidUsageError(\n                \"Number of options to RadioButtonGroup must be between 1 and 10 (inclusive).\"\n            )\n        self.options = coerce_to_list(options, class_=Option, allow_none=False)\n        if initial_option is not None and initial_option not in options:\n            raise InvalidUsageError(\"`initial_option` must be a member of `options`\")\n        self.initial_option = initial_option\n        self.confirm = confirm\n        self.focus_on_load = focus_on_load\n\n    def _resolve(self) -> Dict[str, Any]:\n        radio_button_group = self._attributes()\n        radio_button_group[\"action_id\"] = self.action_id\n        radio_button_group[\"options\"] = [option._resolve() for option in self.options]\n        if self.initial_option:\n            radio_button_group[\"initial_option\"] = self.initial_option._resolve()\n        if self.confirm:\n            radio_button_group[\"confirm\"] = self.confirm._resolve()\n        if self.focus_on_load:\n            radio_button_group[\"focus_on_load\"] = self.focus_on_load\n        return radio_button_group\n
"},{"location":"reference/elements/#elements.RichTextInput","title":"RichTextInput","text":"

Allows users to enter formatted text in a WYSIWYG editor, similar to the Slack messaging experience.

See: https://api.slack.com/reference/block-kit/block-elements#rich_text_input.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_value Optional[RichText]

The initial value in the rich text input when it is loaded.

None dispatch_action_config Optional[DispatchActionConfiguration]

a DispatchActionConfiguration object that determines when during text input the element returns a block_actions payload.

None focus_on_load bool

whether or not the menu will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the menu when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class RichTextInput(Element):\n    \"\"\"\n    Allows users to enter formatted text in a WYSIWYG editor, similar to the Slack\n        messaging experience.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#rich_text_input>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_value: The initial value in the rich text input when it is loaded.\n        dispatch_action_config: a `DispatchActionConfiguration` object that\n            determines when during text input the element returns a\n            `block_actions` payload.\n        focus_on_load: whether or not the menu will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the menu when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_value: Optional[RichText] = None,\n        dispatch_action_config: Optional[DispatchActionConfiguration] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ) -> \"RichTextInput\":\n        super().__init__(ElementType.RICH_TEXT_INPUT)\n        self.action_id = validate_action_id(action_id)\n        self.initial_value = initial_value\n        self.dispatch_action_config = dispatch_action_config\n        self.focus_on_load = focus_on_load\n        self.placeholder = placeholder\n\n    def _resolve(self) -> Dict[str, Any]:\n        rich_text_input = super()._attributes()\n        rich_text_input[\"action_id\"] = self.action_id\n        if self.initial_value is not None:\n            rich_text_input[\"initial_value\"] = self.initial_value._resolve()\n        if self.dispatch_action_config is not None:\n            rich_text_input[\"dispatch_action_config\"] = self.dispatch_action_config\n        if self.focus_on_load is not None:\n            rich_text_input[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder is not None:\n            rich_text_input[\"placeholder\"] = self.placeholder\n        return rich_text_input\n
"},{"location":"reference/elements/#elements.StaticMultiSelectMenu","title":"StaticMultiSelectMenu","text":"

The most basic form of select menu containing a static list of options passed in when defining the element.

See: https://api.slack.com/reference/block-kit/block-elements#static_multi_select.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required options Union[Option, List[Option]]

a list of Options (max 100). Only one of options or option_groups must be provided.

required option_groups List[OptionGroup]

a list of OptionGroups (max 100). Only one of options or option_groups can be provided.

None initial_options Optional[Union[Option, List[Option], OptionGroup, List[OptionGroup]]]

the Options to be intially selected when the element is first rendered.

None confirm ConfirmationDialogue

a ConfirmationDialogue object that will be presented when the menu is used.

None max_selected_items Optional[int]

the

None focus_on_load bool

whether or not the menu will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the menu when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class StaticMultiSelectMenu(Element):\n    \"\"\"\n    The most basic form of select menu containing a static list of options\n    passed in when defining the element.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#static_multi_select>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        options: a list of [`Options`](/slackblocks/latest/reference/objects/#objects.Option)\n            (max 100). Only one of `options` or `option_groups` must be\n            provided.\n        option_groups: a list of\n            [`OptionGroups`](/slackblocks/latest/reference/objects/#objects.OptionGroup)\n            (max 100). Only one of `options` or `option_groups` can be\n            provided.\n        initial_options: the [`Options`](/slackblocks/latest/reference/objects/#objects.Option)\n            to be intially selected when the element is first rendered.\n        confirm: a `ConfirmationDialogue` object that will be presented when\n            the menu is used.\n        max_selected_items: the\n        focus_on_load: whether or not the menu will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the menu when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        options: Union[Option, List[Option]],\n        option_groups: List[OptionGroup] = None,\n        initial_options: Optional[\n            Union[Option, List[Option], OptionGroup, List[OptionGroup]]\n        ] = None,\n        confirm: ConfirmationDialogue = None,\n        max_selected_items: Optional[int] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.MULTI_SELECT_STATIC)\n        self.action_id = validate_action_id(action_id)\n        if options and option_groups:\n            raise InvalidUsageError(\n                \"Cannot set both `options` and `option_groups` parameters.\"\n            )\n        self.options = coerce_to_list(\n            options, class_=Option, allow_none=True, max_size=100\n        )\n        self.option_groups = coerce_to_list(\n            option_groups, class_=OptionGroup, allow_none=True, max_size=100\n        )\n        self.initial_options = coerce_to_list(\n            initial_options, class_=(Option, OptionGroup), allow_none=True, max_size=100\n        )\n        if (\n            options\n            and self.initial_options\n            and not all(isinstance(option, Option) for option in self.initial_options)\n        ):\n            raise InvalidUsageError(\n                \"If using `options` then `initial_options` must also be of type `List[Option]`, \"\n                f\"not `{type(self.initial_options)}`.\"\n            )\n        if (\n            option_groups\n            and self.initial_options\n            and not all(\n                isinstance(option, OptionGroup) for option in self.initial_options\n            )\n        ):\n            raise InvalidUsageError(\n                \"If using `option_groups` then `initial_options` must also be of type \"\n                f\"`List[OptionGroup]`, not `{type(self.initial_options)}`.\"\n            )\n\n        # Check that Option Text is all TextType.PLAINTEXT\n        if self.options:\n            options_to_validate = self.options\n        if self.option_groups:\n            options_to_validate = sum(\n                [option_group.options for option_group in option_groups], []\n            )\n        for option in options_to_validate:\n            if option.text.text_type == TextType.MARKDOWN:\n                raise InvalidUsageError(\n                    \"Text in Options for StaticSelectMenu can only be of TextType.PLAINTEXT\"\n                )\n\n        self.confirm = confirm\n        self.max_selected_items = max_selected_items\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, force_plaintext=True, max_length=150, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        static_multi_select = self._attributes()\n        static_multi_select[\"action_id\"] = self.action_id\n        if self.options:\n            static_multi_select[\"options\"] = [\n                option._resolve() for option in self.options\n            ]\n        if self.option_groups:\n            static_multi_select[\"option_groups\"] = [\n                option_group._resolve() for option_group in self.option_groups\n            ]\n        if self.initial_options:\n            static_multi_select[\"initial_options\"] = [\n                initial_option._resolve() for initial_option in self.initial_options\n            ]\n        if self.confirm:\n            static_multi_select[\"confirm\"] = self.confirm._resolve()\n        if self.max_selected_items:\n            static_multi_select[\"max_selected_items\"] = self.max_selected_items\n        if self.focus_on_load:\n            static_multi_select[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            static_multi_select[\"placeholder\"] = self.placeholder._resolve()\n        return static_multi_select\n
"},{"location":"reference/elements/#elements.StaticSelectMenu","title":"StaticSelectMenu","text":"

A simple select menu interactive UI element, with a static list of options passed in when defining the element.

See: https://api.slack.com/reference/block-kit/block-elements#static_select.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required options List[Option]

a list of Option objects that will form the content of the menu (max 100).

None option_groups List[OptionGroup]

a list of OptionGroups (max 100). Only one of options or option_groups can be provided.

None initial_option Optional[Union[Option, OptionGroup]]

an Option object that will be initially selected when first presented to the user.

None confirm Optional[ConfirmationDialogue]

a ConfirmationDialogue object that will be presented when an option in the overflow menu is selected.

None focus_on_load bool

whether or not the input will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the input when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class StaticSelectMenu(Element):\n    \"\"\"\n    A simple select menu interactive UI element, with a static list of options passed in when\n        defining the element.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#static_select>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        options: a list of\n            [`Option`](/slackblocks/latest/reference/objects/#objects.Option) objects that will form\n            the content of the menu (max 100).\n        option_groups: a list of\n            [`OptionGroups`](/slackblocks/latest/reference/objects/#objects.OptionGroup)\n            (max 100). Only one of `options` or `option_groups` can be\n            provided.\n        initial_option: an\n            [`Option`](/slackblocks/latest/reference/objects/#objects.Option) object that will be\n            initially selected when first presented to the user.\n        confirm: a `ConfirmationDialogue` object that will be presented when an\n            option in the overflow menu is selected.\n        focus_on_load: whether or not the input will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the input when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        options: List[Option] = None,\n        option_groups: List[OptionGroup] = None,\n        initial_option: Optional[Union[Option, OptionGroup]] = None,\n        confirm: Optional[ConfirmationDialogue] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.STATIC_SELECT_MENU)\n        self.action_id = validate_action_id(action_id)\n        if options and option_groups:\n            raise InvalidUsageError(\n                \"Cannot set both `options` and `option_groups` parameters.\"\n            )\n        self.options = coerce_to_list(\n            options, class_=Option, allow_none=True, max_size=100\n        )\n        self.option_groups = coerce_to_list(\n            option_groups, class_=OptionGroup, allow_none=True, max_size=100\n        )\n        if options and initial_option and not isinstance(initial_option, Option):\n            raise InvalidUsageError(\n                \"If using `options` then `initial_option` must also be of type `Option`, \"\n                f\"not `{type(initial_option)}`.\"\n            )\n        if (\n            option_groups\n            and initial_option\n            and not isinstance(initial_option, OptionGroup)\n        ):\n            raise InvalidUsageError(\n                \"If using `option_groups` then `initial_option` must also be of type \"\n                f\"`OptionGroup`, not `{type(initial_option)}`.\"\n            )\n\n        # Check that Option Text is all TextType.PLAINTEXT\n        if self.options:\n            options_to_validate = self.options\n        if self.option_groups:\n            options_to_validate = sum(\n                [option_group.options for option_group in option_groups], []\n            )\n        for option in options_to_validate:\n            if option.text.text_type == TextType.MARKDOWN:\n                raise InvalidUsageError(\n                    \"Text in Options for StaticSelectMenu can only be of TextType.PLAINTEXT\"\n                )\n\n        self.initial_option = initial_option\n        self.confirm = confirm\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, max_length=150, force_plaintext=True, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        static_select_menu = self._attributes()\n        static_select_menu[\"action_id\"] = self.action_id\n        if self.options:\n            static_select_menu[\"options\"] = [\n                option._resolve() for option in self.options\n            ]\n        if self.option_groups:\n            static_select_menu[\"option_groups\"] = [\n                option_group._resolve() for option_group in self.option_groups\n            ]\n        if self.initial_option:\n            static_select_menu[\"initial_option\"] = self.initial_option._resolve()\n        if self.confirm:\n            static_select_menu[\"confirm\"] = self.confirm._resolve()\n        if self.focus_on_load:\n            static_select_menu[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            static_select_menu[\"placeholder\"] = self.placeholder._resolve()\n        return static_select_menu\n
"},{"location":"reference/elements/#elements.TimePicker","title":"TimePicker","text":"

An interactive UI element that allows users to select a time of day.

See: https://api.slack.com/reference/block-kit/block-elements#timepicker.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_time Optional[str] None confirm Optional[ConfirmationDialogue]

a ConfirmationDialogue object that will be presented when the input field is used.

None focus_on_load bool

whether or not the menu will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the menu when it's initially rendered.

None timezone Optional[str]

a string in the IANA format, e.g. \"America/Chicago\".

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class TimePicker(Element):\n    \"\"\"\n    An interactive UI element that allows users to select a time of day.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#timepicker>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_time:\n        confirm: a `ConfirmationDialogue` object that will be presented when\n            the input field is used.\n        focus_on_load: whether or not the menu will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the menu when it's initially rendered.\n        timezone: a string in the IANA format, e.g. \"America/Chicago\".\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_time: Optional[str] = None,\n        confirm: Optional[ConfirmationDialogue] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n        timezone: Optional[str] = None,\n    ):\n        super().__init__(type_=ElementType.TIME_PICKER)\n        self.action_id = validate_action_id(action_id)\n        self.initial_time = initial_time\n        self.confirm = confirm\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder,\n            max_length=150,\n            force_plaintext=True,\n            allow_none=True,\n        )\n        self.timezone = timezone\n\n    def _resolve(self) -> Dict[str, Any]:\n        time_picker = self._attributes()\n        time_picker[\"action_id\"] = self.action_id\n        if self.initial_time:\n            time_picker[\"initial_time\"] = self.initial_time\n        if self.confirm:\n            time_picker[\"confirm\"] = self.confirm\n        if self.focus_on_load:\n            time_picker[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            time_picker[\"placeholder\"] = self.placeholder._resolve()\n        if self.timezone is not None:\n            time_picker[\"timezone\"] = self.timezone\n        return time_picker\n
"},{"location":"reference/elements/#elements.URLInput","title":"URLInput","text":"

An interactive UI element for collecting URL input from users.

See: https://api.slack.com/reference/block-kit/block-elements#url.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_value Optional[str]

the text to populate the input field with when it is first rendered.

None dispatch_action_config Optional[DispatchActionConfiguration]

a DispatchActionConfiguration object that determines when during text input the element returns a block_actions payload.

None focus_on_load bool

whether or not the menu will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the input when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class URLInput(Element):\n    \"\"\"\n    An interactive UI element for collecting URL input from users.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#url>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_value: the text to populate the input field with when it\n            is first rendered.\n        dispatch_action_config: a `DispatchActionConfiguration` object that\n            determines when during text input the element returns a\n            `block_actions` payload.\n        focus_on_load: whether or not the menu will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the input when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_value: Optional[str] = None,\n        dispatch_action_config: Optional[DispatchActionConfiguration] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.URL_INPUT)\n        self.action_id = validate_action_id(action_id)\n        self.initial_value = initial_value\n        self.dispatch_action_config = dispatch_action_config\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder,\n            force_plaintext=True,\n            max_length=150,\n            allow_none=True,\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        url_input = self._attributes()\n        url_input[\"action_id\"] = self.action_id\n        if self.initial_value is not None:\n            url_input[\"initial_value\"] = self.initial_value\n        if self.dispatch_action_config:\n            url_input[\"dispatch_action_config\"] = self.dispatch_action_config._resolve()\n        if self.focus_on_load:\n            url_input[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            url_input[\"placeholder\"] = self.placeholder\n        return url_input\n
"},{"location":"reference/elements/#elements.UserMultiSelectMenu","title":"UserMultiSelectMenu","text":"

This interactive UI element allows users to select multiple users visible to the current user in the active workspace.

See: https://api.slack.com/reference/block-kit/block-elements#users_multi_select.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_users Optional[List[str]]

a list of string user IDs to be intially selected when the element is first rendered.

None confirm ConfirmationDialogue

a ConfirmationDialogue object that will be presented when the menu is used.

None max_selected_items Optional[int]

the highest number of items from the list that can be selected at one time.

None focus_on_load bool

whether or not the menu will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the menu when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class UserMultiSelectMenu(Element):\n    \"\"\"\n    This interactive UI element allows users to select multiple users visible\n        to the current user in the active workspace.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#users_multi_select>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_users: a list of string user IDs to be intially selected\n            when the element is first rendered.\n        confirm: a `ConfirmationDialogue` object that will be presented when\n            the menu is used.\n        max_selected_items: the highest number of items from the list that\n            can be selected at one time.\n        focus_on_load: whether or not the menu will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the menu when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_users: Optional[List[str]] = None,\n        confirm: ConfirmationDialogue = None,\n        max_selected_items: Optional[int] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.MULTI_SELECT_USERS)\n        self.action_id = validate_action_id(action_id)\n        self.initial_users = coerce_to_list(initial_users, str, allow_none=True)\n        self.confirm = confirm\n        self.max_selected_items = max_selected_items\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, force_plaintext=True, max_length=150, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        user_multi_select = self._attributes()\n        user_multi_select[\"action_id\"] = self.action_id\n        if self.initial_users:\n            user_multi_select[\"initial_users\"] = self.initial_users\n        if self.confirm:\n            user_multi_select[\"confirm\"] = self.confirm._resolve()\n        if self.max_selected_items:\n            user_multi_select[\"max_selected_items\"] = self.max_selected_items\n        if self.focus_on_load:\n            user_multi_select[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            user_multi_select[\"placeholder\"] = self.placeholder._resolve()\n        return user_multi_select\n
"},{"location":"reference/elements/#elements.UserSelectMenu","title":"UserSelectMenu","text":"

A select menu interactive UI element, sourced automatically with Slack users from the current workspace visible to the current user.

See: https://api.slack.com/reference/block-kit/block-elements#users_select.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_user Optional[str]

the single (string) user ID that will be initially selected when first presented to the user.

None confirm Optional[ConfirmationDialogue]

a ConfirmationDialogue object that will be presented when an option in the overflow menu is selected.

None focus_on_load bool

whether or not the input will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the input when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class UserSelectMenu(Element):\n    \"\"\"\n    A select menu interactive UI element, sourced automatically with Slack users from the\n        current workspace visible to the current user.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#users_select>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_user: the single (string) user ID that will be initially selected\n            when first presented to the user.\n        confirm: a `ConfirmationDialogue` object that will be presented when an\n            option in the overflow menu is selected.\n        focus_on_load: whether or not the input will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the input when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_user: Optional[str] = None,\n        confirm: Optional[ConfirmationDialogue] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.USERS_SELECT_MENU)\n        self.action_id = validate_action_id(action_id)\n        self.initial_user = initial_user\n        self.confirm = confirm\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, max_length=150, force_plaintext=True, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        user_select_menu = self._attributes()\n        user_select_menu[\"action_id\"] = self.action_id\n        if self.initial_user:\n            user_select_menu[\"initial_user\"] = self.initial_user\n        if self.confirm:\n            user_select_menu[\"confirm\"] = self.confirm._resolve()\n        if self.focus_on_load:\n            user_select_menu[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            user_select_menu[\"placeholder\"] = self.placeholder._resolve()\n        return user_select_menu\n
"},{"location":"reference/elements/#elements.WorkflowButton","title":"WorkflowButton","text":"

An interactive component that allows users to run a link trigger with customizable inputs.

See: https://api.slack.com/reference/block-kit/block-elements#workflow_button.

Parameters:

Name Type Description Default text TextLike

the text content that will appear in the button.

required workflow Optional[Workflow]

a Workflow object that contains details about the workflow that will run when the button is clicked.

None style Optional[ButtonStyleLike]

one of Default, Primary, or Danger, determines the visual style of the button. Consider using the ButtonStyle object for this.

DEFAULT accessibility_label Optional[str]

a string label for longer descriptive text about a button element. Used by screen readers (max 75 chars).

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class WorkflowButton(Element):\n    \"\"\"\n    An interactive component that allows users to run a link trigger with\n        customizable inputs.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#workflow_button>.\n\n    Args:\n        text: the text content that will appear in the button.\n        workflow: a [`Workflow`](/slackblocks/latest/reference/objects/#objects.Workflow) object\n            that contains details about the workflow that will run when the\n            button is clicked.\n        style: one of `Default`, `Primary`, or `Danger`, determines the\n            visual style of the button. Consider using the `ButtonStyle`\n            object for this.\n        accessibility_label: a string label for longer descriptive text about\n            a button element. Used by screen readers (max 75 chars).\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        text: TextLike,\n        workflow: Optional[Workflow] = None,\n        style: Optional[ButtonStyleLike] = ButtonStyle.DEFAULT,\n        accessibility_label: Optional[str] = None,\n    ):\n        super().__init__(type_=ElementType.WORKFLOW_BUTTON)\n        self.text = Text.to_text(text, force_plaintext=True, max_length=75)\n        self.workflow = workflow\n        self.style = ButtonStyle.to_button_style(style).value\n        self.accessibility_label = accessibility_label\n\n    def _resolve(self) -> Dict[str, Any]:\n        workflow_button = self._attributes()\n        workflow_button[\"text\"] = self.text._resolve()\n        if self.workflow:\n            workflow_button[\"workflow\"] = self.workflow._resolve()\n        if self.style is not None:\n            workflow_button[\"style\"] = self.style\n        if self.accessibility_label:\n            workflow_button[\"accessibility_label\"] = self.accessibility_label\n        return workflow_button\n
"},{"location":"reference/messages/","title":"Messages","text":"

Messages are the core unit of Slack messaging functionality. They can be built out using blocks, elements, objects, and rich text features.

See: https://api.slack.com/messaging

"},{"location":"reference/messages/#messages.Message","title":"Message","text":"

A Slack message object that can be converted to a JSON string for use with the Slack message API.

Parameters:

Name Type Description Default channel str

the Slack channel to send the message to, e.g. \"#general\".

required text Optional[str]

markdown text to send in the message. If blocks are provided then this is a fallback to display in notifications.

'' blocks Optional[Union[List[Block], Block]]

a list of Blocks to form the contents of the message instead of the contents of text.

None attachments Optional[List[Attachment]]

a list of Attachments that form the secondary contents of the message (deprecated).

None thread_ts Optional[str]

the timestamp ID of another unthreaded message that will become the parent message of this message (now a reply in a thread).

None mrkdwn bool

if True the contents of text will be rendered as markdown rather than plain text.

True unfurl_links Optional[bool]

if True, links in the message will be automatically unfurled.

None unfurl_media Optional[bool]

if True, media from links (e.g. images) will automatically unfurl.

None

Throws: InvalidUsageException: in the event that the items passed to blocks are not valid Blocks.

Source code in slackblocks/messages.py
class Message(BaseMessage):\n    \"\"\"\n    A Slack message object that can be converted to a JSON string for use with\n    the Slack message API.\n\n    Args:\n        channel: the Slack channel to send the message to, e.g. \"#general\".\n        text: markdown text to send in the message. If `blocks` are provided\n            then this is a fallback to display in notifications.\n        blocks: a list of [`Blocks`](/slackblocks/latest/reference/blocks) to form the contents\n            of the message instead of the contents of `text`.\n        attachments: a list of\n            [`Attachments`](/slackblocks/latest/reference/attachments/#attachments.Attachment)\n            that form the secondary contents of the message (deprecated).\n        thread_ts: the timestamp ID of another unthreaded message that will\n            become the parent message of this message (now a reply in a thread).\n        mrkdwn: if `True` the contents of `text` will be rendered as markdown\n            rather than plain text.\n        unfurl_links: if `True`, links in the message will be automatically\n            unfurled.\n        unfurl_media: if `True`, media from links (e.g. images) will\n            automatically unfurl.\n    Throws:\n        InvalidUsageException: in the event that the items passed to `blocks`\n            are not valid [`Blocks`](/slackblocks/latest/reference/blocks).\n    \"\"\"\n\n    def __init__(\n        self,\n        channel: str,\n        text: Optional[str] = \"\",\n        blocks: Optional[Union[List[Block], Block]] = None,\n        attachments: Optional[List[Attachment]] = None,\n        thread_ts: Optional[str] = None,\n        mrkdwn: bool = True,\n        unfurl_links: Optional[bool] = None,\n        unfurl_media: Optional[bool] = None,\n    ) -> \"Message\":\n        super().__init__(channel, text, blocks, attachments, thread_ts, mrkdwn)\n        self.unfurl_links = unfurl_links\n        self.unfurl_media = unfurl_media\n\n    def _resolve(self) -> Dict[str, Any]:\n        result = {**super()._resolve()}\n        if self.unfurl_links is not None:\n            result[\"unfurl_links\"] = self.unfurl_links\n        if self.unfurl_media is not None:\n            result[\"unfurl_media\"] = self.unfurl_media\n        return result\n
"},{"location":"reference/messages/#messages.ResponseType","title":"ResponseType","text":"

Types of messages that can be sent via WebhookMessage.

Source code in slackblocks/messages.py
class ResponseType(Enum):\n    \"\"\"\n    Types of messages that can be sent via `WebhookMessage`.\n    \"\"\"\n\n    EPHEMERAL = \"ephemeral\"\n    IN_CHANNEL = \"in_channel\"\n\n    @staticmethod\n    def get_value(value: Union[\"ResponseType\", str]) -> str:\n        if isinstance(value, ResponseType):\n            return value.value\n        if value not in [response_type.value for response_type in ResponseType]:\n            raise InvalidUsageError(\n                \"ResponseType must be either `ephemeral` or `in_channel`\"\n            )\n        return value\n
"},{"location":"reference/messages/#messages.WebhookMessage","title":"WebhookMessage","text":"

Messages sent via the Slack WebhookClient takes different arguments than those sent via the regular WebClient.

See: https://github.com/slackapi/python-slack-sdk/blob/7e71b73/slack_sdk/webhook/client.py#L28

Parameters:

Name Type Description Default text Optional[str]

markdown text to send in the message. If blocks are provided then this is a fallback to display in notifications.

None attachments Optional[List[Attachment]]

a list of Attachments that form the secondary contents of the message (deprecated).

None blocks Optional[Union[List[Block], Block]]

a list of Blocks to form the contents of the message instead of the contents of text.

None response_type Union[ResponseType, str]

one of ResponseType.EPHEMERAL or ResponseType.IN_CHANNEL. Ephemeral messages are shown only to the requesting user whereas \"in-channel\" messages are shown to all channel participants.

None replace_orginal

when True, the message triggering this response will be replaced by this messaage. Mutually exclusive with delete_original.

required delete_original Optional[bool]

when True, the original message triggering this response will be deleted, and any content of this message will be posted as a new message. Mutually exclusive with replace_orginal.

None unfurl_links Optional[bool]

if True, links in the message will be automatically unfurled.

None unfurl_media Optional[bool]

if True, media from links (e.g. images) will automatically unfurl.

None metadata Optional[Dict[str, Any]]

additional metadata to attach to the message.

None headres

HTTP request headers to include with the message.

required Throws

InvalidUsageError: when any of the passed fields fail validation.

Source code in slackblocks/messages.py
class WebhookMessage:\n    \"\"\"\n    Messages sent via the Slack `WebhookClient` takes different arguments than\n        those sent via the regular `WebClient`.\n\n    See: <https://github.com/slackapi/python-slack-sdk/blob/7e71b73/slack_sdk/webhook/client.py#L28>\n\n    Args:\n        text: markdown text to send in the message. If `blocks` are provided\n            then this is a fallback to display in notifications.\n        attachments: a list of\n            [`Attachments`](/slackblocks/latest/reference/attachments/#attachments.Attachment)\n            that form the secondary contents of the message (deprecated).\n        blocks: a list of [`Blocks`](/slackblocks/latest/reference/blocks) to form the contents\n            of the message instead of the contents of `text`.\n        response_type: one of `ResponseType.EPHEMERAL` or `ResponseType.IN_CHANNEL`.\n            Ephemeral messages are shown only to the requesting user whereas\n            \"in-channel\" messages are shown to all channel participants.\n        replace_orginal: when `True`, the message triggering this response will be\n            replaced by this messaage. Mutually exclusive with `delete_original`.\n        delete_original: when `True`, the original message triggering this response\n            will be deleted, and any content of this message will be posted as a\n            new message. Mutually exclusive with `replace_orginal`.\n        unfurl_links: if `True`, links in the message will be automatically\n            unfurled.\n        unfurl_media: if `True`, media from links (e.g. images) will\n            automatically unfurl.\n        metadata: additional metadata to attach to the message.\n        headres: HTTP request headers to include with the message.\n\n    Throws:\n        InvalidUsageError: when any of the passed fields fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        text: Optional[str] = None,\n        attachments: Optional[List[Attachment]] = None,\n        blocks: Optional[Union[List[Block], Block]] = None,\n        response_type: Union[ResponseType, str] = None,\n        replace_original: Optional[bool] = None,\n        delete_original: Optional[bool] = None,\n        unfurl_links: Optional[bool] = None,\n        unfurl_media: Optional[bool] = None,\n        metadata: Optional[Dict[str, Any]] = None,\n        headers: Optional[Dict[str, str]] = None,\n    ) -> \"WebhookMessage\":\n        self.text = text\n        self.attachments = coerce_to_list(attachments, Attachment, allow_none=True)\n        self.blocks = coerce_to_list(blocks, Block, allow_none=True)\n        self.response_type = ResponseType.get_value(response_type)\n        self.replace_original = replace_original\n        self.delete_original = delete_original\n        self.unfurl_links = unfurl_links\n        self.unfurl_media = unfurl_media\n        self.metadata = metadata\n        self.headers = headers\n\n    def _resolve(self) -> None:\n        webhook_message = {}\n        if self.text is not None:\n            webhook_message[\"text\"] = self.text\n        if self.attachments is not None:\n            webhook_message[\"attachments\"] = [\n                attachment._resolve() for attachment in self.attachments\n            ]\n        if self.blocks is not None:\n            webhook_message[\"blocks\"] = [block._resolve() for block in self.blocks]\n        if self.response_type is not None:\n            webhook_message[\"response_type\"] = self.response_type\n        if self.replace_original is not None:\n            webhook_message[\"replace_original\"] = self.replace_original\n        if self.delete_original is not None:\n            webhook_message[\"delete_original\"] = self.delete_original\n        if self.unfurl_links is not None:\n            webhook_message[\"unfurl_links\"] = self.unfurl_links\n        if self.unfurl_media is not None:\n            webhook_message[\"unfurl_media\"] = self.unfurl_media\n        if self.metadata is not None:\n            webhook_message[\"metadata\"] = self.metadata\n        if self.headers is not None:\n            webhook_message[\"headers\"] = self.headers\n        return webhook_message\n\n    def to_dict(self) -> Dict[str, Any]:\n        return self._resolve()\n\n    def json(self) -> str:\n        return dumps(self._resolve(), indent=4)\n\n    def __repr__(self) -> str:\n        return self.json()\n\n    def __getitem__(self, item):\n        return self._resolve()[item]\n\n    def keys(self) -> Dict[str, Any]:\n        return self._resolve().keys()\n
"},{"location":"reference/modals/","title":"Modals","text":"

Modals are pop-up windows, primarily used for collecting data from users.

This module is kept only for backwards compatibility, modals have been largely subsumed as a subtype of view.

See: https://api.slack.com/surfaces/modals

options: show_bases: false

"},{"location":"reference/modals/#modals.Modal","title":"Modal","text":"

Bases: ModalView

Kept for backwards compatibility - see ModalView

Source code in slackblocks/modals.py
class Modal(ModalView):\n    \"\"\"\n    Kept for backwards compatibility - see [`ModalView`](/slackblocks/latest/reference/views/#views.ModalView)\n    \"\"\"\n\n    def __repr__(self) -> str:\n        return dumps(self._resolve(), indent=4)\n\n    def to_dict(self) -> Dict[str, Any]:\n        return self._resolve()\n\n    def json(self) -> str:\n        return dumps(self._resolve(), indent=4)\n
"},{"location":"reference/objects/","title":"Objects","text":"

Composition objects are the lowest-level primitives used inside of Block objects.

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

"},{"location":"reference/objects/#objects.Confirm","title":"Confirm","text":"

Alias for ConfirmationDialogue to retain backwards compatibility.

See: ConfirmationDialogue.

Source code in slackblocks/objects.py
class Confirm(ConfirmationDialogue):\n    \"\"\"\n    Alias for `ConfirmationDialogue` to retain backwards compatibility.\n\n    See: [`ConfirmationDialogue`](/slackblocks/latest/reference/objects/#objects.ConfirmationDialogue).\n    \"\"\"\n\n    def __init__(self, *args, **kwargs):\n        super(*args, **kwargs)\n
"},{"location":"reference/objects/#objects.ConfirmationDialogue","title":"ConfirmationDialogue","text":"

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.

Parameters:

Name Type Description Default title TextLike

the text heading presented at the top of the dialogue box (max 100 chars).

required text TextLike

the text explaining the decision being made by the user through the dialogue box (max 300 chars).

required confirm TextLike

the text inside the confirmation button of the dialogue box (max 30 chars).

required deny TextLike

the text inside the deny button of the dialogue box (max 30 chars).

required Throws

InvalidUsageError: if any of the arguments fail to pass validation checks.

Source code in slackblocks/objects.py
class ConfirmationDialogue(CompositionObject):\n    \"\"\"\n    An object that defines a dialog that provides a confirmation step\n    to any interactive element. This dialog will ask the user to confirm\n    their action by offering confirm and deny buttons.\n\n    Args:\n        title: the text heading presented at the top of the dialogue box (max 100 chars).\n        text: the text explaining the decision being made by the user through\n            the dialogue box (max 300 chars).\n        confirm: the text inside the confirmation button of the dialogue box (max 30 chars).\n        deny: the text inside the deny button of the dialogue box (max 30 chars).\n\n    Throws:\n        InvalidUsageError: if any of the arguments fail to pass validation checks.\n    \"\"\"\n\n    def __init__(\n        self,\n        title: TextLike,\n        text: TextLike,\n        confirm: TextLike,\n        deny: TextLike,\n    ):\n        super().__init__(type_=CompositionObjectType.CONFIRM)\n        self.title = Text.to_text(title, max_length=100, force_plaintext=True)\n        self.text = Text.to_text(text, max_length=300)\n        self.confirm = Text.to_text(confirm, max_length=30, force_plaintext=True)\n        self.deny = Text.to_text(deny, max_length=30, force_plaintext=True)\n\n    def _resolve(self) -> Dict[str, Any]:\n        return {\n            \"title\": self.title._resolve(),\n            \"text\": self.text._resolve(),\n            \"confirm\": self.confirm._resolve(),\n            \"deny\": self.deny._resolve(),\n        }\n
"},{"location":"reference/objects/#objects.ConversationFilter","title":"ConversationFilter","text":"

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.

Parameters:

Name Type Description Default include Optional[Union[str, List[str]]]

Which types of conversations to include in the list. One of more of im, mpim, private, public.

None exclude_external_shared_channels Optional[bool]

whether to remove shared public channels from the list. See https://api.slack.com/enterprise/shared-channels.

None exclude_bot_users Optional[bool]

whether to remove bot users from the list of conversations.

None Throws

InvalidUsageException: in the event that the user provides none of include, exclude_external_shared_channels, or exclude_bot_users arguments.

Source code in slackblocks/objects.py
class ConversationFilter(CompositionObject):\n    \"\"\"\n    Provides a way to filter the list of options in a conversations select menu or\n    conversations multi-select menu.\n\n    See: <https://api.slack.com/reference/block-kit/composition-objects#filter_conversations>.\n\n    At least one of the available arguments _must_ be provided.\n\n    Args:\n        include: Which types of conversations to include in the list.\n            One of more of `im`, `mpim`, `private`, `public`.\n        exclude_external_shared_channels: whether to remove shared public channels\n            from the list. See <https://api.slack.com/enterprise/shared-channels>.\n        exclude_bot_users: whether to remove bot users from the list of conversations.\n\n    Throws:\n        InvalidUsageException: in the event that the user provides none of `include`,\n            `exclude_external_shared_channels`, or `exclude_bot_users` arguments.\n    \"\"\"\n\n    def __init__(\n        self,\n        include: Optional[Union[str, List[str]]] = None,\n        exclude_external_shared_channels: Optional[bool] = None,\n        exclude_bot_users: Optional[bool] = None,\n    ) -> \"ConversationFilter\":\n        super().__init__(type_=CompositionObjectType.FILTER)\n        if not (\n            include\n            or exclude_external_shared_channels is not None\n            or exclude_bot_users is not None\n        ):\n            raise InvalidUsageError(\n                \"One of `include`, `exclude_external_shared_channels`, or \"\n                \"`exclude_bot_users` is required.\"\n            )\n        self.include = coerce_to_list(include, str, allow_none=True)\n        self.exclude_external_shared_channels = exclude_external_shared_channels\n        self.exclude_bot_users = exclude_bot_users\n\n    def _resolve(self) -> Dict[str, Any]:\n        filter = {}  # Does not include type in JSON\n        if self.include:\n            filter[\"include\"] = self.include\n        if self.exclude_external_shared_channels is not None:\n            filter[\"exclude_external_shared_channels\"] = (\n                self.exclude_external_shared_channels\n            )\n        if self.exclude_bot_users is not None:\n            filter[\"exclude_bot_users\"] = self.exclude_bot_users\n        return filter\n
"},{"location":"reference/objects/#objects.DispatchActionConfiguration","title":"DispatchActionConfiguration","text":"

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

Parameters:

Name Type Description Default trigger_actions_on Union[str, List[str]]

a list of strings representing interaction types that should return a block_actions payload. One or both of on_enter_pressed, on_character_entered.

None Throws

InvalidUsageError: if an invalid value is provided amongst the options for trigger_actions_on.

Source code in slackblocks/objects.py
class DispatchActionConfiguration(CompositionObject):\n    \"\"\"\n    Determines when a plain-text input element will return a `block_action`s interaction payload.\n\n    Args:\n        trigger_actions_on: a list of strings representing interaction types that should return\n            a `block_actions` payload. One or both of `on_enter_pressed`, `on_character_entered`.\n\n    Throws:\n        InvalidUsageError: if an invalid value is provided amongst the options for\n            `trigger_actions_on`.\n    \"\"\"\n\n    def __init__(self, trigger_actions_on: Union[str, List[str]] = None):\n        self.trigger_actions_on = list(\n            set(coerce_to_list(trigger_actions_on, str, min_size=1, max_size=2))\n        )\n        for trigger in self.trigger_actions_on:\n            if trigger not in ALLOWABLE_TRIGGERS:\n                raise InvalidUsageError(\n                    f\"Trigger {trigger} not in allowable values ({ALLOWABLE_TRIGGERS})\"\n                )\n\n    def _resolve(self) -> Dict[str, Any]:\n        dispatch_action_config = {}  # Does not include type in JSON\n        dispatch_action_config[\"trigger_actions_on\"] = self.trigger_actions_on\n        return dispatch_action_config\n
"},{"location":"reference/objects/#objects.InputParameter","title":"InputParameter","text":"

Contains information about an input parameter.

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

Parameters:

Name Type Description Default name str

the name of the input parameter.

required value str

the value associated with the input parameter.

required Source code in slackblocks/objects.py
class InputParameter(CompositionObject):\n    \"\"\"\n    Contains information about an input parameter.\n\n    See <https://api.slack.com/automation/workflows#defining-input-parameters>.\n\n    Args:\n        name: the name of the input parameter.\n        value: the value associated with the input parameter.\n    \"\"\"\n\n    def __init__(self, name: str, value: str):\n        super().__init__(type_=CompositionObjectType.INPUT_PARAMETER)\n        self.name = name\n        self.value = value\n\n    def _resolve(self) -> Dict[str, Any]:\n        input_parameter = {}  # Does not include type in JSON\n        input_parameter[\"name\"] = self.name\n        input_parameter[\"value\"] = self.value\n        return input_parameter\n
"},{"location":"reference/objects/#objects.Option","title":"Option","text":"

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.

Parameters:

Name Type Description Default text TextLike

the text identifying the option (that the user will see).

required value str

the underlying value of that option (not seen by the user).

required description Optional[TextLike]

a more detailed explanation of what the option means (user-facing).

None url Optional[str]

a URL to load in the user's browser when the option is clicked. Only available in OverflowMenus.

None Throws

InvalidUsageError: when any of the provided arguments fail validation.

Source code in slackblocks/objects.py
class Option(CompositionObject):\n    \"\"\"\n    An object that represents a single selectable item in a select menu, multi-select\n    menu, checkbox group, radio button group, or overflow menu.\n\n    See <https://api.slack.com/reference/block-kit/composition-objects#option>.\n\n    Args:\n        text: the text identifying the option (that the user will see).\n        value: the underlying value of that option (not seen by the user).\n        description: a more detailed explanation of what the option means (user-facing).\n        url: a URL to load in the user's browser when the option is clicked.\n            Only available in `OverflowMenus`.\n\n    Throws:\n        InvalidUsageError: when any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        text: TextLike,\n        value: str,\n        description: Optional[TextLike] = None,\n        url: Optional[str] = None,\n    ) -> \"Option\":\n        super().__init__(type_=CompositionObjectType.OPTION)\n        self.text = Text.to_text(text, max_length=75)\n        self.value = validate_string(value, field_name=\"value\", max_length=75)\n        self.description = Text.to_text(\n            description, max_length=75, force_plaintext=True, allow_none=True\n        )\n        if url and len(url) > 3000:\n            raise InvalidUsageError(\"Option URLs must be less than 3000 characters\")\n        self.url = url\n\n    def _resolve(self) -> Dict[str, Any]:\n        option = {}  # Does not include type in JSON\n        option[\"text\"] = self.text._resolve()\n        option[\"value\"] = self.value\n        if self.description is not None:\n            option[\"description\"] = self.description._resolve()\n        if self.url is not None:\n            option[\"url\"] = self.url\n        return option\n\n    def __eq__(self, other) -> bool:\n        return (\n            self.type == other.type\n            and self.text == other.text\n            and self.value == other.value\n            and self.description == other.description\n            and self.url == other.url\n        )\n
"},{"location":"reference/objects/#objects.OptionGroup","title":"OptionGroup","text":"

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.

Parameters:

Name Type Description Default label TextLike

a label shown above the group of options.

required options List[Option]

a list of Option objects that will form the contents of the group (max 100).

required Throws

InvalidUsageError: if no options are provided or the label is not valid.

Source code in slackblocks/objects.py
class OptionGroup(CompositionObject):\n    \"\"\"\n    Provides a way to group options in a select menu or multi-select menu.\n\n    See <https://api.slack.com/reference/block-kit/composition-objects#option_group>.\n\n    Args:\n        label: a label shown above the group of options.\n        options: a list of `Option` objects that will form the contents of the group (max 100).\n\n    Throws:\n        InvalidUsageError: if no options are provided or the label is not valid.\n    \"\"\"\n\n    def __init__(self, label: TextLike, options: List[Option]):\n        super().__init__(type_=CompositionObjectType.OPTION_GROUP)\n        self.label = Text.to_text(label, max_length=75, force_plaintext=True)\n        self.options = coerce_to_list(\n            options,\n            class_=Option,\n            min_size=1,\n            max_size=100,\n            allow_none=False,\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        option_group = {}  # Does not include type in JSON\n        option_group[\"label\"] = self.label._resolve()\n        option_group[\"options\"] = [option._resolve() for option in self.options]\n        return option_group\n
"},{"location":"reference/objects/#objects.SlackFile","title":"SlackFile","text":"

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.

Parameters:

Name Type Description Default url Optional[str]

the URL can be the url_private or the permalink of the Slack file (only one of url or id can be provided).

required id Optional[str]

the Slack ID of the file (only one of url or id can be provided).

required Throws

InvalidUsageError: if both url and id are provided

Source code in slackblocks/objects.py
class SlackFile(CompositionObject):\n    \"\"\"\n    Defines an object containing Slack file information to be used in an image\n        block or image element.\n\n    This file must be an image and you must provide either the URL or ID (not both).\n\n    See: <https://api.slack.com/reference/block-kit/composition-objects#slack_file>.\n\n    Args:\n        url: the URL can be the `url_private` or the `permalink` of the Slack file\n            (only one of `url` or `id` can be provided).\n        id: the Slack ID of the file\n            (only one of `url` or `id` can be provided).\n\n    Throws:\n        InvalidUsageError: if both `url` and `id` are provided\n    \"\"\"\n\n    def __init__(\n        self,\n        url: Optional[str],\n        id: Optional[str],\n    ) -> \"SlackFile\":\n        super().__init__(CompositionObjectType.SLACK_FILE)\n        if url and id:\n            raise InvalidUsageError(\"Cannot provide both `url` and `id`.\")\n        self.url = url\n        self.id = id\n\n    def _resolve(self) -> Dict[str, Any]:\n        file = {}  # Does not include type in JSON\n        if self.url:\n            file[\"url\"] = self.url\n        if self.id:\n            file[\"id\"] = self.id\n        return file\n
"},{"location":"reference/objects/#objects.Text","title":"Text","text":"

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

Parameters:

Name Type Description Default text str

the text to be rendered in a message (max 3000 characters).

required type_ TextType

either TextType.MARKDOWN or TextType.PLAINTEXT.

MARKDOWN emoji bool

only usable with TextType.PLAINTEXT, if True: emoji will be escaped into text format (e.g. :smile:).

False verbatim bool

only usable with TextType.MARKDOWN, if True: links, channel names, user names will not automatically be rendered as links.

False Throws

InvalidUsageException: if the provided text fails validation.

Source code in slackblocks/objects.py
class Text(CompositionObject):\n    \"\"\"\n    An object containing some text, formatted either as `plain_text` or using\n    Slack's `mrkdwn`.\n\n    Args:\n        text: the text to be rendered in a message (max 3000 characters).\n        type_: either `TextType.MARKDOWN` or `TextType.PLAINTEXT`.\n        emoji: only usable with `TextType.PLAINTEXT`, if True: emoji will be\n            escaped into text format (e.g. `:smile:`).\n        verbatim: only usable with `TextType.MARKDOWN`, if True: links, channel\n            names, user names will not automatically be rendered as links.\n\n    Throws:\n        InvalidUsageException: if the provided `text` fails validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        text: str,\n        type_: TextType = TextType.MARKDOWN,\n        emoji: bool = False,\n        verbatim: bool = False,\n    ) -> \"Text\":\n        super().__init__(type_=CompositionObjectType.TEXT)\n        self.text_type = type_\n        self.text = validate_string(\n            text, field_name=\"text\", min_length=1, max_length=3000\n        )\n        if self.text_type == TextType.MARKDOWN:\n            self.verbatim = verbatim\n            self.emoji = None\n        elif self.text_type == TextType.PLAINTEXT:\n            self.verbatim = None\n            self.emoji = emoji\n\n    def _resolve(self) -> Dict[str, Any]:\n        text = self._attributes()\n        text[\"type\"] = self.text_type.value\n        text[\"text\"] = self.text\n        if self.text_type == TextType.MARKDOWN and self.verbatim:\n            text[\"verbatim\"] = self.verbatim\n        elif self.text_type == TextType.PLAINTEXT and self.emoji:\n            text[\"emoji\"] = self.emoji\n        return text\n\n    @staticmethod\n    def to_text(\n        text: Optional[Union[str, \"Text\"]],\n        force_plaintext: bool = False,\n        max_length: Optional[int] = None,\n        allow_none: bool = False,\n    ) -> Optional[\"Text\"]:\n        \"\"\"\n        Coerces `str` or `Text` objects into `Text` objects.\n\n        Args:\n            text: the `str` or `Text` object to ensure is in `Text` format.\n            force_plaintext: if `True`, forces the `str` or `Text` object\n                into a `Text` object with the type `TextType.PLAINTEXT`.\n            max_length: `text` will be checked against this length in addition\n                to the standard `Text` limit of 3000 characters.\n            allow_none: whether to accept `None` as a valid value for `text`.\n        \"\"\"\n        original_type = text.text_type if isinstance(text, Text) else None\n        type_ = (\n            TextType.PLAINTEXT\n            if force_plaintext\n            else original_type or TextType.MARKDOWN\n        )\n        if text is None:\n            if allow_none:\n                return None\n            raise InvalidUsageError(\"This field cannot have the value None or ''\")\n        if text and max_length and len(text) > max_length:\n            raise InvalidUsageError(\n                f\"`text` length ({len(text)}) exceeds `max_length` ({max_length})\"\n            )\n        if isinstance(text, str):\n            return Text(text=text, type_=type_)\n        if isinstance(text, Text):\n\n            return Text(\n                text=text.text, type_=type_, emoji=text.emoji, verbatim=text.verbatim\n            )\n        else:\n            raise InvalidUsageError(\n                f\"Can only coerce Text object from `str` or `Text`, not `{type(text)}`\"\n            )\n\n    def __str__(self) -> str:\n        return dumps(self._resolve())\n\n    def __len__(self) -> int:\n        return len(self.text)\n\n    def __eq__(self, other) -> bool:\n        return (\n            self.text_type == other.text_type\n            and self.text == other.text\n            and self.emoji == other.emoji\n            and self.vertbatim == other.verbatim\n        )\n
"},{"location":"reference/objects/#objects.Text.to_text","title":"to_text staticmethod","text":"
to_text(\n    text,\n    force_plaintext=False,\n    max_length=None,\n    allow_none=False,\n)\n

Coerces str or Text objects into Text objects.

Parameters:

Name Type Description Default text Optional[Union[str, Text]]

the str or Text object to ensure is in Text format.

required force_plaintext bool

if True, forces the str or Text object into a Text object with the type TextType.PLAINTEXT.

False max_length Optional[int]

text will be checked against this length in addition to the standard Text limit of 3000 characters.

None allow_none bool

whether to accept None as a valid value for text.

False Source code in slackblocks/objects.py
@staticmethod\ndef to_text(\n    text: Optional[Union[str, \"Text\"]],\n    force_plaintext: bool = False,\n    max_length: Optional[int] = None,\n    allow_none: bool = False,\n) -> Optional[\"Text\"]:\n    \"\"\"\n    Coerces `str` or `Text` objects into `Text` objects.\n\n    Args:\n        text: the `str` or `Text` object to ensure is in `Text` format.\n        force_plaintext: if `True`, forces the `str` or `Text` object\n            into a `Text` object with the type `TextType.PLAINTEXT`.\n        max_length: `text` will be checked against this length in addition\n            to the standard `Text` limit of 3000 characters.\n        allow_none: whether to accept `None` as a valid value for `text`.\n    \"\"\"\n    original_type = text.text_type if isinstance(text, Text) else None\n    type_ = (\n        TextType.PLAINTEXT\n        if force_plaintext\n        else original_type or TextType.MARKDOWN\n    )\n    if text is None:\n        if allow_none:\n            return None\n        raise InvalidUsageError(\"This field cannot have the value None or ''\")\n    if text and max_length and len(text) > max_length:\n        raise InvalidUsageError(\n            f\"`text` length ({len(text)}) exceeds `max_length` ({max_length})\"\n        )\n    if isinstance(text, str):\n        return Text(text=text, type_=type_)\n    if isinstance(text, Text):\n\n        return Text(\n            text=text.text, type_=type_, emoji=text.emoji, verbatim=text.verbatim\n        )\n    else:\n        raise InvalidUsageError(\n            f\"Can only coerce Text object from `str` or `Text`, not `{type(text)}`\"\n        )\n
"},{"location":"reference/objects/#objects.TextType","title":"TextType","text":"

Allowable types for Slack Text objects.

tradional 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.

Source code in slackblocks/objects.py
class TextType(Enum):\n    \"\"\"\n    Allowable types for Slack Text objects.\n\n    MARKDOWN: tradional markdown formatting, see\n        <https://api.slack.com/reference/surfaces/formatting#basic-formatting>\n    PLAINTEXT: simple Unicode text with no formatting (e.g. bold) features.\n\n    N.B: some usages of Text objects only allow the `PLAINTEXT` variety.\n    \"\"\"\n\n    MARKDOWN = \"mrkdwn\"\n    PLAINTEXT = \"plain_text\"\n
"},{"location":"reference/objects/#objects.Trigger","title":"Trigger","text":"

Contains information about a trigger.

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

Parameters:

Name Type Description Default url str

a link trigger URL, see https://api.slack.com/automation/triggers/link

required customizable_input_parameters Optional[Union[InputParameter, List[InputParameter]]]

a list of InputParameter objects which map to those parameters defined on the Workflow in which they are provided.

required Throws

InvalidUsageError: when any of the items in customizable_input_parameters is not a valid InputParameter.

Source code in slackblocks/objects.py
class Trigger(CompositionObject):\n    \"\"\"\n    Contains information about a trigger.\n\n    See: <https://api.slack.com/automation/triggers>.\n\n    Args:\n        url: a link trigger URL, see\n            <https://api.slack.com/automation/triggers/link>\n        customizable_input_parameters: a list of `InputParameter` objects\n            which map to those parameters defined on the Workflow in\n            which they are provided.\n\n    Throws:\n        InvalidUsageError: when any of the items in\n            `customizable_input_parameters` is not a valid `InputParameter`.\n    \"\"\"\n\n    def __init__(\n        self,\n        url: str,\n        customizable_input_parameters: Optional[\n            Union[InputParameter, List[InputParameter]]\n        ],\n    ) -> \"Trigger\":\n        super().__init__(type_=CompositionObjectType.TRIGGER)\n        self.url = url\n        self.customizable_input_parameters = coerce_to_list(\n            customizable_input_parameters, InputParameter, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        trigger = {}  # Does not include type in JSON\n        trigger[\"url\"] = self.url\n        if self.customizable_input_parameters:\n            trigger[\"customizable_input_parameters\"] = [\n                parameter._resolve() for parameter in self.customizable_input_parameters\n            ]\n        return trigger\n
"},{"location":"reference/objects/#objects.Workflow","title":"Workflow","text":"

Contains information about a workflow.

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

Parameters:

Name Type Description Default trigger Trigger

a Trigger object that will initiate the workflow.

required Source code in slackblocks/objects.py
class Workflow(CompositionObject):\n    \"\"\"\n    Contains information about a workflow.\n\n    See <https://api.slack.com/automation/workflows>.\n\n    Args:\n        trigger: a `Trigger` object that will initiate the workflow.\n    \"\"\"\n\n    def __init__(self, trigger: Trigger) -> \"Workflow\":\n        super().__init__(type_=CompositionObjectType.WORKFLOW)\n        self.trigger = trigger\n\n    def _resolve(self) -> Dict[str, Any]:\n        workflow = {}  # Does not include type in JSON\n        workflow[\"trigger\"] = self.trigger._resolve()\n        return workflow\n
"},{"location":"reference/rich_text/","title":"Rich Text","text":"

Rich Text elements can be used to enhance text-based messages with code, list, quotations and formatted text (including options not available in traditional markdown like strikethrough).

These formatting elements can only be used within a RichTextBlock.

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

"},{"location":"reference/rich_text/#rich-text-elements-primitives","title":"Rich Text Elements (Primitives)","text":"

Rich text elements are the primitive elements used to populate the rich text object \"containers\", which are then fed into the RichTextBlock.

"},{"location":"reference/rich_text/#rich_text.elements.RichText","title":"RichText","text":"

The core unit of the rich text API. Allows for the formatting of text with visual styles like bolding, italics and strikethroughs. Combined with higher-level containers like RichTextSection, RichText can be used to create complicated and deeply nested rich text within Slack messages.

Parameters:

Name Type Description Default text str

the text content to render.

required bold Optional[bool]

whether to render the given text in bold font.

None italic Optional[bool]

whether to render the given text in italics.

None strike Optional[bool]

whether to render the given text with a \"strikethrough\".

None code Optional[bool]

whether to render the given text as an inline code snippet (monospaced).

None Source code in slackblocks/rich_text/elements.py
class RichText(RichTextElement):\n    \"\"\"\n    The core unit of the rich text API. Allows for the formatting of text\n        with visual styles like bolding, italics and strikethroughs.\n        Combined with higher-level containers like `RichTextSection`,\n        `RichText` can be used to create complicated and deeply nested\n        rich text within Slack messages.\n\n    Args:\n        text: the text content to render.\n        bold: whether to render the given text in bold font.\n        italic: whether to render the given text in italics.\n        strike: whether to render the given text with a \"strikethrough\".\n        code: whether to render the given text as an inline code snippet\n            (monospaced).\n    \"\"\"\n\n    def __init__(\n        self,\n        text: str,\n        bold: Optional[bool] = None,\n        italic: Optional[bool] = None,\n        strike: Optional[bool] = None,\n        code: Optional[bool] = None,\n    ) -> None:\n        super().__init__(type_=RichTextElementType.TEXT)\n        self.text = text\n        self.bold = bold\n        self.italic = italic\n        self.strike = strike\n        self.code = code\n\n    def _resolve(self) -> Dict[str, Any]:\n        rich_text = super()._resolve()\n        rich_text[\"text\"] = self.text\n        style = {}\n        if self.bold is not None:\n            style[\"bold\"] = self.bold\n        if self.italic is not None:\n            style[\"italic\"] = self.italic\n        if self.strike is not None:\n            style[\"strike\"] = self.strike\n        if self.code is not None:\n            style[\"code\"] = self.code\n        if style:\n            rich_text[\"style\"] = style\n        return rich_text\n
"},{"location":"reference/rich_text/#rich_text.elements.RichTextChannel","title":"RichTextChannel","text":"

Rich text rendering of a Slack channel (e.g. #general).

See: https://api.slack.com/reference/block-kit/blocks#channel-element-type

Parameters:

Name Type Description Default channel_id str

the ID of the channel to render. You can get this from the channel settings or the URL (if using Slack in the browser).

required bold Optional[bool]

whether to render the given channel in bold font.

None italic Optional[bool]

whether to render the given channel in italics.

None strike Optional[bool]

whether to render the given channel with a \"strikethrough\".

None highlight Optional[bool]

whether to give the channel a distinct highlight when rendered.

None client_highlight Optional[bool]

???

None unlink Optional[bool]

whether to remove the link to the channel from the channel when rendered.

None Source code in slackblocks/rich_text/elements.py
class RichTextChannel(RichTextElement):\n    \"\"\"\n    Rich text rendering of a Slack channel (e.g. #general).\n\n    See: <https://api.slack.com/reference/block-kit/blocks#channel-element-type>\n\n    Args:\n        channel_id: the ID of the channel to render. You can get this from\n            the channel settings or the URL (if using Slack in the browser).\n        bold: whether to render the given channel in bold font.\n        italic: whether to render the given channel in italics.\n        strike: whether to render the given channel with a \"strikethrough\".\n        highlight: whether to give the channel a distinct highlight when rendered.\n        client_highlight: ???\n        unlink: whether to remove the link to the channel from the channel when\n            rendered.\n    \"\"\"\n\n    def __init__(\n        self,\n        channel_id: str,\n        bold: Optional[bool] = None,\n        italic: Optional[bool] = None,\n        strike: Optional[bool] = None,\n        highlight: Optional[bool] = None,\n        client_highlight: Optional[bool] = None,\n        unlink: Optional[bool] = None,\n    ) -> None:\n        super().__init__(RichTextElementType.CHANNEL)\n        self.channel_id = channel_id\n        self.bold = bold\n        self.italic = italic\n        self.strike = strike\n        self.highlight = highlight\n        self.client_highlight = client_highlight\n        self.unlink = unlink\n\n    def _resolve(self) -> Dict[str, Any]:\n        channel = super()._resolve()\n        channel[\"channel_id\"] = self.channel_id\n        style = {}\n        if self.bold is not None:\n            style[\"bold\"] = self.bold\n        if self.italic is not None:\n            style[\"italic\"] = self.italic\n        if self.strike is not None:\n            style[\"strike\"] = self.strike\n        if self.highlight is not None:\n            style[\"highlight\"] = self.highlight\n        if self.client_highlight is not None:\n            style[\"client_highlight\"] = self.client_highlight\n        if self.unlink is not None:\n            style[\"unlink\"] = self.unlink\n        if style:\n            channel[\"style\"] = style\n        return channel\n
"},{"location":"reference/rich_text/#rich_text.elements.RichTextEmoji","title":"RichTextEmoji","text":"

A rich text element for displaying an emoji.

The emoji can either be one built in to Slack or a custom workspace emoji.

See: https://api.slack.com/reference/block-kit/blocks#emoji-element-type

Parameters:

Name Type Description Default name str

the unique name of the emoji to represent e.g. \"wave\".

required Throws

InvalidUsageError: if the emoji name provided is empty.

Source code in slackblocks/rich_text/elements.py
class RichTextEmoji(RichTextElement):\n    \"\"\"\n    A rich text element for displaying an emoji.\n\n    The emoji can either be one built in to Slack or a custom workspace emoji.\n\n    See: <https://api.slack.com/reference/block-kit/blocks#emoji-element-type>\n\n    Args:\n        name: the unique name of the emoji to represent e.g. \"wave\".\n\n    Throws:\n        InvalidUsageError: if the emoji `name` provided is empty.\n    \"\"\"\n\n    def __init__(self, name: str) -> None:\n        super().__init__(RichTextElementType.EMOJI)\n        self.name = validate_string(name, field_name=\"name\", min_length=1)\n\n    def _resolve(self) -> Dict[str, Any]:\n        emoji = super()._resolve()\n        emoji[\"name\"] = self.name\n        return emoji\n
"},{"location":"reference/rich_text/#rich_text.elements.RichTextLink","title":"RichTextLink","text":"

A rich text primitive to display links in text.

See: https://api.slack.com/reference/block-kit/blocks#link-element-type

Parameters:

Name Type Description Default url str

the url which the link will point to.

required text Optional[str]

the text to render with the link. If not provided, the raw URL will be used.

None unsafe Optional[bool]

whether the link is \"safe\".

None bold Optional[bool]

whether to render the given text in bold font.

None italic Optional[bool]

whether to render the given text in italics.

None strike Optional[bool]

whether to render the given text with a \"strikethrough\".

None code Optional[bool]

whether to render the given text as an inline code snippet (monospaced).

None Source code in slackblocks/rich_text/elements.py
class RichTextLink(RichTextElement):\n    \"\"\"\n    A rich text primitive to display links in text.\n\n    See: <https://api.slack.com/reference/block-kit/blocks#link-element-type>\n\n    Args:\n        url: the url which the link will point to.\n        text: the text to render with the link. If not provided, the raw URL\n            will be used.\n        unsafe: whether the link is \"safe\".\n        bold: whether to render the given text in bold font.\n        italic: whether to render the given text in italics.\n        strike: whether to render the given text with a \"strikethrough\".\n        code: whether to render the given text as an inline code snippet\n            (monospaced).\n    \"\"\"\n\n    def __init__(\n        self,\n        url: str,\n        text: Optional[str] = None,\n        unsafe: Optional[bool] = None,\n        bold: Optional[bool] = None,\n        italic: Optional[bool] = None,\n        strike: Optional[bool] = None,\n        code: Optional[bool] = None,\n    ) -> None:\n        super().__init__(type_=RichTextElementType.LINK)\n        self.url = url\n        self.text = text\n        self.unsafe = unsafe\n        self.bold = bold\n        self.italic = italic\n        self.strike = strike\n        self.code = code\n\n    def _resolve(self) -> Dict[str, Any]:\n        link = super()._resolve()\n        link[\"url\"] = self.url\n        if self.text is not None:\n            link[\"text\"] = self.text\n        if self.unsafe is not None:\n            link[\"unsafe\"] = self.unsafe\n        style = {}\n        if self.bold is not None:\n            style[\"bold\"] = self.bold\n        if self.italic is not None:\n            style[\"italic\"] = self.italic\n        if self.strike is not None:\n            style[\"strike\"] = self.strike\n        if self.code is not None:\n            style[\"code\"] = self.code\n        if style:\n            link[\"style\"] = style\n        return link\n
"},{"location":"reference/rich_text/#rich_text.elements.RichTextUser","title":"RichTextUser","text":"

Rich text element for representing users in RichTextBlocks.

See: https://api.slack.com/reference/block-kit/blocks#user-element-type.

Parameters:

Name Type Description Default user_id str

the Slack ID of the user in question, you can get these from users' profiles or Slack client requests.

required bold Optional[bool]

whether to render the given user in bold font.

None italic Optional[bool]

whether to render the given user in italics.

None strike Optional[bool]

whether to render the given user with a \"strikethrough\".

None highlight Optional[bool]

whether to give the user a distinct highlight when rendered.

None client_highlight Optional[bool]

???

None unlink Optional[bool]

whether to remove the link to the user from the channel when rendered.

None Source code in slackblocks/rich_text/elements.py
class RichTextUser(RichTextElement):\n    \"\"\"\n    Rich text element for representing users in\n        [`RichTextBlocks`](/slackblocks/latest/reference/blocks/#blocks.RichTextBlock).\n\n    See: <https://api.slack.com/reference/block-kit/blocks#user-element-type>.\n\n    Args:\n        user_id: the Slack ID of the user in question, you can get these\n            from users' profiles or Slack client requests.\n        bold: whether to render the given user in bold font.\n        italic: whether to render the given user in italics.\n        strike: whether to render the given user with a \"strikethrough\".\n        highlight: whether to give the user a distinct highlight when rendered.\n        client_highlight: ???\n        unlink: whether to remove the link to the user from the channel when\n            rendered.\n    \"\"\"\n\n    def __init__(\n        self,\n        user_id: str,\n        bold: Optional[bool] = None,\n        italic: Optional[bool] = None,\n        strike: Optional[bool] = None,\n        highlight: Optional[bool] = None,\n        client_highlight: Optional[bool] = None,\n        unlink: Optional[bool] = None,\n    ) -> None:\n        super().__init__(RichTextElementType.USER)\n        self.user_id = user_id\n        self.bold = bold\n        self.italic = italic\n        self.strike = strike\n        self.highlight = highlight\n        self.client_highlight = client_highlight\n        self.unlink = unlink\n\n    def _resolve(self) -> Dict[str, Any]:\n        user = super()._resolve()\n        user[\"user_id\"] = self.user_id\n        style = {}\n        if self.bold is not None:\n            style[\"bold\"] = self.bold\n        if self.italic is not None:\n            style[\"italic\"] = self.italic\n        if self.strike is not None:\n            style[\"strike\"] = self.strike\n        if self.highlight is not None:\n            style[\"highlight\"] = self.highlight\n        if self.client_highlight is not None:\n            style[\"client_highlight\"] = self.client_highlight\n        if self.unlink is not None:\n            style[\"unlink\"] = self.unlink\n        if style:\n            user[\"style\"] = style\n        return user\n
"},{"location":"reference/rich_text/#rich_text.elements.RichTextUserGroup","title":"RichTextUserGroup","text":"

Rich text element for representing groups of users in RichTextBlocks`.

See: https://api.slack.com/reference/block-kit/blocks#user-element-type.

Parameters:

Name Type Description Default user_group_id str

the Slack ID of the user group being represented.

required bold Optional[bool]

whether to render the given user in bold font.

None italic Optional[bool]

whether to render the given user in italics.

None strike Optional[bool]

whether to render the given user with a \"strikethrough\".

None highlight Optional[bool]

whether to give the user a distinct highlight when rendered.

None client_highlight Optional[bool]

???

None unlink Optional[bool]

whether to remove the link to the user from the channel when rendered.

None Source code in slackblocks/rich_text/elements.py
class RichTextUserGroup(RichTextElement):\n    \"\"\"\n    Rich text element for representing groups of users in\n        [`RichTextBlocks`](/slackblocks/latest/reference/blocks/#blocks.RichTextBlock)`.\n\n    See: <https://api.slack.com/reference/block-kit/blocks#user-element-type>.\n\n    Args:\n        user_group_id: the Slack ID of the user group being represented.\n        bold: whether to render the given user in bold font.\n        italic: whether to render the given user in italics.\n        strike: whether to render the given user with a \"strikethrough\".\n        highlight: whether to give the user a distinct highlight when rendered.\n        client_highlight: ???\n        unlink: whether to remove the link to the user from the channel when\n            rendered.\n    \"\"\"\n\n    def __init__(\n        self,\n        user_group_id: str,\n        bold: Optional[bool] = None,\n        italic: Optional[bool] = None,\n        strike: Optional[bool] = None,\n        highlight: Optional[bool] = None,\n        client_highlight: Optional[bool] = None,\n        unlink: Optional[bool] = None,\n    ) -> None:\n        super().__init__(RichTextElementType.USER_GROUP)\n        self.user_group_id = user_group_id\n        self.bold = bold\n        self.italic = italic\n        self.strike = strike\n        self.highlight = highlight\n        self.client_highlight = client_highlight\n        self.unlink = unlink\n\n    def _resolve(self) -> Dict[str, Any]:\n        user_group = super()._resolve()\n        user_group[\"user_group_id\"] = self.user_group_id\n        style = {}\n        if self.bold is not None:\n            style[\"bold\"] = self.bold\n        if self.italic is not None:\n            style[\"italic\"] = self.italic\n        if self.strike is not None:\n            style[\"strike\"] = self.strike\n        if self.highlight is not None:\n            style[\"highlight\"] = self.highlight\n        if self.client_highlight is not None:\n            style[\"client_highlight\"] = self.client_highlight\n        if self.unlink is not None:\n            style[\"unlink\"] = self.unlink\n        if style:\n            user_group[\"style\"] = style\n        return user_group\n
"},{"location":"reference/rich_text/#rich-text-objects-containers","title":"Rich Text Objects (Containers)","text":"

Rich text objects are containers for rich text elements.

These obejects form the contents of the RichTextBlock.

"},{"location":"reference/rich_text/#rich_text.objects.ListType","title":"ListType","text":"

An Enum that lists the available types of rich text lists.

  • ListType.BULLET: an unorderd (bulleted) list.
  • ListType.ORDERED: an ordered (numbered) list.
Source code in slackblocks/rich_text/objects.py
class ListType(Enum):\n    \"\"\"\n    An `Enum` that lists the available types of rich text lists.\n\n    - `ListType.BULLET`: an unorderd (bulleted) list.\n    - `ListType.ORDERED`: an ordered (numbered) list.\n    \"\"\"\n\n    BULLET = \"bullet\"\n    ORDERED = \"ordered\"\n\n    def all() -> List[str]:\n        return [list_type.value for list_type in ListType]\n
"},{"location":"reference/rich_text/#rich_text.objects.RichTextCodeBlock","title":"RichTextCodeBlock","text":"

A rich text element for representing blocks of code in RichTextBlocks.

This is roughly equivalent to the triple-backtick ```code``` syntax in markdown.

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

Parameters:

Name Type Description Default elements Union[RichTextElement, List[RichTextElement]]

one or more rich text primitive objexts (e.g. RichText).

required border Optional[int]

the thickness (in pixels) of the border around the code block.

None Throws

InvalidUsageError: if any of the items in elements aren't valid rich text elements.

Source code in slackblocks/rich_text/objects.py
class RichTextCodeBlock(RichTextObject):\n    \"\"\"\n    A rich text element for representing blocks of code in\n        [`RichTextBlocks`](reference/blocks/#blocks.RichTextBlock).\n\n    This is roughly equivalent to the triple-backtick \\`\\`\\``code`\\`\\`\\` syntax in markdown.\n\n    See: <https://api.slack.com/reference/block-kit/blocks#rich_text_preformatted>.\n\n    Args:\n        elements: one or more rich text primitive objexts\n            (e.g. [`RichText`](/slackblocks/latest/reference/rich_text/#rich_text.RichText)).\n        border: the thickness (in pixels) of the border around the code block.\n\n    Throws:\n        InvalidUsageError: if any of the items in `elements` aren't valid rich\n            text elements.\n    \"\"\"\n\n    def __init__(\n        self,\n        elements: Union[RichTextElement, List[RichTextElement]],\n        border: Optional[int] = None,\n    ) -> None:\n        super().__init__(type_=RichTextObjectType.PREFORMATTED)\n        self.elements = coerce_to_list(\n            elements,\n            (\n                RichText,\n                RichTextChannel,\n                RichTextEmoji,\n                RichTextLink,\n                RichTextUser,\n                RichTextUserGroup,\n            ),\n        )\n        self.border = border\n\n    def _resolve(self) -> Dict[str, Any]:\n        preformatted = super()._resolve()\n        preformatted[\"elements\"] = [element._resolve() for element in self.elements]\n        if self.border is not None:\n            preformatted[\"border\"] = self.border\n        return preformatted\n
"},{"location":"reference/rich_text/#rich_text.objects.RichTextList","title":"RichTextList","text":"

Renders to a HTML list containing rich text elements.

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

Parameters:

Name Type Description Default style Union[str, ListType]

one of ListType.BULLET or ListType.ORDERED.

required elements Union[RichTextSection, List[RichTextSection]]

a list of (possibly nested) RichTextSection elements. Each object in this list will be rendered as a list item.

required indent Optional[int]

indent (in pixels) of each list item.

None offset Optional[int]

offset (in pixels) of each list item.

0 border Optional[int]

thickness (in pixels) of the (optional) border around the list.

0 Throws

InvalidUsageError: if style is not a valid ListType or any of the items in elements isn't a valid RichTextSection.

Source code in slackblocks/rich_text/objects.py
class RichTextList(RichTextObject):\n    \"\"\"\n    Renders to a HTML list containing rich text elements.\n\n    See: <https://api.slack.com/reference/block-kit/blocks#rich_text_list>.\n\n    Args:\n        style: one of `ListType.BULLET` or `ListType.ORDERED`.\n        elements: a list of (possibly nested) `RichTextSection` elements.\n            Each object in this list will be rendered as a list item.\n        indent: indent (in pixels) of each list item.\n        offset: offset (in pixels) of each list item.\n        border: thickness (in pixels) of the (optional) border around the list.\n\n    Throws:\n        InvalidUsageError: if style is not a valid `ListType` or any of the\n            items in `elements` isn't a valid `RichTextSection`.\n    \"\"\"\n\n    def __init__(\n        self,\n        style: Union[str, ListType],\n        elements: Union[RichTextSection, List[RichTextSection]],\n        indent: Optional[int] = None,\n        offset: Optional[int] = 0,\n        border: Optional[int] = 0,\n    ) -> None:\n        super().__init__(type_=RichTextObjectType.LIST)\n        if isinstance(style, str):\n            if style in ListType.all():\n                self.style = style\n            else:\n                raise InvalidUsageError(f\"`style` must be one of [{ListType.all()}]\")\n        elif isinstance(style, ListType):\n            self.style = style.value\n        self.elements = coerce_to_list(elements, RichTextSection, min_size=1)\n        self.indent = validate_int(indent, allow_none=True)\n        self.offset = validate_int(offset, allow_none=True)\n        self.border = validate_int(border, allow_none=True)\n\n    def _resolve(self) -> Dict[str, Any]:\n        rich_text_list = super()._resolve()\n        rich_text_list[\"elements\"] = [element._resolve() for element in self.elements]\n        rich_text_list[\"style\"] = self.style\n        if self.indent is not None:\n            rich_text_list[\"indent\"] = self.indent\n        if self.offset is not None:\n            rich_text_list[\"offset\"] = self.offset\n        if self.border is not None:\n            rich_text_list[\"border\"] = self.border\n        return rich_text_list\n
"},{"location":"reference/rich_text/#rich_text.objects.RichTextQuote","title":"RichTextQuote","text":"

A rich text object for representing a block quote.

Block quotes are presented with a vertical bar to the left hand side of the text.

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

Parameters:

Name Type Description Default elements Union[RichTextElement, List[RichTextElement]]

one or more rich text primitive objexts (e.g. RichText).

required border Optional[int]

the thickness (in pixels) of the border around the code block.

None Source code in slackblocks/rich_text/objects.py
class RichTextQuote(RichTextObject):\n    \"\"\"\n    A rich text object for representing a block quote.\n\n    Block quotes are presented with a vertical bar to the left hand side of\n        the text.\n\n    See: <https://api.slack.com/reference/block-kit/blocks#rich_text_quote>\n\n    Args:\n        elements: one or more rich text primitive objexts\n            (e.g. [`RichText`](/slackblocks/latest/reference/rich_text/#rich_text.RichText)).\n        border: the thickness (in pixels) of the border around the code block.\n    \"\"\"\n\n    def __init__(\n        self,\n        elements: Union[RichTextElement, List[RichTextElement]],\n        border: Optional[int] = None,\n    ) -> None:\n        super().__init__(RichTextObjectType.QUOTE)\n        self.elements = coerce_to_list(\n            elements,\n            (\n                RichText,\n                RichTextChannel,\n                RichTextEmoji,\n                RichTextLink,\n                RichTextUser,\n                RichTextUserGroup,\n            ),\n        )\n        self.border = border\n\n    def _resolve(self) -> Dict[str, Any]:\n        quote = super()._resolve()\n        quote[\"elements\"] = [element._resolve() for element in self.elements]\n        if self.border is not None:\n            quote[\"border\"] = self.border\n        return quote\n
"},{"location":"reference/rich_text/#rich_text.objects.RichTextSection","title":"RichTextSection","text":"

The most basic rich text container object, which takes rich text elements and renders them when RichTextSection is passed to a RichTextBlock.

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

Parameters:

Name Type Description Default elements Union[RichTextElement, List[RichTextElement]]

one or more rich text elements that will form the content of the section. e.g. RichText, RichTextLink.

required Throws

InvalidUsageError: if any of the items passed to elements isn't a valid RichTextObject.

Source code in slackblocks/rich_text/objects.py
class RichTextSection(RichTextObject):\n    \"\"\"\n    The most basic rich text container object, which takes rich text elements\n        and renders them when `RichTextSection` is passed to a\n        [`RichTextBlock`](/slackblocks/latest/reference/blocks/#blocks.RichTextBlock).\n\n    See: <https://api.slack.com/reference/block-kit/blocks#rich_text_section>.\n\n    Args:\n        elements: one or more rich text elements that will form the content of the section.\n            e.g. `RichText`, `RichTextLink`.\n\n    Throws:\n        InvalidUsageError: if any of the items passed to `elements` isn't a valid\n            `RichTextObject`.\n    \"\"\"\n\n    def __init__(self, elements: Union[RichTextElement, List[RichTextElement]]) -> None:\n        super().__init__(type_=RichTextObjectType.SECTION)\n        self.elements = coerce_to_list(\n            elements,\n            class_=(\n                RichTextChannel,\n                RichTextEmoji,\n                RichTextLink,\n                RichText,\n                RichTextUser,\n                RichTextUserGroup,\n            ),\n            min_size=1,\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        section = super()._resolve()\n        section[\"elements\"] = [element._resolve() for element in self.elements]\n        return section\n
"},{"location":"reference/utils/","title":"Utilities","text":"

This module collects various utility functions used for validating the input to Messages, Blocks, Elements and Objects.

"},{"location":"reference/utils/#utils.coerce_to_list","title":"coerce_to_list","text":"
coerce_to_list(\n    object_or_objects,\n    class_,\n    allow_none=False,\n    min_size=None,\n    max_size=None,\n)\n

Takes and object or list of objects and validates its contents, ensuring that the resulting object is a list.

Parameters:

Name Type Description Default object_or_objects Union[T, List[T]]

the Python object or objects to validate and convert to a list.

required class_ Union[Any, List[Any]]

the Python type (or class) of objects expected in the list.

required allow_none bool

whether or not None is a valid input (and thus output) option.

False min_size Optional[int]

if provided, the length of object_or_objects cannot be smaller than this.

None max_size Optional[int]

if provided, the length of object_or_objects cannot be larger than this.

None

Returns:

Type Description List[T]

object_or_objects if it was a valid list, [object_or_objects] if it was a valid object, or None if provided and allowed.

Throws

InvalidUsageError: if any of the validation checks fail.

Source code in slackblocks/utils.py
def coerce_to_list(\n    object_or_objects: Union[T, List[T]],\n    class_: Union[Any, List[Any]],\n    allow_none: bool = False,\n    min_size: Optional[int] = None,\n    max_size: Optional[int] = None,\n) -> List[T]:\n    \"\"\"\n    Takes and object or list of objects and validates its contents, ensuring that the\n    resulting object is a list.\n\n    Args:\n        object_or_objects: the Python object or objects to validate and convert to a list.\n        class_: the Python type (or class) of objects expected in the list.\n        allow_none: whether or not None is a valid input (and thus output) option.\n        min_size: if provided, the length of `object_or_objects` cannot be smaller than this.\n        max_size: if provided, the length of `object_or_objects` cannot be larger than this.\n\n    Returns:\n        `object_or_objects` if it was a valid list, `[object_or_objects]` if it was a valid\n            object, or `None` if provided and allowed.\n\n    Throws:\n        InvalidUsageError: if any of the validation checks fail.\n    \"\"\"\n    if object_or_objects is None and allow_none:\n        return None\n    if object_or_objects is None and not allow_none:\n        raise InvalidUsageError(\n            f\"Type of {object_or_objects} ({type(object_or_objects)})) is \"\n            f\"None should be type `{class_}`.\"\n        )\n\n    if isinstance(object_or_objects, List):\n        items = object_or_objects\n    else:\n        items = [\n            object_or_objects,\n        ]\n\n    for item in items:\n        if not isinstance(class_, Tuple):\n            class_ = (class_,)\n        if not isinstance(item, class_):\n            raise InvalidUsageError(\n                f\"Type of {item} ({type(item)})) inconsistent with expected type {class_}.\"\n            )\n\n    if items is not None:\n        length = len(items)\n        if min_size is not None and length < min_size:\n            raise InvalidUsageError(\n                f\"Size ({length}) of list of {type(class_)} is less than `min_size` ({min_size})\"\n            )\n\n        if max_size is not None and length > max_size:\n            raise InvalidUsageError(\n                f\"Size ({length}) of list of {type(class_)} exceeds `max_size` ({max_size})\"\n            )\n\n    return items\n
"},{"location":"reference/utils/#utils.is_hex","title":"is_hex","text":"
is_hex(string)\n

Determines whether a given string is a valid hexadecimal number.

Parameters:

Name Type Description Default string str

the string to examine for hex characters.

required

Returns:

Type Description bool

True if the string is a valid hexadecimal number, otherwise False.

Source code in slackblocks/utils.py
def is_hex(string: str) -> bool:\n    \"\"\"\n    Determines whether a given string is a valid hexadecimal number.\n\n    Args:\n        string: the string to examine for hex characters.\n\n    Returns:\n        `True` if the string is a valid hexadecimal number, otherwise `False`.\n    \"\"\"\n    return all(char in hexdigits for char in string)\n
"},{"location":"reference/utils/#utils.validate_action_id","title":"validate_action_id","text":"
validate_action_id(action_id, allow_none=False)\n

Action IDs are used in the handing of user interactivity within Slack blocks. This function checks that a given action_id is valid as per the requirements imposed by the Slack API.

See: https://api.slack.com/interactivity/handling

Parameters:

Name Type Description Default action_id str

the action_id string to validate for correctness as per the Slack API.

required allow_none bool

whether to accept None as a valid value for action_id.

False

Returns:

Type Description Optional[str]

The original value action_id if all validation checks pass.

Throws

InvalidUsageError if any of the validation checks fail.

Source code in slackblocks/utils.py
def validate_action_id(action_id: str, allow_none: bool = False) -> Optional[str]:\n    \"\"\"\n    Action IDs are used in the handing of user interactivity within Slack blocks.\n    This function checks that a given `action_id` is valid as per the requirements\n    imposed by the Slack API.\n\n    See: <https://api.slack.com/interactivity/handling>\n\n    Args:\n        action_id: the action_id string to validate for correctness as per the Slack API.\n        allow_none: whether to accept `None` as a valid value for `action_id`.\n\n    Returns:\n        The original value `action_id` if all validation checks pass.\n\n    Throws:\n        InvalidUsageError if any of the validation checks fail.\n    \"\"\"\n    if action_id is None:\n        if not allow_none:\n            raise InvalidUsageError(\"`action_id` cannot be None.\")\n    else:\n        length = len(action_id)\n        if length < 1:\n            raise InvalidUsageError(\"`action_id` cannot be empty.\")\n        if length > 255:\n            raise InvalidUsageError(\n                f\"`action_id` length ({length}) exceeds limit of 255 characters (id: {action_id}).\"\n            )\n    return action_id\n
"},{"location":"reference/utils/#utils.validate_int","title":"validate_int","text":"
validate_int(\n    num, min_value=None, max_value=None, allow_none=False\n)\n

Performs basic validation checks against a given integer.

Parameters:

Name Type Description Default num Union[int, None]

the number to validate.

required min_value Optional[int]

if num is less than this value, an error will be thrown.

None max_value Optional[int]

if num is greater than this value, an error will be thrown.

None allow_none bool

whether None is a valid value for num. If num is None allow_none is False, an error will be thrown.

False

Returns:

Type Description int

The original value of num if it passes all validation checks.

Throws

InvalidUsageError: if any of the validation checks fail.

Source code in slackblocks/utils.py
def validate_int(\n    num: Union[int, None],\n    min_value: Optional[int] = None,\n    max_value: Optional[int] = None,\n    allow_none: bool = False,\n) -> int:\n    \"\"\"\n    Performs basic validation checks against a given integer.\n\n    Args:\n        num: the number to validate.\n        min_value: if `num` is less than this value, an error will be thrown.\n        max_value: if `num` is greater than this value, an error will be thrown.\n        allow_none: whether `None` is a valid value for `num`. If `num` is `None`\n            `allow_none` is `False`, an error will be thrown.\n\n    Returns:\n        The original value of `num` if it passes all validation checks.\n\n    Throws:\n        InvalidUsageError: if any of the validation checks fail.\n    \"\"\"\n    if num is None and not allow_none:\n        raise InvalidUsageError(\"`num` is None, which is disallowed.\")\n    if min_value is not None:\n        if num < min_value:\n            raise InvalidUsageError(f\"{num} is less than the minimum {min_value}\")\n    if max_value is not None:\n        if num > max_value:\n            raise InvalidUsageError(f\"{num} is less than the minimum {max_value}\")\n    return num\n
"},{"location":"reference/utils/#utils.validate_string","title":"validate_string","text":"
validate_string(\n    string,\n    field_name,\n    max_length=None,\n    min_length=None,\n    allow_none=False,\n)\n

Performs basic validation actions (e.g. length checking) on a given string based on the provided criteria.

Parameters:

Name Type Description Default string Optional[str]

the string to validate

required field_name str

the name of the field the string belongs to (for error reporting purposes).

required min_length Optional[int]

if the string is less than this length, an error will be raised.

None max_length Optional[int]

if the string is greated than this length, an error will be raised.

None allow_none bool

whether None is a valid value for the string being validated.

False

Returns:

Type Description Optional[str]

The original string if it deemed to be valid (i.e. no errors are thrown).

Throws

InvalidUsageError: if any of the validation checks (length, None) fail.

Source code in slackblocks/utils.py
def validate_string(\n    string: Optional[str],\n    field_name: str,\n    max_length: Optional[int] = None,\n    min_length: Optional[int] = None,\n    allow_none: bool = False,\n) -> Optional[str]:\n    \"\"\"\n    Performs basic validation actions (e.g. length checking) on a given string\n    based on the provided criteria.\n\n    Args:\n        string: the string to validate\n        field_name: the name of the field the string belongs to (for error reporting purposes).\n        min_length: if the string is less than this length, an error will be raised.\n        max_length: if the string is greated than this length, an error will be raised.\n        allow_none: whether `None` is a valid value for the string being validated.\n\n    Returns:\n        The original string if it deemed to be valid (i.e. no errors are thrown).\n\n    Throws:\n        InvalidUsageError: if any of the validation checks (length, `None`) fail.\n    \"\"\"\n    if string is None:\n        if not allow_none:\n            raise InvalidUsageError(\n                f\"Expecting string for field `{field_name}`, cannot be None.\"\n            )\n    else:\n        length = len(string)\n        if min_length and length < min_length:\n            raise InvalidUsageError(\n                f\"Argument to field `{field_name}` ({length} characters) \"\n                f\"is less than minimum length of {min_length} characters\"\n            )\n        if max_length and length > max_length:\n            raise InvalidUsageError(\n                f\"Argument to field `{field_name}` ({length} characters) \"\n                f\"exceeds length limit of {max_length} characters\"\n            )\n    return string\n
"},{"location":"reference/views/","title":"Views","text":"

Views are app-customized visual areas within modals and Home tabs.

See: https://api.slack.com/reference/surfaces/views.

"},{"location":"reference/views/#views.HomeTabView","title":"HomeTabView","text":"

HomeTabViews are used with the views.publish Web API method.

See: https://api.slack.com/reference/surfaces/views#home.

Parameters:

Name Type Description Default blocks Union[Block, List[Block]]

A list of blocks that defines the content of the view (max 100).

required private_metadata Optional[str]

a string (max 3000 chars) that will be sent to your app in view_submission.

None callback_id Optional[str]

A string that will identify submissions of this view.

None external_id Optional[str]

A custom identifier that is unique within the views of a given Slack team.

None Source code in slackblocks/views.py
class HomeTabView(View):\n    \"\"\"\n    `HomeTabViews` are used with the `views.publish` Web API method.\n\n    See: <https://api.slack.com/reference/surfaces/views#home>.\n\n    Args:\n        blocks: A list of blocks that defines the content of the view (max 100).\n        private_metadata: a string (max 3000 chars) that will be sent to your app\n            in `view_submission`.\n        callback_id: A string that will identify submissions of this view.\n        external_id: A custom identifier that is unique within the views of a\n            given Slack team.\n    \"\"\"\n\n    def __init__(\n        self,\n        blocks: Union[Block, List[Block]],\n        private_metadata: Optional[str] = None,\n        callback_id: Optional[str] = None,\n        external_id: Optional[str] = None,\n    ) -> \"HomeTabView\":\n        super().__init__(\n            type=ViewType.HOME,\n            blocks=blocks,\n            private_metadata=private_metadata,\n            callback_id=callback_id,\n            external_id=external_id,\n        )\n
"},{"location":"reference/views/#views.ModalView","title":"ModalView","text":"

Modal views are used with the views.open, views.update and views.push Slack Web API methods.

See: https://api.slack.com/reference/surfaces/views#modal

Parameters:

Name Type Description Default title TextLike

heading that appears at the top left of the view.

required blocks Union[Block, List[Block]]

a list of blocks (max 100) that define the content of the view.

required close Optional[TextLike]

the text of the close button (max 24 chars) in the view. Must be Text.PLAINTEXT.

None submit Optional[TextLike]

the text of the submit button (max 24 chars) in the view. Must be Text.PLAINTEXT.

None private_metadata Optional[str]

a string (max 3000 chars) that will be sent to your app in view_submission.

None callback_id Optional[str]

A string that will identify submissions of this view.

None clear_on_close Optional[bool]

when True all views in the model will be cleared when it is closed.

False notify_on_close Optional[bool]

when True a view_closed event will be sent when the modal is closed.

False external_id Optional[str]

A custom identifier that is unique within the views of a given Slack team.

None submit_disabled Optional[bool]

when True disabled submitting the form until one or more inputs have been provided. Used only for configuaration models.

False Source code in slackblocks/views.py
class ModalView(View):\n    \"\"\"\n    Modal views are used with the `views.open`, `views.update` and `views.push`\n        Slack Web API methods.\n\n    See: <https://api.slack.com/reference/surfaces/views#modal>\n\n    Args:\n        title: heading that appears at the top left of the view.\n        blocks: a list of blocks (max 100) that define the content of the view.\n        close: the text of the close button (max 24 chars) in the view.\n            Must be `Text.PLAINTEXT`.\n        submit: the text of the submit button (max 24 chars) in the view.\n            Must be `Text.PLAINTEXT`.\n        private_metadata: a string (max 3000 chars) that will be sent to your app\n            in `view_submission`.\n        callback_id: A string that will identify submissions of this view.\n        clear_on_close: when `True` all views in the model will be cleared when\n            it is closed.\n        notify_on_close: when `True` a `view_closed` event will be sent when the\n            modal is closed.\n        external_id: A custom identifier that is unique within the views of a\n            given Slack team.\n        submit_disabled: when `True` disabled submitting the form until one or\n            more inputs have been provided. Used only for\n            [`configuaration models`](https://api.slack.com/reference/workflows/configuration-view).\n    \"\"\"\n\n    def __init__(\n        self,\n        title: TextLike,\n        blocks: Union[Block, List[Block]],\n        close: Optional[TextLike] = None,\n        submit: Optional[TextLike] = None,\n        private_metadata: Optional[str] = None,\n        callback_id: Optional[str] = None,\n        clear_on_close: Optional[bool] = False,\n        notify_on_close: Optional[bool] = False,\n        external_id: Optional[str] = None,\n        submit_disabled: Optional[bool] = False,\n    ):\n        super().__init__(\n            type=ViewType.MODAL,\n            blocks=blocks,\n            private_metadata=private_metadata,\n            callback_id=callback_id,\n            external_id=external_id,\n        )\n        self.title = Text.to_text(title, force_plaintext=True, max_length=24)\n        self.close = Text.to_text(\n            close, force_plaintext=True, max_length=24, allow_none=True\n        )\n        self.submit = Text.to_text(\n            submit, force_plaintext=True, max_length=24, allow_none=True\n        )\n        self.clear_on_close = clear_on_close\n        self.notify_on_close = notify_on_close\n        self.submit_disabled = submit_disabled\n\n    def _resolve(self) -> Dict[str, Any]:\n        modal_view = super()._resolve()\n        modal_view[\"title\"] = self.title._resolve()\n        if self.close:\n            modal_view[\"close\"] = self.close._resolve()\n        if self.submit:\n            modal_view[\"submit\"] = self.submit._resolve()\n        if self.clear_on_close:\n            modal_view[\"clear_on_close\"] = self.clear_on_close\n        if self.notify_on_close:\n            modal_view[\"notify_on_close\"] = self.notify_on_close\n        if self.submit_disabled:\n            modal_view[\"submit_disabled\"] = self.submit_disabled\n        return modal_view\n
"},{"location":"usage/installation/","title":"Installation","text":""},{"location":"usage/installation/#installing-slackblocks","title":"Installing slackblocks","text":"

You can install slackblocks using any Python package manager with access to PyPI. Installation commands for some of the more popular ones are included below.

pippoetryPipenv
pip install slackblocks\n
poetry add slackblocks\n
pipenv install slackblocks\n

slackblocks is a pure Python package and is published automatically to PyPI as Python wheels whenever a new version is released.

As of version `v0.1.0`` it has no dependencies outside of the Python standard library.

"},{"location":"usage/installation/#uninstalling-slackblocks","title":"Uninstalling slackblocks","text":"

If, for whatever reason, you need to remove slackblocks from your environment you can do so with the following commands:

pippoetryPipenv
pip uninstall slackblocks\n
poetry remove slackblocks\n
pipenv uninstall slackblocks\n
"},{"location":"usage/sending_messages/","title":"Sending Messages","text":"

slackblocks is designed primarily for use with either the slack-sdk or (legacy) slackclient Python packages. Usage of slackblocks remains identical regardless of which Slack client library you're using.

While there's nothing stopping you from sending the rendered messages directly with curl or requests, we recommend using the ** (dictionary unpacking)operator to unpack slackblocks Messages directly into the Slack client's chat_postMessage function.

An example of this is provided below along with the JSON result of rendering the message, an equivalent curl command, and finally the result of the message as it appears in the Slack user interface.

Python (slackblocks)JSON MessageEquivalent curl CommandSlack UI Output
from os import environ\nfrom slack import WebClient\nfrom slackblocks import Message, SectionBlock\n\n\nclient = WebClient(token=environ[\"SLACK_API_TOKEN\"])\nblock = SectionBlock(\"Hello, world!\")\nmessage = Message(channel=\"#general\", blocks=block)\n\nresponse = client.chat_postMessage(**message)\n

{\n    \"channel\": \"#general\",\n    \"mrkdwn\": true,\n    \"blocks\": [\n        {\n            \"type\": \"section\",\n            \"block_id\": \"992ceb6b-9ad4-496b-b8e6-1bd8a632e8b3\",\n            \"text\": {\n                \"type\": \"mrkdwn\",\n                \"text\": \"Hello, world!\"\n            }\n        }\n    ]\n}\n
* Note that the block_id field is a pseudorandomly generated UUID. You can pass a value to Block constructors should you desire deterministic Blocks.

curl -H \"Content-type: application/json\" \\\n--data '{\"channel\":\"#general\",\"blocks\":[{\"type\":\"section\", \"block_id\": \"992ceb6b-9ad4-496b-b8e6-1bd8a632e8b3\", \"text\":{\"type\":\"mrkdwn\",\"text\":\"Hello, world\"}}]}' \\\n-H \"Authorization: Bearer ${SLACK_API_TOKEN}\" \\\n-X POST https://slack.com/api/chat.postMessage\n

"},{"location":"usage/using_blocks/","title":"Using Blocks","text":""},{"location":"usage/using_blocks/#section-block","title":"Section Block","text":"

A section is one of the most flexible blocks available - it can be used as a simple text block, or with any of the available block elements.

Section blocks can also optionally be given an \"accessory,\" which is typically one of the interactive Elements.

Parameters:

Name Type Description Default text Optional[TextLike]

text to include in the block. Can be a string or Text object (of either mrkdwn or plaintext variety). Defaults to markdown if unspecified. One of either text or fields must be provided.

None block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None fields Optional[Union[TextLike, List[TextLike]]]

a list of text objects. One of either text or fields must be provided.

None accessory Optional[Element]

an optional Element object that will take a secondary place in the block (after or to the side of text or fields).

None Throws

InvalidUsageError: if any of the provided arguments fail validation checks.

slackblocksJSONSlack UI
from slackblocks import Checkboxes, Option, SectionBlock\n\nSectionBlock(\n    text=\"This is a section block with a checkbox accessory.\", \n    block_id=\"fake_block_id\"\n    accessory=CheckboxGroup(\n        action_id=\"checkboxes-action\",\n        options=[\n            Option(\n                text=\"*Your Only Option*\",\n                value=\"option_one\"\n            )\n        ]\n    )\n)\n
{\n    \"type\": \"section\",\n    \"block_id\": \"fake_block_id\",\n    \"text\": {\n        \"type\": \"mrkdwn\",\n        \"text\": \"This is a section block with a checkbox accessory.\"\n    },\n    \"accessory\": {\n        \"type\": \"checkboxes\",\n        \"options\": [\n            {\n                \"text\": {\n                    \"type\": \"mrkdwn\",\n                    \"text\": \"*Your Only Option*\"\n                },\n                \"value\": \"option_one\"\n            }\n        ],\n        \"action_id\": \"checkboxes-action\"\n    }\n}\n

"},{"location":"usage/using_blocks/#rich-text-block","title":"Rich Text Block","text":"

A RichTextBlock is used to provide easier rich text formatting than standard markdown text (e.g. in a SectionBlock) and access to text formatting features not available in traditional markdown (e.g. strikethrough). See the various rich text elements you can include here.

Parameters:

Name Type Description Default elements Union[RichTextObject, List[RichTextObject]]

a single rich text element or a list of those elements.

required block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None Throws

InvalidUsageError: if the elements in elements are not valid rich text elements.

slackblocksJSONSlack UI
from slackblock import RichTextBlock, RichTextSection, RichText\n\nRichTextBlock(\n    RichTextSection(\n        [\n            RichText(\n                \"You 'bout to witness hip-hop in its most purest\",\n                bold=True,\n            ),\n            RichText(\n                \"Most rawest form, flow almost flawless\",\n                strike=True,\n            ),\n            RichText(\n                \"Most hardest, most honest known artist\",\n                italic=True,\n            ),\n        ]\n    ),\n    block_id=\"fake_block_id\",\n)\n
{\n    \"type\": \"rich_text\",\n    \"block_id\": \"fake_block_id\",\n    \"elements\": [\n        {\n            \"type\": \"rich_text_section\",\n            \"elements\": [\n                {\n                    \"type\": \"text\",\n                    \"text\": \"You 'bout to witness hip-hop in its most purest\\n\",\n                    \"style\": {\n                        \"bold\": true\n                    }\n                },\n                {\n                    \"type\": \"text\",\n                    \"text\": \"Most rawest form, flow almost flawless\\n\",\n                    \"style\": {\n                        \"strike\": true\n                    }\n                },\n                {\n                    \"type\": \"text\",\n                    \"text\": \"Most hardest, most honest known artist\\n\",\n                    \"style\": {\n                        \"italic\": true\n                    }\n                }\n            ]\n        }\n    ]\n}\n

"},{"location":"usage/using_blocks/#header-block","title":"Header Block","text":"

A Header Block is a plain-text block that displays in a larger, bold font.

Parameters:

Name Type Description Default text Union[str, Text]

the text that will be rendered as a heading.

required block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None slackblocksJSONSlack UI
from slackblocks import HeaderBlock\n\nHeaderBlock(\n    \"This is a header block\",\n)\n
{\n    \"type\": \"header\",\n    \"text\": {\n        \"type\": \"plain_text\",\n        \"text\": \"This is a header block\",\n        \"emoji\": true\n    }\n}\n

"},{"location":"usage/using_blocks/#image-block","title":"Image Block","text":"

An Image Block contains a single graphic, accessed by URL.

Parameters:

Name Type Description Default image_url str

the URL pointing to the image file you want to display.

required alt_text Optional[str]

alternative text for accessibility purposes and when the image fails to load.

' ' title Optional[Union[Text, str]]

an optional text title to be presented with the image.

None block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None Throws

InvalidUsageError: when one or more of the provided args fails validation.

slackblocksJSONSlack UI
from slackblocks import ImageBlock\n\nImageBlock(\n    image_url=\"https://api.slack.com/img/blocks/bkb_template_images/beagle.png\",\n    alt_text=\"a beagle\",\n    title=\"dog\",\n    block_id=\"fake_block_id\",\n)\n
{\n    \"type\": \"image\",\n    \"block_id\": \"fake_block_id\",\n    \"image_url\": \"https://api.slack.com/img/blocks/bkb_template_images/beagle.png\",\n    \"alt_text\": \"a beagle\",\n    \"title\": {\n        \"type\": \"plain_text\",\n        \"text\": \"dog\"\n    }\n}\n

"},{"location":"usage/using_blocks/#input-block","title":"Input Block","text":"

A block that collects information from users - it can hold a plain-text input element, a checkbox element, a radio button element, a select menu element, a multi-select menu element, or a datepicker.

Parameters:

Name Type Description Default label TextLike

the name which identifies the input field.

required element Element

an interactive Element (e.g. a text field).

required dispatch_action bool

whether the Element should trigger the sending of a block_actions payload.

False block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None hint Optional[TextLike]

an optional additional guide on what input the user should prodive.

None optional bool

whether this input field may be empty when the user submits e.g. the modal.

False Throws

InvalidUsageError: when any of the provided arguments fail validation.

slackblocksJSONSlack UI
from slackblocks import InputBlock, Text, TextType, PlainTextInput\n\nInputBlock(\n    label=Text(\"Label\", type_=TextType.PLAINTEXT, emoji=True),\n    hint=Text(\"Hint\", type_=TextType.PLAINTEXT, emoji=True),\n    element=PlainTextInput(action_id=\"action\"),\n    block_id=\"fake_block_id\",\n    optional=True,\n)\n
{\n    \"type\": \"input\",\n    \"block_id\": \"fake_block_id\",\n    \"label\": {\n        \"type\": \"plain_text\",\n        \"text\": \"Label\",\n        \"emoji\": true\n    },\n    \"element\": {\n        \"type\": \"plain_text_input\",\n        \"action_id\": \"action\"\n    },\n    \"hint\": {\n        \"type\": \"plain_text\",\n        \"text\": \"Hint\",\n        \"emoji\": true\n    },\n    \"optional\": true\n}\n

"},{"location":"usage/using_blocks/#divider-block","title":"Divider Block","text":"

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

Parameters:

Name Type Description Default block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None slackblocksJSONSlack UI
from slackblocks import DividerBlock\n\nDividerBlock()\n
{\n    \"type\": \"divider\"\n}\n

"},{"location":"usage/using_blocks/#file-block","title":"File Block","text":"

Displays a remote file (e.g. a PDF).

For details on how remote files are exposed to Slack, see https://api.slack.com/messaging/files#adding.

Parameters:

Name Type Description Default external_id str

the ID assigned to the remote file when it was added to Slack.

required block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

required source str

always \"remote\" as per the Slack API (may change in the future).

'remote' slackblocksJSONSlack UI
from slackblocks import FileBlock\n\nFileBlock(\n    external_id=\"external_id\",\n    block_id=\"fake_block_id\",\n)\n
{\n    \"type\": \"file\",\n    \"external_id\": \"external_id\",\n    \"source\": \"remote\",\n    \"block_id\": \"fake_block_id\"\n}\n

* Note that this example comes from the Slack Web API docs.

"},{"location":"usage/using_blocks/#context-block","title":"Context Block","text":"

A ContextBlock displays contextul message info, including both images and text.

Parameters:

Name Type Description Default elements Optional[List[Union[Element, CompositionObject]]]

a list of Text objects and Image elements.

None block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None Throws

InvalidUsageError: when items in elements are not Text or Image or exceed 10 items.

slackblocksJSONSlack UI
from slackblocks import ContextBlock, Text\n\nContextBlock(\n    elements=[\n        Text(\"Hello, world!\"),\n    ], \n    block_id=\"fake_block_id\"\n)\n
{\n    \"type\": \"context\",\n    \"block_id\": \"fake_block_id\",\n    \"elements\": [\n        {\n            \"type\": \"mrkdwn\",\n            \"text\": \"Hello, world!\"\n        }\n    ]\n}\n

"},{"location":"usage/using_blocks/#actions-block","title":"Actions Block","text":"

A Block that is used to hold interactive elements (normally for users to interface with).

Parameters:

Name Type Description Default elements Optional[List[Element]]

a list of Elements (up to a maximum of 25).

None block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None Throws

InvalidUsageError: if any of the items in elements are invalid.

slackblocksJSONSlack UI
ActionsBlock(\n    block_id=\"fake_block_id\",\n    elements=CheckboxGroup(\n        action_id=\"actionId-0\",\n        options=[\n            Option(text=\"*a*\", value=\"a\", description=\"*a*\"),\n            Option(text=\"*b*\", value=\"b\", description=\"*b*\"),\n            Option(text=\"*c*\", value=\"c\", description=\"*c*\"),\n        ],\n    ),\n)\n
{\n    \"type\": \"actions\",\n    \"block_id\": \"fake_block_id\",\n    \"elements\": [\n        {\n            \"type\": \"checkboxes\",\n            \"action_id\": \"actionId-0\",\n            \"options\": [\n                {\n                    \"text\": {\n                        \"type\": \"mrkdwn\",\n                        \"text\": \"*a*\"\n                    },\n                    \"value\": \"a\",\n                    \"description\": {\n                        \"type\": \"plain_text\",\n                        \"text\": \"*a*\"\n                    }\n                },\n                {\n                    \"text\": {\n                        \"type\": \"mrkdwn\",\n                        \"text\": \"*b*\"\n                    },\n                    \"value\": \"b\",\n                    \"description\": {\n                        \"type\": \"plain_text\",\n                        \"text\": \"*b*\"\n                    }\n                },\n                {\n                    \"text\": {\n                        \"type\": \"mrkdwn\",\n                        \"text\": \"*c*\"\n                    },\n                    \"value\": \"c\",\n                    \"description\": {\n                        \"type\": \"plain_text\",\n                        \"text\": \"*c*\"\n                    }\n                }\n            ]\n        }\n    ]\n}\n

"}]} \ No newline at end of file +{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Welcome to slackblocks!","text":"

slackblocks is Python package for creating complex Slack messages using the Slack BlockKit API.

It exists so you don't have to define block-based Slack messages by hand-writing JSON.

"},{"location":"#components","title":"Components","text":"

The Slack BlockKit API defines a number of different resource types (all defined in JSON) which work together to define Block-based messages.

slackblocks makes using this API easier by providing a hierarchy of Python classes that represent these resources.

"},{"location":"#objects","title":"Objects","text":"

Objects (e.g. Text) are the lowest level pimitives that are used to populate Elements and Blocks.

"},{"location":"#elements","title":"Elements","text":"

Elements are typically interactive UI elements that take in Object to define their content. For example, the CheckboxGroup element takes in one or more Option items and presents a checkbox menu to the user with those options.

"},{"location":"#blocks","title":"Blocks","text":"

Blocks are the core element of the API, with different Blocks used to create different types of visual elements. For example, the DividerBlock, when rendered, will show a visual element similar to a <hr> HTML element. The RichTextBlock on the other hand allows for the display of text elements with visual styling like italics, block quotes, lists and code blocks.

"},{"location":"#messages","title":"Messages","text":"

Messages are a convenience wrapper around Blocks that can be unpacked as arguments straight into the official Slack Python SDK (or its legacy slackclient counterpart).

"},{"location":"#views","title":"Views","text":"

Views are an alternative usage for Blocks that allow for the creation of custom UI \"surfaces\" within Slack, e.g. for third-party apps.

"},{"location":"#guides","title":"Guides","text":"

In addition to a complete reference of all classes and functions provided by the slackblocks library, this documentation contains guides on:

  • Installing slackblocks
  • Using Blocks
  • Sending Block-based Messages
"},{"location":"reference/attachments/","title":"Attachments","text":"

Warning: Deprecated Feature

Attachments, while still accepted by the Slack API, have long (for years now) been considered a deprecated feature.

That said, there is currently no other way to achieve the vertical, colored bars next to content.

Secondary (less important) content can be attached using the deprecated attachments API.

See: https://api.slack.com/slackblocks/latest/reference/messaging/attachments.

"},{"location":"reference/attachments/#attachments.Attachment","title":"Attachment","text":"

Lower priority content can be attached to messages using Attachments. This is content that doesn't necessarily need to be seen to appreciate the intent of the message, but perhaps adds further context or additional information.

See https://api.slack.com/reference/messaging/attachments.

N.B: fields is a deprecated field, included only for legacy purposes. Other legacy fields, e.g. author_name are deliberately omitted as they were never implemented in slackblocks.

Parameters:

Name Type Description Default blocks Optional[Union[Block, List[Block]]]

an array of Blocks that define the content of the attachment.

None color Optional[Union[str, Color]]

the color (in hex format, e.g. #ffffff) of the vertical bar to the left of the attachment content. Consider using the Color enum from this module.

None fields Optional[Union[Field, List[Field]]]

a list of Field objects to be included in what's rendered in the attachment.

None Throws

InvalidUsageError: if the color code provided is invalid.

Source code in slackblocks/attachments.py
class Attachment:\n    \"\"\"\n    Lower priority content can be attached to messages using Attachments.\n    This is content that doesn't necessarily need to be seen to appreciate\n    the intent of the message, but perhaps adds further context or additional information.\n\n    See <https://api.slack.com/reference/messaging/attachments>.\n\n    N.B: `fields` is a deprecated field, included only for legacy purposes. Other legacy\n    fields, e.g. `author_name` are deliberately omitted as they were never implemented in\n    `slackblocks`.\n\n    Args:\n        blocks: an array of Blocks that define the content of the attachment.\n        color: the color (in hex format, e.g. #ffffff) of the vertical bar to the left of the\n            attachment content. Consider using the `Color` enum from this module.\n        fields: a list of `Field` objects to be included in what's rendered in the attachment.\n\n    Throws:\n        InvalidUsageError: if the `color` code provided is invalid.\n    \"\"\"\n\n    def __init__(\n        self,\n        blocks: Optional[Union[Block, List[Block]]] = None,\n        color: Optional[Union[str, Color]] = None,\n        fields: Optional[Union[Field, List[Field]]] = None,\n    ):\n        self.blocks = coerce_to_list(blocks, Block, allow_none=True)\n        self.fields = coerce_to_list(fields, Field, allow_none=True)\n        if type(color) is Color:\n            self.color = color.value\n        elif type(color) is str:\n            if len(color) == 7 and color.startswith(\"#\") and is_hex(color[1:]):\n                self.color = color\n            elif len(color) == 6 and is_hex(color):\n                self.color = f\"#{color}\"\n            else:\n                raise InvalidUsageError(\n                    \"Color must be a valid hex code (e.g. `#ffffff`)\"\n                )\n        else:\n            self.color = None\n\n    def _resolve(self) -> Dict[str, Any]:\n        attachment = dict()\n        if self.blocks:\n            attachment[\"blocks\"] = [block._resolve() for block in self.blocks]\n        if self.color:\n            attachment[\"color\"] = self.color\n        return attachment\n\n    def __repr__(self) -> str:\n        return dumps(self._resolve(), indent=4)\n
"},{"location":"reference/attachments/#attachments.Color","title":"Color","text":"

Color is a utility class for use with the Slack secondary attachments API.

Pass these to the color argument of Attachment.

Color.GOOD Color.WARNING Color.DANGER Color.RED Color.BLUE Color.YELLOW Color.GREEN Color.ORANGE Color.PURPLE Color.BLACK Source code in slackblocks/attachments.py
class Color(Enum):\n    \"\"\"\n    Color is a utility class for use with the Slack secondary attachments API.\n\n    Pass these to the `color` argument of\n        [`Attachment`](/slackblocks/latest/reference/attachments/#attachments.Attachment).\n\n    <table style=\"width:50%\">\n    <tr>\n    <td><code>Color.GOOD</code></td>\n    <td>\n    <img valign='middle' alt='good' src='https://readme-swatches.vercel.app/4CAF50?style=round'/>\n    </td>\n    </tr>\n    <tr>\n    <td><code>Color.WARNING</code></td>\n    <td>\n    <img valign='middle' alt='warning' src='https://readme-swatches.vercel.app/FFEB3B?style=round'/>\n    </td>\n    </tr>\n    <tr>\n    <td><code>Color.DANGER</code></td>\n    <td>\n    <img valign='middle' alt='danger' src='https://readme-swatches.vercel.app/F44336?style=round'/>\n    </td>\n    </tr>\n    <tr>\n    <td><code>Color.RED</code></td>\n    <td>\n    <img valign='middle' alt='red' src='https://readme-swatches.vercel.app/ff0000?style=round'/>\n    </td>\n    </tr>\n    <tr>\n    <td><code>Color.BLUE</code></td>\n    <td>\n    <img valign='middle' alt='blue' src='https://readme-swatches.vercel.app/0000ff?style=round'/>\n    </td>\n    </tr>\n    <tr>\n    <td><code>Color.YELLOW</code></td>\n    <td>\n    <img valign='middle' alt='yellow' src='https://readme-swatches.vercel.app/ffff00?style=round'/>\n    </td>\n    </tr>\n    <tr>\n    <td><code>Color.GREEN</code></td>\n    <td>\n    <img valign='middle' alt='green' src='https://readme-swatches.vercel.app/00ff00?style=round'/>\n    </td>\n    </tr>\n    <tr>\n    <td><code>Color.ORANGE</code></td>\n    <td>\n    <img valign='middle' alt='orange' src='https://readme-swatches.vercel.app/ff8800?style=round'/>\n    </td>\n    </tr>\n    <tr>\n    <td><code>Color.PURPLE</code></td>\n    <td>\n    <img valign='middle' alt='purple' src='https://readme-swatches.vercel.app/8800ff?style=round'/>\n    </td>\n    </tr>\n    <tr>\n    <td><code>Color.BLACK</code></td>\n    <td>\n    <img valign='middle' alt='black' src='https://readme-swatches.vercel.app/000000?style=round'/>\n    </td>\n    </tr>\n    </table>\n    \"\"\"\n\n    GOOD = \"good\"\n    WARNING = \"warning\"\n    DANGER = \"danger\"\n    RED = \"#ff0000\"\n    BLUE = \"#0000ff\"\n    YELLOW = \"#ffff00\"\n    GREEN = \"#00ff00\"\n    ORANGE = \"#ff8800\"\n    PURPLE = \"#8800ff\"\n    BLACK = \"#000000\"\n\n    def __repr__(self) -> str:\n        return f\"<slackblocks Color {self.name}: {self.value}>\"\n
"},{"location":"reference/attachments/#attachments.Field","title":"Field","text":"

Field text objects for use with Slack's secondary attachment API.

See https://api.slack.com/reference/messaging/attachments#fields.

Parameters:

Name Type Description Default title Optional[str]

text shown as a bold heading on the field.

None value Optional[str]

text (mrkdwn or plaintext) representing the value of the field.

None short Optional[bool]

whether the contents of the field is short enough to be presented in multipe columns.

False Source code in slackblocks/attachments.py
class Field:\n    \"\"\"\n    Field text objects for use with Slack's secondary attachment API.\n\n    See <https://api.slack.com/reference/messaging/attachments#fields>.\n\n    Args:\n        title: text shown as a bold heading on the field.\n        value: text (`mrkdwn` or `plaintext`) representing the value of the field.\n        short: whether the contents of the field is short enough to be presented in\n            multipe columns.\n    \"\"\"\n\n    def __init__(\n        self,\n        title: Optional[str] = None,\n        value: Optional[str] = None,\n        short: Optional[bool] = False,\n    ):\n        self.title = title\n        self.value = value\n        self.short = short\n\n    def _resolve(self):\n        field = dict()\n        field[\"short\"] = self.short\n        if self.title:\n            field[\"title\"] = self.title\n        if self.value:\n            field[\"value\"] = self.value\n        return dumps(field)\n
"},{"location":"reference/blocks/","title":"Blocks","text":"

Blocks are a series of container components that can be combined to create rich and interactive messages.

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

"},{"location":"reference/blocks/#blocks.ActionsBlock","title":"ActionsBlock","text":"

A Block that is used to hold interactive elements (normally for users to interface with).

Parameters:

Name Type Description Default elements Optional[List[Element]]

a list of Elements (up to a maximum of 25).

None block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None Throws

InvalidUsageError: if any of the items in elements are invalid.

Source code in slackblocks/blocks.py
class ActionsBlock(Block):\n    \"\"\"\n    A `Block` that is used to hold interactive elements (normally for users to interface with).\n\n    Args:\n        elements: a list of [Elements](/slackblocks/latest/reference/elements)\n            (up to a maximum of 25).\n        block_id: you can use this field to provide a deterministic identifier for the block.\n\n    Throws:\n        InvalidUsageError: if any of the items in `elements` are invalid.\n    \"\"\"\n\n    def __init__(\n        self,\n        elements: Optional[List[Element]] = None,\n        block_id: Optional[str] = None,\n    ) -> \"ActionsBlock\":\n        super().__init__(type_=BlockType.ACTIONS, block_id=block_id)\n        self.elements = coerce_to_list(\n            elements, (Element), allow_none=True, max_size=25\n        )\n\n    def _resolve(self):\n        actions = self._attributes()\n        actions[\"elements\"] = [element._resolve() for element in self.elements]\n        return actions\n
"},{"location":"reference/blocks/#blocks.ContextBlock","title":"ContextBlock","text":"

A ContextBlock displays contextul message info, including both images and text.

Parameters:

Name Type Description Default elements Optional[List[Union[Element, CompositionObject]]]

a list of Text objects and Image elements.

None block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None Throws

InvalidUsageError: when items in elements are not Text or Image or exceed 10 items.

Source code in slackblocks/blocks.py
class ContextBlock(Block):\n    \"\"\"\n    A `ContextBlock` displays contextul message info, including both images and text.\n\n    Args:\n        elements: a list of `Text` objects and `Image` elements.\n        block_id: you can use this field to provide a deterministic identifier for the block.\n\n    Throws:\n        InvalidUsageError: when items in `elements` are not `Text` or `Image` or exceed 10 items.\n    \"\"\"\n\n    def __init__(\n        self,\n        elements: Optional[List[Union[Element, CompositionObject]]] = None,\n        block_id: Optional[str] = None,\n    ) -> \"ContextBlock\":\n        super().__init__(type_=BlockType.CONTEXT, block_id=block_id)\n        self.elements = []\n        for element in elements:\n            if (\n                element.type == CompositionObjectType.TEXT\n                or element.type == ElementType.IMAGE\n            ):\n                self.elements.append(element)\n            else:\n                raise InvalidUsageError(\n                    f\"Context blocks can only hold image and text elements, not {element.type}\"\n                )\n        if len(self.elements) > 10:\n            raise InvalidUsageError(\"Context blocks can hold a maximum of ten elements\")\n\n    def _resolve(self) -> Dict[str, any]:\n        context = self._attributes()\n        context[\"elements\"] = [element._resolve() for element in self.elements]\n        return context\n
"},{"location":"reference/blocks/#blocks.DividerBlock","title":"DividerBlock","text":"

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

Parameters:

Name Type Description Default block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None Source code in slackblocks/blocks.py
class DividerBlock(Block):\n    \"\"\"\n    A content divider, like an `<hr>` in HTML, to split up different blocks inside of\n    a message.\n\n    Args:\n        block_id: you can use this field to provide a deterministic identifier for the block.\n    \"\"\"\n\n    def __init__(self, block_id: Optional[str] = None) -> \"DividerBlock\":\n        super().__init__(type_=BlockType.DIVIDER, block_id=block_id)\n\n    def _resolve(self):\n        return self._attributes()\n
"},{"location":"reference/blocks/#blocks.FileBlock","title":"FileBlock","text":"

Displays a remote file (e.g. a PDF).

For details on how remote files are exposed to Slack, see https://api.slack.com/messaging/files#adding.

Parameters:

Name Type Description Default external_id str

the ID assigned to the remote file when it was added to Slack.

required block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

required source str

always \"remote\" as per the Slack API (may change in the future).

'remote' Source code in slackblocks/blocks.py
class FileBlock(Block):\n    \"\"\"\n    Displays a remote file (e.g. a PDF).\n\n    For details on how remote files are exposed to Slack, see\n    <https://api.slack.com/messaging/files#adding>.\n\n    Args:\n        external_id: the ID assigned to the remote file when it was added to Slack.\n        block_id: you can use this field to provide a deterministic identifier for the block.\n        source: always \"remote\" as per the Slack API (may change in the future).\n    \"\"\"\n\n    def __init__(\n        self, external_id: str, block_id: Optional[str], source: str = \"remote\"\n    ) -> \"FileBlock\":\n        super().__init__(type_=BlockType.FILE, block_id=block_id)\n        self.external_id = external_id\n        self.source = source\n\n    def _resolve(self) -> Dict[str, any]:\n        file = self._attributes()\n        file[\"external_id\"] = self.external_id\n        file[\"source\"] = self.source\n        return file\n
"},{"location":"reference/blocks/#blocks.HeaderBlock","title":"HeaderBlock","text":"

A Header Block is a plain-text block that displays in a larger, bold font.

Parameters:

Name Type Description Default text Union[str, Text]

the text that will be rendered as a heading.

required block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None Source code in slackblocks/blocks.py
class HeaderBlock(Block):\n    \"\"\"\n    A Header Block is a plain-text block that displays in a larger, bold font.\n\n    Args:\n        text: the text that will be rendered as a heading.\n        block_id: you can use this field to provide a deterministic identifier for the block.\n    \"\"\"\n\n    def __init__(\n        self, text: Union[str, Text], block_id: Optional[str] = None\n    ) -> \"HeaderBlock\":\n        super().__init__(type_=BlockType.HEADER, block_id=block_id)\n        if type(text) is Text:\n            self.text = text\n        else:\n            self.text = Text(text, type_=TextType.PLAINTEXT, verbatim=False)\n\n    def _resolve(self) -> Dict[str, any]:\n        header = self._attributes()\n        header[\"text\"] = self.text._resolve()\n        return header\n
"},{"location":"reference/blocks/#blocks.ImageBlock","title":"ImageBlock","text":"

An Image Block contains a single graphic, accessed by URL.

Parameters:

Name Type Description Default image_url str

the URL pointing to the image file you want to display.

required alt_text Optional[str]

alternative text for accessibility purposes and when the image fails to load.

' ' title Optional[Union[Text, str]]

an optional text title to be presented with the image.

None block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None Throws

InvalidUsageError: when one or more of the provided args fails validation.

Source code in slackblocks/blocks.py
class ImageBlock(Block):\n    \"\"\"\n    An Image Block contains a single graphic, accessed by URL.\n\n    Args:\n        image_url: the URL pointing to the image file you want to display.\n        alt_text: alternative text for accessibility purposes and when the image fails to load.\n        title: an optional text title to be presented with the image.\n        block_id: you can use this field to provide a deterministic identifier for the block.\n\n    Throws:\n        InvalidUsageError: when one or more of the provided args fails validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        image_url: str,\n        alt_text: Optional[str] = \" \",\n        title: Optional[Union[Text, str]] = None,\n        block_id: Optional[str] = None,\n    ) -> \"ImageBlock\":\n        super().__init__(type_=BlockType.IMAGE, block_id=block_id)\n        self.image_url = validate_string(\n            string=image_url,\n            field_name=\"title\",\n            max_length=3000,\n        )\n        self.alt_text = validate_string(\n            alt_text, field_name=\"alt_text\", max_length=2000\n        )\n        if title and isinstance(title, Text):\n            if title.text_type == TextType.MARKDOWN:\n                # Coerce title into plaintext\n                self.title = Text(\n                    text=title.text,\n                    type_=TextType.PLAINTEXT,\n                    emoji=title.emoji,\n                    verbatim=title.verbatim,\n                )\n            else:\n                self.title = title\n        elif isinstance(title, str):\n            self.title = Text(text=title, type_=TextType.PLAINTEXT)\n\n    def _resolve(self) -> Dict[str, Any]:\n        image = self._attributes()\n        image[\"image_url\"] = self.image_url\n        if self.alt_text:\n            image[\"alt_text\"] = self.alt_text\n        if self.title:\n            image[\"title\"] = self.title._resolve()\n        return image\n
"},{"location":"reference/blocks/#blocks.InputBlock","title":"InputBlock","text":"

A block that collects information from users - it can hold a plain-text input element, a checkbox element, a radio button element, a select menu element, a multi-select menu element, or a datepicker.

Parameters:

Name Type Description Default label TextLike

the name which identifies the input field.

required element Element

an interactive Element (e.g. a text field).

required dispatch_action bool

whether the Element should trigger the sending of a block_actions payload.

False block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None hint Optional[TextLike]

an optional additional guide on what input the user should prodive.

None optional bool

whether this input field may be empty when the user submits e.g. the modal.

False Throws

InvalidUsageError: when any of the provided arguments fail validation.

Source code in slackblocks/blocks.py
class InputBlock(Block):\n    \"\"\"\n    A block that collects information from users - it can hold a plain-text\n    input element, a checkbox element, a radio button element, a select\n    menu element, a multi-select menu element, or a datepicker.\n\n    Args:\n        label: the name which identifies the input field.\n        element: an interactive [Element](/slackblocks/latest/reference/elements)\n            (e.g. a text field).\n        dispatch_action: whether the [Element](/slackblocks/latest/reference/elements)\n            should trigger the sending of a `block_actions` payload.\n        block_id: you can use this field to provide a deterministic identifier for the block.\n        hint: an optional additional guide on what input the user should prodive.\n        optional: whether this input field may be empty when the user submits e.g. the modal.\n\n    Throws:\n        InvalidUsageError: when any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        label: TextLike,\n        element: Element,\n        dispatch_action: bool = False,\n        block_id: Optional[str] = None,\n        hint: Optional[TextLike] = None,\n        optional: bool = False,\n    ) -> \"InputBlock\":\n        super().__init__(type_=BlockType.INPUT, block_id=block_id)\n        self.label = Text.to_text(\n            label, force_plaintext=True, max_length=2000, allow_none=False\n        )\n        if not isinstance(element, ALLOWED_INPUT_ELEMENTS):\n            raise InvalidUsageError(\"\")\n        self.element = element\n        self.dispatch_action = dispatch_action\n        self.hint = Text.to_text(\n            hint, force_plaintext=True, max_length=2000, allow_none=True\n        )\n        self.optional = optional\n\n    def _resolve(self) -> Dict[str, Any]:\n        input_block = self._attributes()\n        input_block[\"label\"] = self.label._resolve()\n        input_block[\"element\"] = self.element._resolve()\n        if self.hint:\n            input_block[\"hint\"] = self.hint._resolve()\n        if self.dispatch_action:\n            input_block[\"dispatch_action\"] = self.dispatch_action\n        if self.optional:\n            input_block[\"optional\"] = self.optional\n        return input_block\n
"},{"location":"reference/blocks/#blocks.RichTextBlock","title":"RichTextBlock","text":"

A RichTextBlock is used to provide easier rich text formatting than standard markdown text (e.g. in a SectionBlock) and access to text formatting features not available in traditional markdown (e.g. strikethrough). See the various rich text elements you can include here.

Parameters:

Name Type Description Default elements Union[RichTextObject, List[RichTextObject]]

a single rich text element or a list of those elements.

required block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None Throws

InvalidUsageError: if the elements in elements are not valid rich text elements.

Source code in slackblocks/blocks.py
class RichTextBlock(Block):\n    \"\"\"\n    A RichTextBlock is used to provide easier rich text formatting\n        than standard markdown text (e.g. in a\n        [`SectionBlock`](/slackblocks/latest/reference/blocks/#blocks.SectionBlock))\n        and access to text formatting features not available in traditional\n        markdown (e.g. strikethrough). See the various rich text elements\n        you can include [here](/slackblocks/latest/reference/rich_text).\n\n    Args:\n        elements: a single [rich text element](rich_text)\n            or a list of those elements.\n        block_id: you can use this field to provide a deterministic identifier\n            for the block.\n\n    Throws:\n        InvalidUsageError: if the elements in `elements` are not valid rich\n            text elements.\n    \"\"\"\n\n    def __init__(\n        self,\n        elements: Union[RichTextObject, List[RichTextObject]],\n        block_id: Optional[str] = None,\n    ) -> \"RichTextBlock\":\n        super().__init__(type_=BlockType.RICH_TEXT, block_id=block_id)\n        self.elements = coerce_to_list(\n            elements,\n            (\n                RichTextList,\n                RichTextCodeBlock,\n                RichTextQuote,\n                RichTextSection,\n            ),\n            min_size=1,\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        rich_text_block = self._attributes()\n        rich_text_block[\"elements\"] = [element._resolve() for element in self.elements]\n        return rich_text_block\n
"},{"location":"reference/blocks/#blocks.SectionBlock","title":"SectionBlock","text":"

A section is one of the most flexible blocks available - it can be used as a simple text block, or with any of the available block elements.

Section blocks can also optionally be given an \"accessory,\" which is typically one of the interactive Elements.

Parameters:

Name Type Description Default text Optional[TextLike]

text to include in the block. Can be a string or Text object (of either mrkdwn or plaintext variety). Defaults to markdown if unspecified. One of either text or fields must be provided.

None block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None fields Optional[Union[TextLike, List[TextLike]]]

a list of text objects. One of either text or fields must be provided.

None accessory Optional[Element]

an optional Element object that will take a secondary place in the block (after or to the side of text or fields).

None Throws

InvalidUsageError: if any of the provided arguments fail validation checks.

Source code in slackblocks/blocks.py
class SectionBlock(Block):\n    \"\"\"\n    A section is one of the most flexible blocks available -\n    it can be used as a simple text block, or with any of the\n    available block elements.\n\n    Section blocks can also optionally be given an \"accessory,\"\n    which is typically one of the interactive\n    [Elements](/slackblocks/latest/reference/elements).\n\n    Args:\n        text: text to include in the block. Can be a string or `Text` object (of either\n            `mrkdwn` or `plaintext` variety). Defaults to markdown if unspecified. One of either\n            `text` or `fields` must be provided.\n        block_id: you can use this field to provide a deterministic identifier for the block.\n        fields: a list of text objects. One of either `text` or `fields` must be provided.\n        accessory: an optional [Element](/slackblocks/latest/reference/elements) object that\n            will take a secondary place in the block (after or to the side of  `text` or\n            `fields`).\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation checks.\n    \"\"\"\n\n    def __init__(\n        self,\n        text: Optional[TextLike] = None,\n        block_id: Optional[str] = None,\n        fields: Optional[Union[TextLike, List[TextLike]]] = None,\n        accessory: Optional[Element] = None,\n    ) -> \"SectionBlock\":\n        super().__init__(type_=BlockType.SECTION, block_id=block_id)\n        if not text and not fields:\n            raise InvalidUsageError(\n                \"Must supply either `text` or `fields` or `both` to SectionBlock.\"\n            )\n        self.text = Text.to_text(text, max_length=3000, allow_none=True)\n        self.fields = coerce_to_list(\n            (\n                [\n                    Text.to_text(field, max_length=2000, allow_none=False)\n                    for field in coerce_to_list(\n                        fields, class_=(str, Text), allow_none=True\n                    )\n                ]\n                if fields\n                else None\n            ),\n            class_=Text,\n            allow_none=True,\n            max_size=10,\n        )\n\n        self.accessory = accessory\n\n    def _resolve(self) -> Dict[str, Any]:\n        section = self._attributes()\n        if self.text:\n            section[\"text\"] = self.text._resolve()\n        if self.fields:\n            section[\"fields\"] = [field._resolve() for field in self.fields]\n        if self.accessory:\n            section[\"accessory\"] = self.accessory._resolve()\n        return section\n
"},{"location":"reference/elements/","title":"Elements","text":"

Block elements can be used inside of section, context, input, and actions layout blocks.

See: https://api.slack.com/reference/block-kit/block-elements

"},{"location":"reference/elements/#elements.Button","title":"Button","text":"

An interactive element that inserts a button. The button can be a trigger for anything from opening a simple link to starting a complex workflow.

See: https://api.slack.com/reference/block-kit/block-elements#button.

Parameters:

Name Type Description Default text TextLike

text on the button (plaintext only; max 75 chars).

required action_id str

an identifier so the source of the action can be known.

required url Optional[str]

a URL to load in the user's browser when the button is clicked.

None value Optional[str]

the value sent with the interaction payload.

None style Optional[str]

the visual style of the button, one of primary, danger.

None confirm Optional[ConfirmationDialogue]

a ConfirmationDialogue object that will be presented when the button is clicked.

None accessibility_label Optional[str]

a string label for longer descriptive text about a button element. Used by screen readers (max 75 chars).

None

Throws: InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class Button(Element):\n    \"\"\"\n    An interactive element that inserts a button. The button can be a\n    trigger for anything from opening a simple link to starting a complex\n    workflow.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#button>.\n\n    Args:\n        text: text on the button (plaintext only; max 75 chars).\n        action_id: an identifier so the source of the action can be known.\n        url: a URL to load in the user's browser when the button is clicked.\n        value: the value sent with the interaction payload.\n        style: the visual style of the button, one of `primary`, `danger`.\n        confirm: a `ConfirmationDialogue` object that will be presented when\n            the button is clicked.\n        accessibility_label: a string label for longer descriptive text about\n            a button element. Used by screen readers (max 75 chars).\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        text: TextLike,\n        action_id: str,\n        url: Optional[str] = None,\n        value: Optional[str] = None,\n        style: Optional[str] = None,\n        confirm: Optional[ConfirmationDialogue] = None,\n        accessibility_label: Optional[str] = None,\n    ) -> \"Button\":\n        super().__init__(type_=ElementType.BUTTON)\n        self.text = Text.to_text(text, max_length=75, force_plaintext=True)\n        self.action_id = validate_action_id(action_id)\n        self.url = validate_string(\n            url, field_name=\"url\", max_length=3000, allow_none=True\n        )\n        self.value = validate_string(\n            value,\n            field_name=\"value\",\n            max_length=2000,\n            allow_none=True,\n        )\n        self.style = style.value if isinstance(style, ButtonStyle) else style\n        self.confirm = confirm\n        self.accessibility_label = validate_string(\n            accessibility_label,\n            \"accessibility_label\",\n            max_length=75,\n            allow_none=True,\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        button = self._attributes()\n        button[\"text\"] = self.text._resolve()\n        button[\"action_id\"] = self.action_id\n        if self.style:\n            button[\"style\"] = self.style\n        if self.url:\n            button[\"url\"] = self.url\n        if self.value:\n            button[\"value\"] = self.value\n        if self.confirm:\n            button[\"confirm\"] = self.confirm._resolve()\n        if self.accessibility_label:\n            button[\"accessibility_label\"] = self.accessibility_label\n        return button\n
"},{"location":"reference/elements/#elements.ButtonStyle","title":"ButtonStyle","text":"

Utility class for determining the style of Buttons and WorkflowButtons.

Source code in slackblocks/elements.py
class ButtonStyle(Enum):\n    \"\"\"\n    Utility class for determining the style of `Buttons` and `WorkflowButtons`.\n    \"\"\"\n\n    DEFAULT = None\n    PRIMARY = \"primary\"\n    DANGER = \"danger\"\n\n    @staticmethod\n    def to_button_style(style: Optional[Union[\"ButtonStyle\", str]]) -> \"ButtonStyle\":\n        if isinstance(style, ButtonStyle):\n            return style\n        if isinstance(style, (str, None)):\n            return ButtonStyle[style]\n        raise InvalidUsageError(\n            f\"Can only coerce to ButtonStyle from ButtonStyle or string, not {type(style)}.\"\n        )\n
"},{"location":"reference/elements/#elements.ChannelMultiSelectMenu","title":"ChannelMultiSelectMenu","text":"

This interactive UI element allows users to select multiple channels visible to the current user in the active workspace.

See: https://api.slack.com/reference/block-kit/block-elements#channel_multi_select.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_channels Optional[List[str]]

a list of conversation IDs as strings that will already be selected when the menu renders.

None confirm ConfirmationDialogue

a ConfirmationDialogue object that will be presented when the menu is used.

None max_selected_items Optional[int]

the maximum number of items that can be selected in the menu.

None focus_on_load bool

whether or not the menu will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the menu when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class ChannelMultiSelectMenu(Element):\n    \"\"\"\n    This interactive UI element allows users to select multiple channels visible\n        to the current user in the active workspace.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#channel_multi_select>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_channels: a list of conversation IDs as strings that will\n            already be selected when the menu renders.\n        confirm: a `ConfirmationDialogue` object that will be presented when\n            the menu is used.\n        max_selected_items: the maximum number of items that can be selected\n            in the menu.\n        focus_on_load: whether or not the menu will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the menu when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_channels: Optional[List[str]] = None,\n        confirm: ConfirmationDialogue = None,\n        max_selected_items: Optional[int] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.MULTI_SELECT_CHANNELS)\n        self.action_id = validate_action_id(action_id)\n        self.initial_channels = coerce_to_list(\n            initial_channels, class_=str, allow_none=True\n        )\n        self.confirm = confirm\n        self.max_selected_items = max_selected_items\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, force_plaintext=True, max_length=150, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        channel_multi_select = self._attributes()\n        channel_multi_select[\"action_id\"] = self.action_id\n        if self.initial_channels:\n            channel_multi_select[\"initial_channels\"] = [\n                initial_option._resolve() for initial_option in self.initial_channels\n            ]\n        if self.confirm:\n            channel_multi_select[\"confirm\"] = self.confirm._resolve()\n        if self.max_selected_items:\n            channel_multi_select[\"max_selected_items\"] = self.max_selected_items\n        if self.focus_on_load:\n            channel_multi_select[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            channel_multi_select[\"placeholder\"] = self.placeholder._resolve()\n        return channel_multi_select\n
"},{"location":"reference/elements/#elements.ChannelSelectMenu","title":"ChannelSelectMenu","text":"

A select menu interactive UI element, sourced with a list of public channels visible to the current user.

See: https://api.slack.com/reference/block-kit/block-elements#channels_select.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_channel Optional[str]

the single (string) user ID that will be initially selected when first presented to the user.

None confirm Optional[ConfirmationDialogue]

a ConfirmationDialogue object that will be presented when an option in the overflow menu is selected.

None response_url_enabled Optional[bool]

When set to true, the view_submission payload from the menu's parent view will contain a response_url. (This response_url can be used for message responses).

False focus_on_load bool

whether or not the input will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the input when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class ChannelSelectMenu(Element):\n    \"\"\"\n    A select menu interactive UI element, sourced with a list of public channels visible\n        to the current user.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#channels_select>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_channel: the single (string) user ID that will be initially selected\n            when first presented to the user.\n        confirm: a `ConfirmationDialogue` object that will be presented when an\n            option in the overflow menu is selected.\n        response_url_enabled: When set to true, the view_submission payload from the\n            menu's parent view will contain a response_url. (This response_url can be\n            used for message responses).\n        focus_on_load: whether or not the input will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the input when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_channel: Optional[str] = None,\n        confirm: Optional[ConfirmationDialogue] = None,\n        response_url_enabled: Optional[bool] = False,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.CHANNELS_SELECT_MENU)\n        self.action_id = validate_action_id(action_id)\n        self.initial_channel = initial_channel\n        self.confirm = confirm\n        self.response_url_enabled = response_url_enabled\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder,\n            max_length=150,\n            force_plaintext=True,\n            allow_none=True,\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        channel_select_menu = self._attributes()\n        channel_select_menu[\"action_id\"] = self.action_id\n        if self.initial_channel:\n            channel_select_menu[\"initial_channel\"] = self.initial_channel\n        if self.confirm:\n            channel_select_menu[\"confirm\"] = self.confirm._resolve()\n        if self.response_url_enabled:\n            channel_select_menu[\"response_url_enabled\"] = self.response_url_enabled\n        if self.focus_on_load:\n            channel_select_menu[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            channel_select_menu[\"placeholder\"] = self.placeholder._resolve()\n        return channel_select_menu\n
"},{"location":"reference/elements/#elements.CheckboxGroup","title":"CheckboxGroup","text":"

A checkbox group that allows a user to choose multiple items from a list of possible options.

See: https://api.slack.com/reference/block-kit/block-elements#checkboxes.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required options Union[Option, List[Option]]

a list of Option objects that will form the content of the checkbox group.

required initial_options Optional[Union[Option, List[Option]]]

a list of Option objects that will be initially selected when first presented to the user.

None confirm ConfirmationDialogue

a ConfirmationDialogue object that will be presented when the checkbox group is used.

None focus_on_load bool

whether or not the checkbox group will be set to autofocus within the view object.

False Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class CheckboxGroup(Element):\n    \"\"\"\n    A checkbox group that allows a user to choose multiple items from a list\n    of possible options.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#checkboxes>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        options: a list of\n            [`Option`](/slackblocks/latest/reference/objects/#objects.Option) objects that will\n            form the content of the checkbox group.\n        initial_options: a list of\n            [`Option`](/slackblocks/latest/reference/objects/#objects.Option) objects that will\n            be initially selected when first presented to the user.\n        confirm: a `ConfirmationDialogue` object that will be presented when\n            the checkbox group is used.\n        focus_on_load: whether or not the checkbox group will be set to autofocus\n            within the view object.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        options: Union[Option, List[Option]],\n        initial_options: Optional[Union[Option, List[Option]]] = None,\n        confirm: ConfirmationDialogue = None,\n        focus_on_load: bool = False,\n    ) -> \"CheckboxGroup\":\n        super().__init__(type_=ElementType.CHECKBOXES)\n        self.action_id = validate_action_id(action_id)\n        self.options = coerce_to_list(options, Option)\n        self.initial_options = coerce_to_list(initial_options, Option, allow_none=True)\n        self.confirm = confirm\n        self.focus_on_load = focus_on_load\n\n    def _resolve(self) -> Dict[str, Any]:\n        checkbox_group = self._attributes()\n        checkbox_group[\"action_id\"] = self.action_id\n        checkbox_group[\"options\"] = [option._resolve() for option in self.options]\n        if self.initial_options:\n            checkbox_group[\"initial_options\"] = [\n                option._resolve() for option in self.initial_options\n            ]\n        if self.confirm:\n            checkbox_group[\"confirm\"] = self.confirm._resolve()\n        if self.focus_on_load:\n            checkbox_group[\"focus_on_load\"] = self.focus_on_load\n        return checkbox_group\n
"},{"location":"reference/elements/#elements.ConversationMultiSelectMenu","title":"ConversationMultiSelectMenu","text":"

This interactive UI element allows users to select multiple conversations visible to the current user in the active workspace.

See: https://api.slack.com/reference/block-kit/block-elements#conversation_multi_select.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_conversations Optional[List[str]]

a list of conversation IDs as strings that will already be selected when the menu renders.

None default_to_current_conversation Optional[bool]

Pre-populates the select menu with the conversation that the user was viewing when they opened the modal (defaults to False).

False confirm ConfirmationDialogue

a ConfirmationDialogue object that will be presented when the menu is used.

None max_selected_items Optional[int]

the maximum number of items that can be selected in the menu.

None filter Optional[ConversationFilter]

a Filter object that filters out conversations that don't match the settings of the filter.

None focus_on_load Optional[bool]

whether or not the menu will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the menu when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class ConversationMultiSelectMenu(Element):\n    \"\"\"\n    This interactive UI element allows users to select multiple conversations visible\n        to the current user in the active workspace.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#conversation_multi_select>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_conversations: a list of conversation IDs as strings that will\n            already be selected when the menu renders.\n        default_to_current_conversation: Pre-populates the select menu with the\n            conversation that the user was viewing when they opened the modal\n            (defaults to `False`).\n        confirm: a `ConfirmationDialogue` object that will be presented when\n            the menu is used.\n        max_selected_items: the maximum number of items that can be selected\n            in the menu.\n        filter: a [`Filter`](/slackblocks/latest/reference/objects/#objects.ConversationFilter)\n            object that filters out conversations that don't match the settings\n            of the filter.\n        focus_on_load: whether or not the menu will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the menu when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_conversations: Optional[List[str]] = None,\n        default_to_current_conversation: Optional[bool] = False,\n        confirm: ConfirmationDialogue = None,\n        max_selected_items: Optional[int] = None,\n        filter: Optional[ConversationFilter] = None,\n        focus_on_load: Optional[bool] = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.MULTI_SELECT_CONVERSATIONS)\n        self.action_id = validate_action_id(action_id)\n        self.initial_conversations = coerce_to_list(\n            initial_conversations, str, allow_none=True\n        )\n        self.default_to_current_conversation = default_to_current_conversation\n        self.confirm = confirm\n        self.max_selected_items = max_selected_items\n        self.filter = filter\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, force_plaintext=True, max_length=150, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        conversation_multi_select = self._attributes()\n        conversation_multi_select[\"action_id\"] = self.action_id\n        if self.initial_conversations:\n            conversation_multi_select[\"intial_conversations\"] = (\n                self.initial_conversations\n            )\n        if self.default_to_current_conversation:\n            conversation_multi_select[\"default_to_current_conversation\"] = (\n                self.default_to_current_conversation\n            )\n        if self.confirm:\n            conversation_multi_select[\"confirm\"] = self.confirm._resolve()\n        if self.max_selected_items:\n            conversation_multi_select[\"max_selected_items\"] = self.max_selected_items\n        if self.filter:\n            conversation_multi_select[\"filter\"] = self.filter._resolve()\n        if self.focus_on_load:\n            conversation_multi_select[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            conversation_multi_select[\"placeholder\"] = self.placeholder._resolve()\n        return conversation_multi_select\n
"},{"location":"reference/elements/#elements.ConversationSelectMenu","title":"ConversationSelectMenu","text":"

A select menu interactive UI element, sourced with a list of public and private channels, DMs, and MPIMs visible to the current user.

See: https://api.slack.com/reference/block-kit/block-elements#conversations_select.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_conversation Optional[str]

the single (string) coversation ID that will be initially selected when first presented to the user.

None default_to_current_conversation Optional[bool]

Pre-populates the select menu with the conversation that the user was viewing when they opened the modal (defaults to False).

False confirm Optional[ConfirmationDialogue]

a ConfirmationDialogue object that will be presented when an option in the overflow menu is selected.

None response_url_enabled Optional[bool]

When set to true, the view_submission payload from the menu's parent view will contain a response_url. (This response_url can be used for message responses).

False filter Optional[ConversationFilter]

a Filter object that filters out conversations that don't match the settings of the filter.

None focus_on_load bool

whether or not the input will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the input when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class ConversationSelectMenu(Element):\n    \"\"\"\n    A select menu interactive UI element, sourced with a list of public and private channels,\n        DMs, and MPIMs visible to the current user.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#conversations_select>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_conversation: the single (string) coversation ID that will be initially\n            selected when first presented to the user.\n        default_to_current_conversation: Pre-populates the select menu with the\n            conversation that the user was viewing when they opened the modal\n            (defaults to `False`).\n        confirm: a `ConfirmationDialogue` object that will be presented when an\n            option in the overflow menu is selected.\n        response_url_enabled: When set to true, the view_submission payload from the\n            menu's parent view will contain a response_url. (This response_url can be\n            used for message responses).\n        filter: a [`Filter`](/slackblocks/latest/reference/objects/#objects.ConversationFilter)\n            object that filters out conversations that don't match the settings\n            of the filter.\n        focus_on_load: whether or not the input will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the input when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_conversation: Optional[str] = None,\n        default_to_current_conversation: Optional[bool] = False,\n        confirm: Optional[ConfirmationDialogue] = None,\n        response_url_enabled: Optional[bool] = False,\n        filter: Optional[ConversationFilter] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.CONVERSATIONS_SELECT_MENU)\n        self.action_id = validate_action_id(action_id)\n        self.initial_conversation = initial_conversation\n        self.default_to_current_conversation = default_to_current_conversation\n        self.confirm = confirm\n        self.response_url_enabled = response_url_enabled\n        self.filter = filter\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder,\n            max_length=150,\n            force_plaintext=True,\n            allow_none=True,\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        conversation_select_menu = self._attributes()\n        conversation_select_menu[\"action_id\"] = self.action_id\n        if self.initial_conversation:\n            conversation_select_menu[\"initial_conversation\"] = self.initial_conversation\n        if self.default_to_current_conversation:\n            conversation_select_menu[\"default_to_current_conversation\"] = (\n                self.default_to_current_conversation\n            )\n        if self.confirm:\n            conversation_select_menu[\"confirm\"] = self.confirm._resolve()\n        if self.response_url_enabled:\n            conversation_select_menu[\"response_url_enabled\"] = self.response_url_enabled\n        if self.filter:\n            conversation_select_menu[\"filter\"] = self.filter\n        if self.focus_on_load:\n            conversation_select_menu[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            conversation_select_menu[\"placeholder\"] = self.placeholder._resolve()\n        return conversation_select_menu\n
"},{"location":"reference/elements/#elements.DatePicker","title":"DatePicker","text":"

Interactive element that allows users to select a date from a calendar.

See: https://api.slack.com/reference/block-kit/block-elements#datepicker.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_date Optional[str]

the date (in YYYY-MM-DD format) that will appear on the picker when it first renders.

None confirm ConfirmationDialogue

a ConfirmationDialogue object that will be presented when the date picker is clicked.

None focus_on_load bool

whether or not the date picker will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a TextType.PLAINTEXT Text object that defines what text will initially appear on the picker.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class DatePicker(Element):\n    \"\"\"\n    Interactive element that allows users to select a date from a calendar.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#datepicker>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_date: the date (in `YYYY-MM-DD` format) that will appear on the\n            picker when it first renders.\n        confirm: a `ConfirmationDialogue` object that will be presented when\n            the date picker is clicked.\n        focus_on_load: whether or not the date picker will be set to autofocus\n            within the view object.\n        placeholder: a `TextType.PLAINTEXT` `Text` object that defines what text\n            will initially appear on the picker.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_date: Optional[str] = None,\n        confirm: ConfirmationDialogue = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ) -> \"DatePicker\":\n        super().__init__(type_=ElementType.DATE_PICKER)\n        self.action_id = validate_action_id(action_id)\n        if initial_date:\n            self.initial_date = datetime.strptime(initial_date, \"%Y-%m-%d\").strftime(\n                \"%Y-%m-%d\"\n            )\n        self.confirm = confirm\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, force_plaintext=True, max_length=150, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        date_picker = self._attributes()\n        date_picker[\"action_id\"] = self.action_id\n        if self.initial_date is not None:\n            date_picker[\"initial_date\"] = self.initial_date\n        if self.confirm:\n            date_picker[\"confirm\"] = self.confirm\n        if self.focus_on_load:\n            date_picker[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            date_picker[\"placeholder\"] = self.placeholder._resolve()\n        return date_picker\n
"},{"location":"reference/elements/#elements.DateTimePicker","title":"DateTimePicker","text":"

Allows users to select both a date and a time of day.

Provides the date-time formatted as a Unix timestamp.

See: https://api.slack.com/reference/block-kit/block-elements#datetimepicker.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_datetime Optional[int]

the initial value the date-time picker will be set to when it first renders.

None confirm ConfirmationDialogue

a ConfirmationDialogue object that will be presented when the button is date-time picker is used.

None focus_on_load bool

whether or not the datetime picker will be set to autofocus within the view object.

False

Throws: InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class DateTimePicker(Element):\n    \"\"\"\n    Allows users to select both a date and a time of day.\n\n    Provides the date-time formatted as a Unix timestamp.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#datetimepicker>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_datetime: the initial value the date-time picker will be set to\n            when it first renders.\n        confirm: a `ConfirmationDialogue` object that will be presented when\n            the button is date-time picker is used.\n        focus_on_load: whether or not the datetime picker will be set to autofocus\n            within the view object.\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_datetime: Optional[int] = None,\n        confirm: ConfirmationDialogue = None,\n        focus_on_load: bool = False,\n    ) -> \"DateTimePicker\":\n        super().__init__(type_=ElementType.DATETIME_PICKER)\n        self.action_id = validate_action_id(action_id)\n        if initial_datetime:\n            self.initial_datetime = initial_datetime\n        self.confirm = confirm\n        self.focus_on_load = focus_on_load\n\n    def _resolve(self) -> Dict[str, Any]:\n        datetime_picker = self._attributes()\n        datetime_picker[\"action_id\"] = self.action_id\n        if self.initial_datetime:\n            datetime_picker[\"initial_date_time\"] = self.initial_datetime\n        if self.confirm:\n            datetime_picker[\"confirm\"] = self.confirm\n        if self.focus_on_load:\n            datetime_picker[\"focus_on_load\"] = self.focus_on_load\n        return datetime_picker\n
"},{"location":"reference/elements/#elements.EmailInput","title":"EmailInput","text":"

Allows user to enter an email into a single-line text field.

See: https://api.slack.com/reference/block-kit/block-elements#email.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_value Optional[str]

The initial value in the email input when it is loaded.

None dispatch_action_config Optional[DispatchActionConfiguration]

a DispatchActionConfiguration object that determines when during text input the element returns a block_actions payload.

None focus_on_load bool

whether or not the email input will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a TextType.PLAINTEXT Text object that defines what text will initially appear in the input field.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class EmailInput(Element):\n    \"\"\"\n    Allows user to enter an email into a single-line text field.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#email>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_value: The initial value in the email input when it is loaded.\n        dispatch_action_config: a `DispatchActionConfiguration` object that\n            determines when during text input the element returns a\n            `block_actions` payload.\n        focus_on_load: whether or not the email input will be set to autofocus\n            within the view object.\n        placeholder: a `TextType.PLAINTEXT` `Text` object that defines what text\n            will initially appear in the input field.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_value: Optional[str] = None,\n        dispatch_action_config: Optional[DispatchActionConfiguration] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.EMAIL_INPUT)\n        self.action_id = validate_action_id(action_id)\n        self.initial_value = initial_value\n        self.dispatch_action_config = dispatch_action_config\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, max_length=150, force_plaintext=True, allow_none=True\n        )\n\n    def _resolve(self):\n        email_input = self._attributes()\n        email_input[\"action_id\"] = self.action_id\n        if self.initial_value:\n            email_input[\"initial_value\"] = self.initial_value\n        if self.dispatch_action_config:\n            email_input[\"dispatch_action_config\"] = (\n                self.dispatch_action_config._resolve()\n            )\n        if self.focus_on_load:\n            email_input[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            email_input[\"placeholder\"] = self.placeholder._resolve()\n        return email_input\n
"},{"location":"reference/elements/#elements.ExternalMultiSelectMenu","title":"ExternalMultiSelectMenu","text":"

An interactive UI element that loads its options from an external data source, allowing for a dynamic list of options.

See: https://api.slack.com/reference/block-kit/block-elements#external_multi_select.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required min_query_length Optional[int]

minimum number of characters entered before the query is dispactched (defaults to 3 if not provided).

None initial_options Optional[Union[Option, List[Option], OptionGroup, List[OptionGroup]]]

the Options to be intially selected when the element is first rendered.

None confirm ConfirmationDialogue

a ConfirmationDialogue object that will be presented when the menu is used.

None max_selected_items Optional[int]

the highest number of items from the list that can be selected at one time.

None focus_on_load bool

whether or not the menu will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the menu when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class ExternalMultiSelectMenu(Element):\n    \"\"\"\n    An interactive UI element that loads its options from an external data source,\n        allowing for a dynamic list of options.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#external_multi_select>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        min_query_length: minimum number of characters entered before the query\n            is dispactched (defaults to 3 if not provided).\n        initial_options: the [`Options`](/slackblocks/latest/reference/objects/#objects.Option)\n            to be intially selected when the element is first rendered.\n        confirm: a `ConfirmationDialogue` object that will be presented when\n            the menu is used.\n        max_selected_items: the highest number of items from the list that\n            can be selected at one time.\n        focus_on_load: whether or not the menu will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the menu when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        min_query_length: Optional[int] = None,\n        initial_options: Optional[\n            Union[Option, List[Option], OptionGroup, List[OptionGroup]]\n        ] = None,\n        confirm: ConfirmationDialogue = None,\n        max_selected_items: Optional[int] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.MULTI_SELECT_EXTERNAL)\n        self.action_id = validate_action_id(action_id)\n        self.min_query_length = min_query_length\n        self.initial_options = coerce_to_list(\n            initial_options, class_=(Option, OptionGroup), allow_none=True, max_size=100\n        )\n        self.confirm = confirm\n        self.max_selected_items = max_selected_items\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, force_plaintext=True, max_length=150, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        external_select_menu = self._attributes()\n        external_select_menu[\"action_id\"] = self.action_id\n        if self.min_query_length:\n            external_select_menu[\"min_query_length\"] = self.min_query_length\n        if self.initial_options:\n            external_select_menu[\"initial_options\"] = [\n                initial_option._resolve() for initial_option in self.initial_options\n            ]\n        if self.confirm:\n            external_select_menu[\"confirm\"] = self.confirm._resolve()\n        if self.max_selected_items:\n            external_select_menu[\"max_selected_items\"] = self.max_selected_items\n        if self.focus_on_load:\n            external_select_menu[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            external_select_menu[\"placeholder\"] = self.placeholder._resolve()\n        return external_select_menu\n
"},{"location":"reference/elements/#elements.ExternalSelectMenu","title":"ExternalSelectMenu","text":"

A select menu interactive UI element, sourced with externally provided options.

See

https://api.slack.com/slackblocks/latest/reference/block-kit/block-elements#external_select. # noqa: E501

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_option Union[Option, OptionGroup]

an Option object that will be initially selected when first presented to the user.

None min_query_length Optional[int]

minimum number of characters entered before the query is dispactched (defaults to 3 if not provided).

None confirm Optional[ConfirmationDialogue]

a ConfirmationDialogue object that will be presented when an option in the overflow menu is selected.

None focus_on_load bool

whether or not the input will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the input when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class ExternalSelectMenu(Element):\n    \"\"\"\n    A select menu interactive UI element, sourced with externally provided options.\n\n    See:\n        <https://api.slack.com/slackblocks/latest/reference/block-kit/block-elements#external_select>. # noqa: E501\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_option: an\n            [`Option`](/slackblocks/latest/reference/objects/#objects.Option) object that will be\n            initially selected when first presented to the user.\n        min_query_length: minimum number of characters entered before the query\n            is dispactched (defaults to 3 if not provided).\n        confirm: a `ConfirmationDialogue` object that will be presented when an\n            option in the overflow menu is selected.\n        focus_on_load: whether or not the input will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the input when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_option: Union[Option, OptionGroup] = None,\n        min_query_length: Optional[int] = None,\n        confirm: Optional[ConfirmationDialogue] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.EXTERNAL_SELECT_MENU)\n        self.action_id = validate_action_id(action_id)\n        self.initial_option = initial_option\n        self.min_query_length = min_query_length\n        self.confirm = confirm\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder,\n            max_length=150,\n            force_plaintext=True,\n            allow_none=True,\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        external_select_menu = self._attributes()\n        external_select_menu[\"action_id\"] = self.action_id\n        if self.initial_option:\n            external_select_menu[\"initial_option\"] = self.initial_option._resolve()\n        if self.min_query_length is not None:\n            external_select_menu[\"min_query_length\"] = self.min_query_length\n        if self.confirm:\n            external_select_menu[\"confirm\"] = self.confirm._resolve()\n        if self.focus_on_load:\n            external_select_menu[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            external_select_menu[\"placeholder\"] = self.placeholder._resolve()\n        return external_select_menu\n
"},{"location":"reference/elements/#elements.FileInput","title":"FileInput","text":"

An interactive element that allows users to upload files.

See: https://api.slack.com/reference/block-kit/block-elements#file_input.

Parameters:

Name Type Description Default action_id Optional[str]

an identifier so the source of the action can be known.

None filetypes Optional[Union[str, List[str]]]

a list of file extensions (as strings) that will be accepted for upload.

None max_files Optional[int]

the maximum number of files that can be uploaded (between 1 and 10).

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class FileInput(Element):\n    \"\"\"\n    An interactive element that allows users to upload files.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#file_input>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        filetypes: a list of file extensions (as strings) that will be accepted\n            for upload.\n        max_files: the maximum number of files that can be uploaded (between 1\n            and 10).\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: Optional[str] = None,\n        filetypes: Optional[Union[str, List[str]]] = None,\n        max_files: Optional[int] = None,\n    ) -> \"FileInput\":\n        super().__init__(ElementType.FILE_INPUT)\n        self.action_id = validate_action_id(action_id)\n        self.filetypes = coerce_to_list(\n            filetypes,\n            (str),\n            allow_none=True,\n        )\n        self.max_files = validate_int(\n            max_files, min_value=1, max_value=10, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        file_input = super()._resolve()\n        if self.action_id is not None:\n            file_input[\"action_id\"] = self.action_id\n        if self.filetypes is not None:\n            file_input[\"filetypes\"] = self.filetypes\n        if self.max_files is not None:\n            file_input[\"max_files\"] = self.max_files\n        return file_input\n
"},{"location":"reference/elements/#elements.Image","title":"Image","text":"

An element to insert an image - this element can be used in section and context blocks only. If you want a block with only an image in it, you're looking for the Image block.

You must provide either one of image_url or slack_file

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

Parameters:

Name Type Description Default alt_text str

a plain-text-only summary of the content of the image.

' ' image_url Optional[str]

a URL for a publicly hosted image (the user must provide either image_url or slack_file).

None slack_file Optional[SlackFile]

a SlackFile (the user must provide either image_url or slack_file).

None Throws

InvalidUsageError: if any of the provided arguments fail validation, or both/neither of image_url and slack_file are provided.

Source code in slackblocks/elements.py
class Image(Element):\n    \"\"\"\n    An element to insert an image - this element can be used in section\n    and context blocks only. If you want a block with only an image in it,\n    you're looking for the Image block.\n\n    You must provide either one of `image_url` or `slack_file`\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#image>.\n\n    Args:\n        alt_text: a plain-text-only summary of the content of the image.\n        image_url: a URL for a publicly hosted image (the user must provide\n            either `image_url` or `slack_file`).\n        slack_file: a\n            [`SlackFile`](/slackblocks/latest/reference/objects/#objects.SlackFile)\n            (the user must provide either `image_url` or `slack_file`).\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation,\n            or both/neither of `image_url` and `slack_file` are provided.\n    \"\"\"\n\n    def __init__(\n        self,\n        alt_text: str = \" \",\n        image_url: Optional[str] = None,\n        slack_file: Optional[SlackFile] = None,\n    ):\n        super().__init__(type_=ElementType.IMAGE)\n        if image_url is None and slack_file is None:\n            raise InvalidUsageError(\"Must provide one of `image_url` or `slack_file`\")\n        if image_url and slack_file:\n            raise InvalidUsageError(\"Cannot provide both `image_url` or `slack_file`\")\n        self.image_url = image_url\n        self.alt_text = alt_text\n        self.slack_file = slack_file\n\n    def _resolve(self) -> Dict[str, Any]:\n        image = self._attributes()\n        if self.image_url is not None:\n            image[\"image_url\"] = self.image_url\n        image[\"alt_text\"] = self.alt_text\n        if self.slack_file is not None:\n            image[\"slack_file\"] = self.slack_file\n        return image\n
"},{"location":"reference/elements/#elements.NumberInput","title":"NumberInput","text":"

This input elements accepts both integer and decimal numbers. For example, 0.25, 5.5, and -10 are all valid input values.

See https://api.slack.com/reference/block-kit/block-elements#number.

Parameters:

Name Type Description Default is_decimal_allowed bool

whether to accept decimal values as input.

required action_id Optional[str]

an identifier so the source of the action can be known.

None initial_value Optional[str]

the initial value in the number input when it is loaded.

None min_value Optional[Union[float, int]]

minimum accepted value for the input field.

None max_value Optional[Union[float, int]]

maximum accepted value for the input field.

None dispatch_action_config Optional[DispatchActionConfiguration]

a DispatchActionConfiguration object that determines when during text input the element returns a block_actions payload.

None focus_on_load bool

whether or not the menu will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the input when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class NumberInput(Element):\n    \"\"\"\n    This input elements accepts both integer and decimal numbers. For example,\n    0.25, 5.5, and -10 are all valid input values.\n\n    See <https://api.slack.com/reference/block-kit/block-elements#number>.\n\n    Args:\n        is_decimal_allowed: whether to accept decimal values as input.\n        action_id: an identifier so the source of the action can be known.\n        initial_value: the initial value in the number input when it is loaded.\n        min_value: minimum accepted value for the input field.\n        max_value: maximum accepted value for the input field.\n        dispatch_action_config: a `DispatchActionConfiguration` object that\n            determines when during text input the element returns a\n            `block_actions` payload.\n        focus_on_load: whether or not the menu will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the input when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        is_decimal_allowed: bool,\n        action_id: Optional[str] = None,\n        initial_value: Optional[str] = None,\n        min_value: Optional[Union[float, int]] = None,\n        max_value: Optional[Union[float, int]] = None,\n        dispatch_action_config: Optional[DispatchActionConfiguration] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.NUMBER_INPUT)\n        self.is_decimal_allowed = is_decimal_allowed\n        self.action_id = validate_action_id(action_id, allow_none=True)\n        self.initial_value = initial_value\n        self.min_value = min_value\n        self.max_value = max_value\n        if min_value:\n            if not is_decimal_allowed:\n                if isinstance(min_value, float):\n                    raise InvalidUsageError(\n                        f\"`min_value` ({min_value}) cannot be a float when \"\n                        \"`is_decimal_allowed` is `False`\"\n                    )\n        if max_value:\n            if not is_decimal_allowed:\n                if isinstance(max_value, float):\n                    raise InvalidUsageError(\n                        f\"`max_value` ({max_value}) cannot be a float when \"\n                        \"`is_decimal_allowed` is `False`\"\n                    )\n        if (min_value or min_value == 0) and (max_value or max_value == 0):\n            if min_value > max_value:\n                raise InvalidUsageError(\n                    f\"`min_value` ({min_value}) cannot be greater than \"\n                    \"`max_value` ({min_value})\"\n                )\n        self.dispatch_action_config = dispatch_action_config\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, max_length=150, force_plaintext=True, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        number_input = self._attributes()\n        number_input[\"is_decimal_allowed\"] = self.is_decimal_allowed\n        if self.action_id:\n            number_input[\"action_id\"] = self.action_id\n        if self.initial_value:\n            number_input[\"initial_value\"] = self.initial_value\n        if self.min_value:\n            number_input[\"min_value\"] = self.min_value\n        if self.max_value:\n            number_input[\"max_value\"] = self.max_value\n        if self.dispatch_action_config:\n            number_input[\"dispatch_action_config\"] = (\n                self.dispatch_action_config._resolve()\n            )\n        if self.focus_on_load:\n            number_input[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            number_input[\"placeholder\"] = self.placeholder._resolve()\n        return number_input\n
"},{"location":"reference/elements/#elements.OverflowMenu","title":"OverflowMenu","text":"

Context menu for additional options (think '...').

See https://api.slack.com/reference/block-kit/block-elements#overflow.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required options Union[Option, List[Option]]

a list of Option objects that will form the content of the overflow menu.

required confirm ConfirmationDialogue

a ConfirmationDialogue object that will be presented when an option in the overflow menu is selected.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class OverflowMenu(Element):\n    \"\"\"\n    Context menu for additional options (think '...').\n\n    See <https://api.slack.com/reference/block-kit/block-elements#overflow>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        options: a list of\n            [`Option`](/slackblocks/latest/reference/objects/#objects.Option) objects that will form\n            the content of the overflow menu.\n        confirm: a `ConfirmationDialogue` object that will be presented when an\n            option in the overflow menu is selected.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        options: Union[Option, List[Option]],\n        confirm: ConfirmationDialogue = None,\n    ):\n        super().__init__(type_=ElementType.OVERFLOW_MENU)\n        self.action_id = validate_action_id(action_id)\n        self.options = coerce_to_list(options, Option, min_size=1, max_size=5)\n        self.confirm = confirm\n\n    def _resolve(self) -> Dict[str, Any]:\n        overflow_menu = self._attributes()\n        overflow_menu[\"action_id\"] = self.action_id\n        overflow_menu[\"options\"] = [option._resolve() for option in self.options]\n        if self.confirm:\n            overflow_menu[\"confirm\"] = self.confirm._resolve()\n        return overflow_menu\n
"},{"location":"reference/elements/#elements.PlainTextInput","title":"PlainTextInput","text":"

A plain-text input, similar to the HTML tag, creates a field where a user can enter freeform data. It can appear as a single-line field or a larger text area using the multiline flag.

See: https://api.slack.com/reference/block-kit/block-elements#input.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_value Optional[str]

the initial value in the plain-text input when it is loaded.

None multiline bool

whether to accept multiple lines of input(defaults to false).

False min_length Optional[int]

minimum number of characters to accept as input.

None max_length Optional[int]

maximum number of characters to accept as input.

None dispatch_action_config Optional[DispatchActionConfiguration]

a DispatchActionConfiguration object that determines when during text input the element returns a block_actions payload.

None focus_on_load bool

whether or not the input will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the input when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class PlainTextInput(Element):\n    \"\"\"\n    A plain-text input, similar to the HTML <input> tag, creates a field where a user\n    can enter freeform data. It can appear as a single-line field or a larger text\n    area using the multiline flag.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#input>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_value: the initial value in the plain-text input when it is loaded.\n        multiline: whether to accept multiple lines of input(defaults to false).\n        min_length: minimum number of characters to accept as input.\n        max_length: maximum number of characters to accept as input.\n        dispatch_action_config: a `DispatchActionConfiguration` object that\n            determines when during text input the element returns a\n            `block_actions` payload.\n        focus_on_load: whether or not the input will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the input when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_value: Optional[str] = None,\n        multiline: bool = False,\n        min_length: Optional[int] = None,\n        max_length: Optional[int] = None,\n        dispatch_action_config: Optional[DispatchActionConfiguration] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.PLAIN_TEXT_INPUT)\n        self.action_id = validate_action_id(action_id)\n        self.multiline = multiline\n        self.initial_value = initial_value\n        self.min_length = min_length\n        if max_length and max_length > 3000:\n            raise InvalidUsageError(\"`max_length` value cannot exceed 3000 characters\")\n        self.max_length = max_length\n        self.dispatch_action_config = dispatch_action_config\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, max_length=150, force_plaintext=True, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        plain_text_input = self._attributes()\n        if self.multiline:\n            plain_text_input[\"multiline\"] = self.multiline\n        if self.action_id:\n            plain_text_input[\"action_id\"] = self.action_id\n        if self.initial_value:\n            plain_text_input[\"initial_value\"] = self.initial_value\n        if self.min_length:\n            plain_text_input[\"min_length\"] = self.min_length\n        if self.max_length:\n            plain_text_input[\"max_length\"] = self.max_length\n        if self.dispatch_action_config:\n            plain_text_input[\"dispatch_action_config\"] = (\n                self.dispatch_action_config._resolve()\n            )\n        if self.focus_on_load:\n            plain_text_input[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            plain_text_input[\"placeholder\"] = self.placeholder._resolve()\n        return plain_text_input\n
"},{"location":"reference/elements/#elements.RadioButtonGroup","title":"RadioButtonGroup","text":"

A radio button group that allows a user to choose one item from a list of possible options.

See: https://api.slack.com/reference/block-kit/block-elements#radio.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required options List[Option]

a list of Option objects that will form the content of the radio button group.

required initial_option Optional[Option]

an Option object that will be initially selected when first presented to the user.

None confirm Optional[ConfirmationDialogue]

a ConfirmationDialogue object that will be presented when an option in the overflow menu is selected.

None focus_on_load bool

whether or not the input will be set to autofocus within the view object.

False Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class RadioButtonGroup(Element):\n    \"\"\"\n    A radio button group that allows a user to choose one item from a list of possible options.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#radio>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        options: a list of\n            [`Option`](/slackblocks/latest/reference/objects/#objects.Option) objects that will form\n            the content of the radio button group.\n        initial_option: an\n            [`Option`](/slackblocks/latest/reference/objects/#objects.Option) object that will be\n            initially selected when first presented to the user.\n        confirm: a `ConfirmationDialogue` object that will be presented when an\n            option in the overflow menu is selected.\n        focus_on_load: whether or not the input will be set to autofocus\n            within the view object.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        options: List[Option],\n        initial_option: Optional[Option] = None,\n        confirm: Optional[ConfirmationDialogue] = None,\n        focus_on_load: bool = False,\n    ):\n        super().__init__(type_=ElementType.RADIO_BUTTON_GROUP)\n        self.action_id = validate_action_id(action_id)\n        if len(options) < 1 or len(options) > 10:\n            raise InvalidUsageError(\n                \"Number of options to RadioButtonGroup must be between 1 and 10 (inclusive).\"\n            )\n        self.options = coerce_to_list(options, class_=Option, allow_none=False)\n        if initial_option is not None and initial_option not in options:\n            raise InvalidUsageError(\"`initial_option` must be a member of `options`\")\n        self.initial_option = initial_option\n        self.confirm = confirm\n        self.focus_on_load = focus_on_load\n\n    def _resolve(self) -> Dict[str, Any]:\n        radio_button_group = self._attributes()\n        radio_button_group[\"action_id\"] = self.action_id\n        radio_button_group[\"options\"] = [option._resolve() for option in self.options]\n        if self.initial_option:\n            radio_button_group[\"initial_option\"] = self.initial_option._resolve()\n        if self.confirm:\n            radio_button_group[\"confirm\"] = self.confirm._resolve()\n        if self.focus_on_load:\n            radio_button_group[\"focus_on_load\"] = self.focus_on_load\n        return radio_button_group\n
"},{"location":"reference/elements/#elements.RichTextInput","title":"RichTextInput","text":"

Allows users to enter formatted text in a WYSIWYG editor, similar to the Slack messaging experience.

See: https://api.slack.com/reference/block-kit/block-elements#rich_text_input.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_value Optional[RichText]

The initial value in the rich text input when it is loaded.

None dispatch_action_config Optional[DispatchActionConfiguration]

a DispatchActionConfiguration object that determines when during text input the element returns a block_actions payload.

None focus_on_load bool

whether or not the menu will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the menu when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class RichTextInput(Element):\n    \"\"\"\n    Allows users to enter formatted text in a WYSIWYG editor, similar to the Slack\n        messaging experience.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#rich_text_input>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_value: The initial value in the rich text input when it is loaded.\n        dispatch_action_config: a `DispatchActionConfiguration` object that\n            determines when during text input the element returns a\n            `block_actions` payload.\n        focus_on_load: whether or not the menu will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the menu when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_value: Optional[RichText] = None,\n        dispatch_action_config: Optional[DispatchActionConfiguration] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ) -> \"RichTextInput\":\n        super().__init__(ElementType.RICH_TEXT_INPUT)\n        self.action_id = validate_action_id(action_id)\n        self.initial_value = initial_value\n        self.dispatch_action_config = dispatch_action_config\n        self.focus_on_load = focus_on_load\n        self.placeholder = placeholder\n\n    def _resolve(self) -> Dict[str, Any]:\n        rich_text_input = super()._attributes()\n        rich_text_input[\"action_id\"] = self.action_id\n        if self.initial_value is not None:\n            rich_text_input[\"initial_value\"] = self.initial_value._resolve()\n        if self.dispatch_action_config is not None:\n            rich_text_input[\"dispatch_action_config\"] = self.dispatch_action_config\n        if self.focus_on_load is not None:\n            rich_text_input[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder is not None:\n            rich_text_input[\"placeholder\"] = self.placeholder\n        return rich_text_input\n
"},{"location":"reference/elements/#elements.StaticMultiSelectMenu","title":"StaticMultiSelectMenu","text":"

The most basic form of select menu containing a static list of options passed in when defining the element.

See: https://api.slack.com/reference/block-kit/block-elements#static_multi_select.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required options Union[Option, List[Option]]

a list of Options (max 100). Only one of options or option_groups must be provided.

required option_groups List[OptionGroup]

a list of OptionGroups (max 100). Only one of options or option_groups can be provided.

None initial_options Optional[Union[Option, List[Option], OptionGroup, List[OptionGroup]]]

the Options to be intially selected when the element is first rendered.

None confirm ConfirmationDialogue

a ConfirmationDialogue object that will be presented when the menu is used.

None max_selected_items Optional[int]

the

None focus_on_load bool

whether or not the menu will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the menu when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class StaticMultiSelectMenu(Element):\n    \"\"\"\n    The most basic form of select menu containing a static list of options\n    passed in when defining the element.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#static_multi_select>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        options: a list of [`Options`](/slackblocks/latest/reference/objects/#objects.Option)\n            (max 100). Only one of `options` or `option_groups` must be\n            provided.\n        option_groups: a list of\n            [`OptionGroups`](/slackblocks/latest/reference/objects/#objects.OptionGroup)\n            (max 100). Only one of `options` or `option_groups` can be\n            provided.\n        initial_options: the [`Options`](/slackblocks/latest/reference/objects/#objects.Option)\n            to be intially selected when the element is first rendered.\n        confirm: a `ConfirmationDialogue` object that will be presented when\n            the menu is used.\n        max_selected_items: the\n        focus_on_load: whether or not the menu will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the menu when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        options: Union[Option, List[Option]],\n        option_groups: List[OptionGroup] = None,\n        initial_options: Optional[\n            Union[Option, List[Option], OptionGroup, List[OptionGroup]]\n        ] = None,\n        confirm: ConfirmationDialogue = None,\n        max_selected_items: Optional[int] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.MULTI_SELECT_STATIC)\n        self.action_id = validate_action_id(action_id)\n        if options and option_groups:\n            raise InvalidUsageError(\n                \"Cannot set both `options` and `option_groups` parameters.\"\n            )\n        self.options = coerce_to_list(\n            options, class_=Option, allow_none=True, max_size=100\n        )\n        self.option_groups = coerce_to_list(\n            option_groups, class_=OptionGroup, allow_none=True, max_size=100\n        )\n        self.initial_options = coerce_to_list(\n            initial_options, class_=(Option, OptionGroup), allow_none=True, max_size=100\n        )\n        if (\n            options\n            and self.initial_options\n            and not all(isinstance(option, Option) for option in self.initial_options)\n        ):\n            raise InvalidUsageError(\n                \"If using `options` then `initial_options` must also be of type `List[Option]`, \"\n                f\"not `{type(self.initial_options)}`.\"\n            )\n        if (\n            option_groups\n            and self.initial_options\n            and not all(\n                isinstance(option, OptionGroup) for option in self.initial_options\n            )\n        ):\n            raise InvalidUsageError(\n                \"If using `option_groups` then `initial_options` must also be of type \"\n                f\"`List[OptionGroup]`, not `{type(self.initial_options)}`.\"\n            )\n\n        # Check that Option Text is all TextType.PLAINTEXT\n        if self.options:\n            options_to_validate = self.options\n        if self.option_groups:\n            options_to_validate = sum(\n                [option_group.options for option_group in option_groups], []\n            )\n        for option in options_to_validate:\n            if option.text.text_type == TextType.MARKDOWN:\n                raise InvalidUsageError(\n                    \"Text in Options for StaticSelectMenu can only be of TextType.PLAINTEXT\"\n                )\n\n        self.confirm = confirm\n        self.max_selected_items = max_selected_items\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, force_plaintext=True, max_length=150, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        static_multi_select = self._attributes()\n        static_multi_select[\"action_id\"] = self.action_id\n        if self.options:\n            static_multi_select[\"options\"] = [\n                option._resolve() for option in self.options\n            ]\n        if self.option_groups:\n            static_multi_select[\"option_groups\"] = [\n                option_group._resolve() for option_group in self.option_groups\n            ]\n        if self.initial_options:\n            static_multi_select[\"initial_options\"] = [\n                initial_option._resolve() for initial_option in self.initial_options\n            ]\n        if self.confirm:\n            static_multi_select[\"confirm\"] = self.confirm._resolve()\n        if self.max_selected_items:\n            static_multi_select[\"max_selected_items\"] = self.max_selected_items\n        if self.focus_on_load:\n            static_multi_select[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            static_multi_select[\"placeholder\"] = self.placeholder._resolve()\n        return static_multi_select\n
"},{"location":"reference/elements/#elements.StaticSelectMenu","title":"StaticSelectMenu","text":"

A simple select menu interactive UI element, with a static list of options passed in when defining the element.

See: https://api.slack.com/reference/block-kit/block-elements#static_select.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required options List[Option]

a list of Option objects that will form the content of the menu (max 100).

None option_groups List[OptionGroup]

a list of OptionGroups (max 100). Only one of options or option_groups can be provided.

None initial_option Optional[Union[Option, OptionGroup]]

an Option object that will be initially selected when first presented to the user.

None confirm Optional[ConfirmationDialogue]

a ConfirmationDialogue object that will be presented when an option in the overflow menu is selected.

None focus_on_load bool

whether or not the input will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the input when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class StaticSelectMenu(Element):\n    \"\"\"\n    A simple select menu interactive UI element, with a static list of options passed in when\n        defining the element.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#static_select>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        options: a list of\n            [`Option`](/slackblocks/latest/reference/objects/#objects.Option) objects that will form\n            the content of the menu (max 100).\n        option_groups: a list of\n            [`OptionGroups`](/slackblocks/latest/reference/objects/#objects.OptionGroup)\n            (max 100). Only one of `options` or `option_groups` can be\n            provided.\n        initial_option: an\n            [`Option`](/slackblocks/latest/reference/objects/#objects.Option) object that will be\n            initially selected when first presented to the user.\n        confirm: a `ConfirmationDialogue` object that will be presented when an\n            option in the overflow menu is selected.\n        focus_on_load: whether or not the input will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the input when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        options: List[Option] = None,\n        option_groups: List[OptionGroup] = None,\n        initial_option: Optional[Union[Option, OptionGroup]] = None,\n        confirm: Optional[ConfirmationDialogue] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.STATIC_SELECT_MENU)\n        self.action_id = validate_action_id(action_id)\n        if options and option_groups:\n            raise InvalidUsageError(\n                \"Cannot set both `options` and `option_groups` parameters.\"\n            )\n        self.options = coerce_to_list(\n            options, class_=Option, allow_none=True, max_size=100\n        )\n        self.option_groups = coerce_to_list(\n            option_groups, class_=OptionGroup, allow_none=True, max_size=100\n        )\n        if options and initial_option and not isinstance(initial_option, Option):\n            raise InvalidUsageError(\n                \"If using `options` then `initial_option` must also be of type `Option`, \"\n                f\"not `{type(initial_option)}`.\"\n            )\n        if (\n            option_groups\n            and initial_option\n            and not isinstance(initial_option, OptionGroup)\n        ):\n            raise InvalidUsageError(\n                \"If using `option_groups` then `initial_option` must also be of type \"\n                f\"`OptionGroup`, not `{type(initial_option)}`.\"\n            )\n\n        # Check that Option Text is all TextType.PLAINTEXT\n        if self.options:\n            options_to_validate = self.options\n        if self.option_groups:\n            options_to_validate = sum(\n                [option_group.options for option_group in option_groups], []\n            )\n        for option in options_to_validate:\n            if option.text.text_type == TextType.MARKDOWN:\n                raise InvalidUsageError(\n                    \"Text in Options for StaticSelectMenu can only be of TextType.PLAINTEXT\"\n                )\n\n        self.initial_option = initial_option\n        self.confirm = confirm\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, max_length=150, force_plaintext=True, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        static_select_menu = self._attributes()\n        static_select_menu[\"action_id\"] = self.action_id\n        if self.options:\n            static_select_menu[\"options\"] = [\n                option._resolve() for option in self.options\n            ]\n        if self.option_groups:\n            static_select_menu[\"option_groups\"] = [\n                option_group._resolve() for option_group in self.option_groups\n            ]\n        if self.initial_option:\n            static_select_menu[\"initial_option\"] = self.initial_option._resolve()\n        if self.confirm:\n            static_select_menu[\"confirm\"] = self.confirm._resolve()\n        if self.focus_on_load:\n            static_select_menu[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            static_select_menu[\"placeholder\"] = self.placeholder._resolve()\n        return static_select_menu\n
"},{"location":"reference/elements/#elements.TimePicker","title":"TimePicker","text":"

An interactive UI element that allows users to select a time of day.

See: https://api.slack.com/reference/block-kit/block-elements#timepicker.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_time Optional[str] None confirm Optional[ConfirmationDialogue]

a ConfirmationDialogue object that will be presented when the input field is used.

None focus_on_load bool

whether or not the menu will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the menu when it's initially rendered.

None timezone Optional[str]

a string in the IANA format, e.g. \"America/Chicago\".

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class TimePicker(Element):\n    \"\"\"\n    An interactive UI element that allows users to select a time of day.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#timepicker>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_time:\n        confirm: a `ConfirmationDialogue` object that will be presented when\n            the input field is used.\n        focus_on_load: whether or not the menu will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the menu when it's initially rendered.\n        timezone: a string in the IANA format, e.g. \"America/Chicago\".\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_time: Optional[str] = None,\n        confirm: Optional[ConfirmationDialogue] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n        timezone: Optional[str] = None,\n    ):\n        super().__init__(type_=ElementType.TIME_PICKER)\n        self.action_id = validate_action_id(action_id)\n        self.initial_time = initial_time\n        self.confirm = confirm\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder,\n            max_length=150,\n            force_plaintext=True,\n            allow_none=True,\n        )\n        self.timezone = timezone\n\n    def _resolve(self) -> Dict[str, Any]:\n        time_picker = self._attributes()\n        time_picker[\"action_id\"] = self.action_id\n        if self.initial_time:\n            time_picker[\"initial_time\"] = self.initial_time\n        if self.confirm:\n            time_picker[\"confirm\"] = self.confirm\n        if self.focus_on_load:\n            time_picker[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            time_picker[\"placeholder\"] = self.placeholder._resolve()\n        if self.timezone is not None:\n            time_picker[\"timezone\"] = self.timezone\n        return time_picker\n
"},{"location":"reference/elements/#elements.URLInput","title":"URLInput","text":"

An interactive UI element for collecting URL input from users.

See: https://api.slack.com/reference/block-kit/block-elements#url.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_value Optional[str]

the text to populate the input field with when it is first rendered.

None dispatch_action_config Optional[DispatchActionConfiguration]

a DispatchActionConfiguration object that determines when during text input the element returns a block_actions payload.

None focus_on_load bool

whether or not the menu will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the input when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class URLInput(Element):\n    \"\"\"\n    An interactive UI element for collecting URL input from users.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#url>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_value: the text to populate the input field with when it\n            is first rendered.\n        dispatch_action_config: a `DispatchActionConfiguration` object that\n            determines when during text input the element returns a\n            `block_actions` payload.\n        focus_on_load: whether or not the menu will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the input when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_value: Optional[str] = None,\n        dispatch_action_config: Optional[DispatchActionConfiguration] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.URL_INPUT)\n        self.action_id = validate_action_id(action_id)\n        self.initial_value = initial_value\n        self.dispatch_action_config = dispatch_action_config\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder,\n            force_plaintext=True,\n            max_length=150,\n            allow_none=True,\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        url_input = self._attributes()\n        url_input[\"action_id\"] = self.action_id\n        if self.initial_value is not None:\n            url_input[\"initial_value\"] = self.initial_value\n        if self.dispatch_action_config:\n            url_input[\"dispatch_action_config\"] = self.dispatch_action_config._resolve()\n        if self.focus_on_load:\n            url_input[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            url_input[\"placeholder\"] = self.placeholder\n        return url_input\n
"},{"location":"reference/elements/#elements.UserMultiSelectMenu","title":"UserMultiSelectMenu","text":"

This interactive UI element allows users to select multiple users visible to the current user in the active workspace.

See: https://api.slack.com/reference/block-kit/block-elements#users_multi_select.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_users Optional[List[str]]

a list of string user IDs to be intially selected when the element is first rendered.

None confirm ConfirmationDialogue

a ConfirmationDialogue object that will be presented when the menu is used.

None max_selected_items Optional[int]

the highest number of items from the list that can be selected at one time.

None focus_on_load bool

whether or not the menu will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the menu when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class UserMultiSelectMenu(Element):\n    \"\"\"\n    This interactive UI element allows users to select multiple users visible\n        to the current user in the active workspace.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#users_multi_select>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_users: a list of string user IDs to be intially selected\n            when the element is first rendered.\n        confirm: a `ConfirmationDialogue` object that will be presented when\n            the menu is used.\n        max_selected_items: the highest number of items from the list that\n            can be selected at one time.\n        focus_on_load: whether or not the menu will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the menu when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_users: Optional[List[str]] = None,\n        confirm: ConfirmationDialogue = None,\n        max_selected_items: Optional[int] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.MULTI_SELECT_USERS)\n        self.action_id = validate_action_id(action_id)\n        self.initial_users = coerce_to_list(initial_users, str, allow_none=True)\n        self.confirm = confirm\n        self.max_selected_items = max_selected_items\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, force_plaintext=True, max_length=150, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        user_multi_select = self._attributes()\n        user_multi_select[\"action_id\"] = self.action_id\n        if self.initial_users:\n            user_multi_select[\"initial_users\"] = self.initial_users\n        if self.confirm:\n            user_multi_select[\"confirm\"] = self.confirm._resolve()\n        if self.max_selected_items:\n            user_multi_select[\"max_selected_items\"] = self.max_selected_items\n        if self.focus_on_load:\n            user_multi_select[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            user_multi_select[\"placeholder\"] = self.placeholder._resolve()\n        return user_multi_select\n
"},{"location":"reference/elements/#elements.UserSelectMenu","title":"UserSelectMenu","text":"

A select menu interactive UI element, sourced automatically with Slack users from the current workspace visible to the current user.

See: https://api.slack.com/reference/block-kit/block-elements#users_select.

Parameters:

Name Type Description Default action_id str

an identifier so the source of the action can be known.

required initial_user Optional[str]

the single (string) user ID that will be initially selected when first presented to the user.

None confirm Optional[ConfirmationDialogue]

a ConfirmationDialogue object that will be presented when an option in the overflow menu is selected.

None focus_on_load bool

whether or not the input will be set to autofocus within the view object.

False placeholder Optional[TextLike]

a plain-text Text object (max 150 chars) that shows in the input when it's initially rendered.

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class UserSelectMenu(Element):\n    \"\"\"\n    A select menu interactive UI element, sourced automatically with Slack users from the\n        current workspace visible to the current user.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#users_select>.\n\n    Args:\n        action_id: an identifier so the source of the action can be known.\n        initial_user: the single (string) user ID that will be initially selected\n            when first presented to the user.\n        confirm: a `ConfirmationDialogue` object that will be presented when an\n            option in the overflow menu is selected.\n        focus_on_load: whether or not the input will be set to autofocus\n            within the view object.\n        placeholder: a plain-text `Text` object (max 150 chars) that shows\n            in the input when it's initially rendered.\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        action_id: str,\n        initial_user: Optional[str] = None,\n        confirm: Optional[ConfirmationDialogue] = None,\n        focus_on_load: bool = False,\n        placeholder: Optional[TextLike] = None,\n    ):\n        super().__init__(type_=ElementType.USERS_SELECT_MENU)\n        self.action_id = validate_action_id(action_id)\n        self.initial_user = initial_user\n        self.confirm = confirm\n        self.focus_on_load = focus_on_load\n        self.placeholder = Text.to_text(\n            placeholder, max_length=150, force_plaintext=True, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        user_select_menu = self._attributes()\n        user_select_menu[\"action_id\"] = self.action_id\n        if self.initial_user:\n            user_select_menu[\"initial_user\"] = self.initial_user\n        if self.confirm:\n            user_select_menu[\"confirm\"] = self.confirm._resolve()\n        if self.focus_on_load:\n            user_select_menu[\"focus_on_load\"] = self.focus_on_load\n        if self.placeholder:\n            user_select_menu[\"placeholder\"] = self.placeholder._resolve()\n        return user_select_menu\n
"},{"location":"reference/elements/#elements.WorkflowButton","title":"WorkflowButton","text":"

An interactive component that allows users to run a link trigger with customizable inputs.

See: https://api.slack.com/reference/block-kit/block-elements#workflow_button.

Parameters:

Name Type Description Default text TextLike

the text content that will appear in the button.

required workflow Optional[Workflow]

a Workflow object that contains details about the workflow that will run when the button is clicked.

None style Optional[ButtonStyleLike]

one of Default, Primary, or Danger, determines the visual style of the button. Consider using the ButtonStyle object for this.

DEFAULT accessibility_label Optional[str]

a string label for longer descriptive text about a button element. Used by screen readers (max 75 chars).

None Throws

InvalidUsageError: if any of the provided arguments fail validation.

Source code in slackblocks/elements.py
class WorkflowButton(Element):\n    \"\"\"\n    An interactive component that allows users to run a link trigger with\n        customizable inputs.\n\n    See: <https://api.slack.com/reference/block-kit/block-elements#workflow_button>.\n\n    Args:\n        text: the text content that will appear in the button.\n        workflow: a [`Workflow`](/slackblocks/latest/reference/objects/#objects.Workflow) object\n            that contains details about the workflow that will run when the\n            button is clicked.\n        style: one of `Default`, `Primary`, or `Danger`, determines the\n            visual style of the button. Consider using the `ButtonStyle`\n            object for this.\n        accessibility_label: a string label for longer descriptive text about\n            a button element. Used by screen readers (max 75 chars).\n\n    Throws:\n        InvalidUsageError: if any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        text: TextLike,\n        workflow: Optional[Workflow] = None,\n        style: Optional[ButtonStyleLike] = ButtonStyle.DEFAULT,\n        accessibility_label: Optional[str] = None,\n    ):\n        super().__init__(type_=ElementType.WORKFLOW_BUTTON)\n        self.text = Text.to_text(text, force_plaintext=True, max_length=75)\n        self.workflow = workflow\n        self.style = ButtonStyle.to_button_style(style).value\n        self.accessibility_label = accessibility_label\n\n    def _resolve(self) -> Dict[str, Any]:\n        workflow_button = self._attributes()\n        workflow_button[\"text\"] = self.text._resolve()\n        if self.workflow:\n            workflow_button[\"workflow\"] = self.workflow._resolve()\n        if self.style is not None:\n            workflow_button[\"style\"] = self.style\n        if self.accessibility_label:\n            workflow_button[\"accessibility_label\"] = self.accessibility_label\n        return workflow_button\n
"},{"location":"reference/messages/","title":"Messages","text":"

Messages are the core unit of Slack messaging functionality. They can be built out using blocks, elements, objects, and rich text features.

See: https://api.slack.com/messaging

"},{"location":"reference/messages/#messages.Message","title":"Message","text":"

A Slack message object that can be converted to a JSON string for use with the Slack message API.

Parameters:

Name Type Description Default channel str

the Slack channel to send the message to, e.g. \"#general\".

required text Optional[str]

markdown text to send in the message. If blocks are provided then this is a fallback to display in notifications.

'' blocks Optional[Union[List[Block], Block]]

a list of Blocks to form the contents of the message instead of the contents of text.

None attachments Optional[List[Attachment]]

a list of Attachments that form the secondary contents of the message (deprecated).

None thread_ts Optional[str]

the timestamp ID of another unthreaded message that will become the parent message of this message (now a reply in a thread).

None mrkdwn bool

if True the contents of text will be rendered as markdown rather than plain text.

True unfurl_links Optional[bool]

if True, links in the message will be automatically unfurled.

None unfurl_media Optional[bool]

if True, media from links (e.g. images) will automatically unfurl.

None

Throws: InvalidUsageException: in the event that the items passed to blocks are not valid Blocks.

Source code in slackblocks/messages.py
class Message(BaseMessage):\n    \"\"\"\n    A Slack message object that can be converted to a JSON string for use with\n    the Slack message API.\n\n    Args:\n        channel: the Slack channel to send the message to, e.g. \"#general\".\n        text: markdown text to send in the message. If `blocks` are provided\n            then this is a fallback to display in notifications.\n        blocks: a list of [`Blocks`](/slackblocks/latest/reference/blocks) to form the contents\n            of the message instead of the contents of `text`.\n        attachments: a list of\n            [`Attachments`](/slackblocks/latest/reference/attachments/#attachments.Attachment)\n            that form the secondary contents of the message (deprecated).\n        thread_ts: the timestamp ID of another unthreaded message that will\n            become the parent message of this message (now a reply in a thread).\n        mrkdwn: if `True` the contents of `text` will be rendered as markdown\n            rather than plain text.\n        unfurl_links: if `True`, links in the message will be automatically\n            unfurled.\n        unfurl_media: if `True`, media from links (e.g. images) will\n            automatically unfurl.\n    Throws:\n        InvalidUsageException: in the event that the items passed to `blocks`\n            are not valid [`Blocks`](/slackblocks/latest/reference/blocks).\n    \"\"\"\n\n    def __init__(\n        self,\n        channel: str,\n        text: Optional[str] = \"\",\n        blocks: Optional[Union[List[Block], Block]] = None,\n        attachments: Optional[List[Attachment]] = None,\n        thread_ts: Optional[str] = None,\n        mrkdwn: bool = True,\n        unfurl_links: Optional[bool] = None,\n        unfurl_media: Optional[bool] = None,\n    ) -> \"Message\":\n        super().__init__(channel, text, blocks, attachments, thread_ts, mrkdwn)\n        self.unfurl_links = unfurl_links\n        self.unfurl_media = unfurl_media\n\n    def _resolve(self) -> Dict[str, Any]:\n        result = {**super()._resolve()}\n        if self.unfurl_links is not None:\n            result[\"unfurl_links\"] = self.unfurl_links\n        if self.unfurl_media is not None:\n            result[\"unfurl_media\"] = self.unfurl_media\n        return result\n
"},{"location":"reference/messages/#messages.ResponseType","title":"ResponseType","text":"

Types of messages that can be sent via WebhookMessage.

Source code in slackblocks/messages.py
class ResponseType(Enum):\n    \"\"\"\n    Types of messages that can be sent via `WebhookMessage`.\n    \"\"\"\n\n    EPHEMERAL = \"ephemeral\"\n    IN_CHANNEL = \"in_channel\"\n\n    @staticmethod\n    def get_value(value: Union[\"ResponseType\", str]) -> str:\n        if isinstance(value, ResponseType):\n            return value.value\n        if value not in [response_type.value for response_type in ResponseType]:\n            raise InvalidUsageError(\n                \"ResponseType must be either `ephemeral` or `in_channel`\"\n            )\n        return value\n
"},{"location":"reference/messages/#messages.WebhookMessage","title":"WebhookMessage","text":"

Messages sent via the Slack WebhookClient takes different arguments than those sent via the regular WebClient.

See: https://github.com/slackapi/python-slack-sdk/blob/7e71b73/slack_sdk/webhook/client.py#L28

Parameters:

Name Type Description Default text Optional[str]

markdown text to send in the message. If blocks are provided then this is a fallback to display in notifications.

None attachments Optional[List[Attachment]]

a list of Attachments that form the secondary contents of the message (deprecated).

None blocks Optional[Union[List[Block], Block]]

a list of Blocks to form the contents of the message instead of the contents of text.

None response_type Union[ResponseType, str]

one of ResponseType.EPHEMERAL or ResponseType.IN_CHANNEL. Ephemeral messages are shown only to the requesting user whereas \"in-channel\" messages are shown to all channel participants.

None replace_orginal

when True, the message triggering this response will be replaced by this messaage. Mutually exclusive with delete_original.

required delete_original Optional[bool]

when True, the original message triggering this response will be deleted, and any content of this message will be posted as a new message. Mutually exclusive with replace_orginal.

None unfurl_links Optional[bool]

if True, links in the message will be automatically unfurled.

None unfurl_media Optional[bool]

if True, media from links (e.g. images) will automatically unfurl.

None metadata Optional[Dict[str, Any]]

additional metadata to attach to the message.

None headres

HTTP request headers to include with the message.

required Throws

InvalidUsageError: when any of the passed fields fail validation.

Source code in slackblocks/messages.py
class WebhookMessage:\n    \"\"\"\n    Messages sent via the Slack `WebhookClient` takes different arguments than\n        those sent via the regular `WebClient`.\n\n    See: <https://github.com/slackapi/python-slack-sdk/blob/7e71b73/slack_sdk/webhook/client.py#L28>\n\n    Args:\n        text: markdown text to send in the message. If `blocks` are provided\n            then this is a fallback to display in notifications.\n        attachments: a list of\n            [`Attachments`](/slackblocks/latest/reference/attachments/#attachments.Attachment)\n            that form the secondary contents of the message (deprecated).\n        blocks: a list of [`Blocks`](/slackblocks/latest/reference/blocks) to form the contents\n            of the message instead of the contents of `text`.\n        response_type: one of `ResponseType.EPHEMERAL` or `ResponseType.IN_CHANNEL`.\n            Ephemeral messages are shown only to the requesting user whereas\n            \"in-channel\" messages are shown to all channel participants.\n        replace_orginal: when `True`, the message triggering this response will be\n            replaced by this messaage. Mutually exclusive with `delete_original`.\n        delete_original: when `True`, the original message triggering this response\n            will be deleted, and any content of this message will be posted as a\n            new message. Mutually exclusive with `replace_orginal`.\n        unfurl_links: if `True`, links in the message will be automatically\n            unfurled.\n        unfurl_media: if `True`, media from links (e.g. images) will\n            automatically unfurl.\n        metadata: additional metadata to attach to the message.\n        headres: HTTP request headers to include with the message.\n\n    Throws:\n        InvalidUsageError: when any of the passed fields fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        text: Optional[str] = None,\n        attachments: Optional[List[Attachment]] = None,\n        blocks: Optional[Union[List[Block], Block]] = None,\n        response_type: Union[ResponseType, str] = None,\n        replace_original: Optional[bool] = None,\n        delete_original: Optional[bool] = None,\n        unfurl_links: Optional[bool] = None,\n        unfurl_media: Optional[bool] = None,\n        metadata: Optional[Dict[str, Any]] = None,\n        headers: Optional[Dict[str, str]] = None,\n    ) -> \"WebhookMessage\":\n        self.text = text\n        self.attachments = coerce_to_list(attachments, Attachment, allow_none=True)\n        self.blocks = coerce_to_list(blocks, Block, allow_none=True)\n        self.response_type = ResponseType.get_value(response_type)\n        self.replace_original = replace_original\n        self.delete_original = delete_original\n        self.unfurl_links = unfurl_links\n        self.unfurl_media = unfurl_media\n        self.metadata = metadata\n        self.headers = headers\n\n    def _resolve(self) -> None:\n        webhook_message = {}\n        if self.text is not None:\n            webhook_message[\"text\"] = self.text\n        if self.attachments is not None:\n            webhook_message[\"attachments\"] = [\n                attachment._resolve() for attachment in self.attachments\n            ]\n        if self.blocks is not None:\n            webhook_message[\"blocks\"] = [block._resolve() for block in self.blocks]\n        if self.response_type is not None:\n            webhook_message[\"response_type\"] = self.response_type\n        if self.replace_original is not None:\n            webhook_message[\"replace_original\"] = self.replace_original\n        if self.delete_original is not None:\n            webhook_message[\"delete_original\"] = self.delete_original\n        if self.unfurl_links is not None:\n            webhook_message[\"unfurl_links\"] = self.unfurl_links\n        if self.unfurl_media is not None:\n            webhook_message[\"unfurl_media\"] = self.unfurl_media\n        if self.metadata is not None:\n            webhook_message[\"metadata\"] = self.metadata\n        if self.headers is not None:\n            webhook_message[\"headers\"] = self.headers\n        return webhook_message\n\n    def to_dict(self) -> Dict[str, Any]:\n        return self._resolve()\n\n    def json(self) -> str:\n        return dumps(self._resolve(), indent=4)\n\n    def __repr__(self) -> str:\n        return self.json()\n\n    def __getitem__(self, item):\n        return self._resolve()[item]\n\n    def keys(self) -> Dict[str, Any]:\n        return self._resolve().keys()\n
"},{"location":"reference/modals/","title":"Modals","text":"

Modals are pop-up windows, primarily used for collecting data from users.

This module is kept only for backwards compatibility, modals have been largely subsumed as a subtype of view.

See: https://api.slack.com/surfaces/modals

options: show_bases: false

"},{"location":"reference/modals/#modals.Modal","title":"Modal","text":"

Bases: ModalView

Kept for backwards compatibility - see ModalView

Source code in slackblocks/modals.py
class Modal(ModalView):\n    \"\"\"\n    Kept for backwards compatibility - see\n        [`ModalView`](/slackblocks/latest/reference/views/#views.ModalView)\n    \"\"\"\n\n    def __repr__(self) -> str:\n        return dumps(self._resolve(), indent=4)\n\n    def to_dict(self) -> Dict[str, Any]:\n        return self._resolve()\n\n    def json(self) -> str:\n        return dumps(self._resolve(), indent=4)\n
"},{"location":"reference/objects/","title":"Objects","text":"

Composition objects are the lowest-level primitives used inside of Block objects.

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

"},{"location":"reference/objects/#objects.Confirm","title":"Confirm","text":"

Alias for ConfirmationDialogue to retain backwards compatibility.

See

ConfirmationDialogue. # noqa: E501

Source code in slackblocks/objects.py
class Confirm(ConfirmationDialogue):\n    \"\"\"\n    Alias for `ConfirmationDialogue` to retain backwards compatibility.\n\n    See:\n        [`ConfirmationDialogue`](/slackblocks/latest/reference/objects/#objects.ConfirmationDialogue).  # noqa: E501\n    \"\"\"\n\n    def __init__(self, *args, **kwargs):\n        super(*args, **kwargs)\n
"},{"location":"reference/objects/#objects.ConfirmationDialogue","title":"ConfirmationDialogue","text":"

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.

Parameters:

Name Type Description Default title TextLike

the text heading presented at the top of the dialogue box (max 100 chars).

required text TextLike

the text explaining the decision being made by the user through the dialogue box (max 300 chars).

required confirm TextLike

the text inside the confirmation button of the dialogue box (max 30 chars).

required deny TextLike

the text inside the deny button of the dialogue box (max 30 chars).

required Throws

InvalidUsageError: if any of the arguments fail to pass validation checks.

Source code in slackblocks/objects.py
class ConfirmationDialogue(CompositionObject):\n    \"\"\"\n    An object that defines a dialog that provides a confirmation step\n    to any interactive element. This dialog will ask the user to confirm\n    their action by offering confirm and deny buttons.\n\n    Args:\n        title: the text heading presented at the top of the dialogue box (max 100 chars).\n        text: the text explaining the decision being made by the user through\n            the dialogue box (max 300 chars).\n        confirm: the text inside the confirmation button of the dialogue box (max 30 chars).\n        deny: the text inside the deny button of the dialogue box (max 30 chars).\n\n    Throws:\n        InvalidUsageError: if any of the arguments fail to pass validation checks.\n    \"\"\"\n\n    def __init__(\n        self,\n        title: TextLike,\n        text: TextLike,\n        confirm: TextLike,\n        deny: TextLike,\n    ):\n        super().__init__(type_=CompositionObjectType.CONFIRM)\n        self.title = Text.to_text(title, max_length=100, force_plaintext=True)\n        self.text = Text.to_text(text, max_length=300)\n        self.confirm = Text.to_text(confirm, max_length=30, force_plaintext=True)\n        self.deny = Text.to_text(deny, max_length=30, force_plaintext=True)\n\n    def _resolve(self) -> Dict[str, Any]:\n        return {\n            \"title\": self.title._resolve(),\n            \"text\": self.text._resolve(),\n            \"confirm\": self.confirm._resolve(),\n            \"deny\": self.deny._resolve(),\n        }\n
"},{"location":"reference/objects/#objects.ConversationFilter","title":"ConversationFilter","text":"

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.

Parameters:

Name Type Description Default include Optional[Union[str, List[str]]]

Which types of conversations to include in the list. One of more of im, mpim, private, public.

None exclude_external_shared_channels Optional[bool]

whether to remove shared public channels from the list. See https://api.slack.com/enterprise/shared-channels.

None exclude_bot_users Optional[bool]

whether to remove bot users from the list of conversations.

None Throws

InvalidUsageException: in the event that the user provides none of include, exclude_external_shared_channels, or exclude_bot_users arguments.

Source code in slackblocks/objects.py
class ConversationFilter(CompositionObject):\n    \"\"\"\n    Provides a way to filter the list of options in a conversations select menu or\n    conversations multi-select menu.\n\n    See: <https://api.slack.com/reference/block-kit/composition-objects#filter_conversations>.\n\n    At least one of the available arguments _must_ be provided.\n\n    Args:\n        include: Which types of conversations to include in the list.\n            One of more of `im`, `mpim`, `private`, `public`.\n        exclude_external_shared_channels: whether to remove shared public channels\n            from the list. See <https://api.slack.com/enterprise/shared-channels>.\n        exclude_bot_users: whether to remove bot users from the list of conversations.\n\n    Throws:\n        InvalidUsageException: in the event that the user provides none of `include`,\n            `exclude_external_shared_channels`, or `exclude_bot_users` arguments.\n    \"\"\"\n\n    def __init__(\n        self,\n        include: Optional[Union[str, List[str]]] = None,\n        exclude_external_shared_channels: Optional[bool] = None,\n        exclude_bot_users: Optional[bool] = None,\n    ) -> \"ConversationFilter\":\n        super().__init__(type_=CompositionObjectType.FILTER)\n        if not (\n            include\n            or exclude_external_shared_channels is not None\n            or exclude_bot_users is not None\n        ):\n            raise InvalidUsageError(\n                \"One of `include`, `exclude_external_shared_channels`, or \"\n                \"`exclude_bot_users` is required.\"\n            )\n        self.include = coerce_to_list(include, str, allow_none=True)\n        self.exclude_external_shared_channels = exclude_external_shared_channels\n        self.exclude_bot_users = exclude_bot_users\n\n    def _resolve(self) -> Dict[str, Any]:\n        filter = {}  # Does not include type in JSON\n        if self.include:\n            filter[\"include\"] = self.include\n        if self.exclude_external_shared_channels is not None:\n            filter[\"exclude_external_shared_channels\"] = (\n                self.exclude_external_shared_channels\n            )\n        if self.exclude_bot_users is not None:\n            filter[\"exclude_bot_users\"] = self.exclude_bot_users\n        return filter\n
"},{"location":"reference/objects/#objects.DispatchActionConfiguration","title":"DispatchActionConfiguration","text":"

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

Parameters:

Name Type Description Default trigger_actions_on Union[str, List[str]]

a list of strings representing interaction types that should return a block_actions payload. One or both of on_enter_pressed, on_character_entered.

None Throws

InvalidUsageError: if an invalid value is provided amongst the options for trigger_actions_on.

Source code in slackblocks/objects.py
class DispatchActionConfiguration(CompositionObject):\n    \"\"\"\n    Determines when a plain-text input element will return a `block_action`s interaction payload.\n\n    Args:\n        trigger_actions_on: a list of strings representing interaction types that should return\n            a `block_actions` payload. One or both of `on_enter_pressed`, `on_character_entered`.\n\n    Throws:\n        InvalidUsageError: if an invalid value is provided amongst the options for\n            `trigger_actions_on`.\n    \"\"\"\n\n    def __init__(self, trigger_actions_on: Union[str, List[str]] = None):\n        self.trigger_actions_on = list(\n            set(coerce_to_list(trigger_actions_on, str, min_size=1, max_size=2))\n        )\n        for trigger in self.trigger_actions_on:\n            if trigger not in ALLOWABLE_TRIGGERS:\n                raise InvalidUsageError(\n                    f\"Trigger {trigger} not in allowable values ({ALLOWABLE_TRIGGERS})\"\n                )\n\n    def _resolve(self) -> Dict[str, Any]:\n        dispatch_action_config = {}  # Does not include type in JSON\n        dispatch_action_config[\"trigger_actions_on\"] = self.trigger_actions_on\n        return dispatch_action_config\n
"},{"location":"reference/objects/#objects.InputParameter","title":"InputParameter","text":"

Contains information about an input parameter.

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

Parameters:

Name Type Description Default name str

the name of the input parameter.

required value str

the value associated with the input parameter.

required Source code in slackblocks/objects.py
class InputParameter(CompositionObject):\n    \"\"\"\n    Contains information about an input parameter.\n\n    See <https://api.slack.com/automation/workflows#defining-input-parameters>.\n\n    Args:\n        name: the name of the input parameter.\n        value: the value associated with the input parameter.\n    \"\"\"\n\n    def __init__(self, name: str, value: str):\n        super().__init__(type_=CompositionObjectType.INPUT_PARAMETER)\n        self.name = name\n        self.value = value\n\n    def _resolve(self) -> Dict[str, Any]:\n        input_parameter = {}  # Does not include type in JSON\n        input_parameter[\"name\"] = self.name\n        input_parameter[\"value\"] = self.value\n        return input_parameter\n
"},{"location":"reference/objects/#objects.Option","title":"Option","text":"

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.

Parameters:

Name Type Description Default text TextLike

the text identifying the option (that the user will see).

required value str

the underlying value of that option (not seen by the user).

required description Optional[TextLike]

a more detailed explanation of what the option means (user-facing).

None url Optional[str]

a URL to load in the user's browser when the option is clicked. Only available in OverflowMenus.

None Throws

InvalidUsageError: when any of the provided arguments fail validation.

Source code in slackblocks/objects.py
class Option(CompositionObject):\n    \"\"\"\n    An object that represents a single selectable item in a select menu, multi-select\n    menu, checkbox group, radio button group, or overflow menu.\n\n    See <https://api.slack.com/reference/block-kit/composition-objects#option>.\n\n    Args:\n        text: the text identifying the option (that the user will see).\n        value: the underlying value of that option (not seen by the user).\n        description: a more detailed explanation of what the option means (user-facing).\n        url: a URL to load in the user's browser when the option is clicked.\n            Only available in `OverflowMenus`.\n\n    Throws:\n        InvalidUsageError: when any of the provided arguments fail validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        text: TextLike,\n        value: str,\n        description: Optional[TextLike] = None,\n        url: Optional[str] = None,\n    ) -> \"Option\":\n        super().__init__(type_=CompositionObjectType.OPTION)\n        self.text = Text.to_text(text, max_length=75)\n        self.value = validate_string(value, field_name=\"value\", max_length=75)\n        self.description = Text.to_text(\n            description, max_length=75, force_plaintext=True, allow_none=True\n        )\n        if url and len(url) > 3000:\n            raise InvalidUsageError(\"Option URLs must be less than 3000 characters\")\n        self.url = url\n\n    def _resolve(self) -> Dict[str, Any]:\n        option = {}  # Does not include type in JSON\n        option[\"text\"] = self.text._resolve()\n        option[\"value\"] = self.value\n        if self.description is not None:\n            option[\"description\"] = self.description._resolve()\n        if self.url is not None:\n            option[\"url\"] = self.url\n        return option\n\n    def __eq__(self, other) -> bool:\n        return (\n            self.type == other.type\n            and self.text == other.text\n            and self.value == other.value\n            and self.description == other.description\n            and self.url == other.url\n        )\n
"},{"location":"reference/objects/#objects.OptionGroup","title":"OptionGroup","text":"

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.

Parameters:

Name Type Description Default label TextLike

a label shown above the group of options.

required options List[Option]

a list of Option objects that will form the contents of the group (max 100).

required Throws

InvalidUsageError: if no options are provided or the label is not valid.

Source code in slackblocks/objects.py
class OptionGroup(CompositionObject):\n    \"\"\"\n    Provides a way to group options in a select menu or multi-select menu.\n\n    See <https://api.slack.com/reference/block-kit/composition-objects#option_group>.\n\n    Args:\n        label: a label shown above the group of options.\n        options: a list of `Option` objects that will form the contents of the group (max 100).\n\n    Throws:\n        InvalidUsageError: if no options are provided or the label is not valid.\n    \"\"\"\n\n    def __init__(self, label: TextLike, options: List[Option]):\n        super().__init__(type_=CompositionObjectType.OPTION_GROUP)\n        self.label = Text.to_text(label, max_length=75, force_plaintext=True)\n        self.options = coerce_to_list(\n            options,\n            class_=Option,\n            min_size=1,\n            max_size=100,\n            allow_none=False,\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        option_group = {}  # Does not include type in JSON\n        option_group[\"label\"] = self.label._resolve()\n        option_group[\"options\"] = [option._resolve() for option in self.options]\n        return option_group\n
"},{"location":"reference/objects/#objects.SlackFile","title":"SlackFile","text":"

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.

Parameters:

Name Type Description Default url Optional[str]

the URL can be the url_private or the permalink of the Slack file (only one of url or id can be provided).

required id Optional[str]

the Slack ID of the file (only one of url or id can be provided).

required Throws

InvalidUsageError: if both url and id are provided

Source code in slackblocks/objects.py
class SlackFile(CompositionObject):\n    \"\"\"\n    Defines an object containing Slack file information to be used in an image\n        block or image element.\n\n    This file must be an image and you must provide either the URL or ID (not both).\n\n    See: <https://api.slack.com/reference/block-kit/composition-objects#slack_file>.\n\n    Args:\n        url: the URL can be the `url_private` or the `permalink` of the Slack file\n            (only one of `url` or `id` can be provided).\n        id: the Slack ID of the file\n            (only one of `url` or `id` can be provided).\n\n    Throws:\n        InvalidUsageError: if both `url` and `id` are provided\n    \"\"\"\n\n    def __init__(\n        self,\n        url: Optional[str],\n        id: Optional[str],\n    ) -> \"SlackFile\":\n        super().__init__(CompositionObjectType.SLACK_FILE)\n        if url and id:\n            raise InvalidUsageError(\"Cannot provide both `url` and `id`.\")\n        self.url = url\n        self.id = id\n\n    def _resolve(self) -> Dict[str, Any]:\n        file = {}  # Does not include type in JSON\n        if self.url:\n            file[\"url\"] = self.url\n        if self.id:\n            file[\"id\"] = self.id\n        return file\n
"},{"location":"reference/objects/#objects.Text","title":"Text","text":"

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

Parameters:

Name Type Description Default text str

the text to be rendered in a message (max 3000 characters).

required type_ TextType

either TextType.MARKDOWN or TextType.PLAINTEXT.

MARKDOWN emoji bool

only usable with TextType.PLAINTEXT, if True: emoji will be escaped into text format (e.g. :smile:).

False verbatim bool

only usable with TextType.MARKDOWN, if True: links, channel names, user names will not automatically be rendered as links.

False Throws

InvalidUsageException: if the provided text fails validation.

Source code in slackblocks/objects.py
class Text(CompositionObject):\n    \"\"\"\n    An object containing some text, formatted either as `plain_text` or using\n    Slack's `mrkdwn`.\n\n    Args:\n        text: the text to be rendered in a message (max 3000 characters).\n        type_: either `TextType.MARKDOWN` or `TextType.PLAINTEXT`.\n        emoji: only usable with `TextType.PLAINTEXT`, if True: emoji will be\n            escaped into text format (e.g. `:smile:`).\n        verbatim: only usable with `TextType.MARKDOWN`, if True: links, channel\n            names, user names will not automatically be rendered as links.\n\n    Throws:\n        InvalidUsageException: if the provided `text` fails validation.\n    \"\"\"\n\n    def __init__(\n        self,\n        text: str,\n        type_: TextType = TextType.MARKDOWN,\n        emoji: bool = False,\n        verbatim: bool = False,\n    ) -> \"Text\":\n        super().__init__(type_=CompositionObjectType.TEXT)\n        self.text_type = type_\n        self.text = validate_string(\n            text, field_name=\"text\", min_length=1, max_length=3000\n        )\n        if self.text_type == TextType.MARKDOWN:\n            self.verbatim = verbatim\n            self.emoji = None\n        elif self.text_type == TextType.PLAINTEXT:\n            self.verbatim = None\n            self.emoji = emoji\n\n    def _resolve(self) -> Dict[str, Any]:\n        text = self._attributes()\n        text[\"type\"] = self.text_type.value\n        text[\"text\"] = self.text\n        if self.text_type == TextType.MARKDOWN and self.verbatim:\n            text[\"verbatim\"] = self.verbatim\n        elif self.text_type == TextType.PLAINTEXT and self.emoji:\n            text[\"emoji\"] = self.emoji\n        return text\n\n    @staticmethod\n    def to_text(\n        text: Optional[Union[str, \"Text\"]],\n        force_plaintext: bool = False,\n        max_length: Optional[int] = None,\n        allow_none: bool = False,\n    ) -> Optional[\"Text\"]:\n        \"\"\"\n        Coerces `str` or `Text` objects into `Text` objects.\n\n        Args:\n            text: the `str` or `Text` object to ensure is in `Text` format.\n            force_plaintext: if `True`, forces the `str` or `Text` object\n                into a `Text` object with the type `TextType.PLAINTEXT`.\n            max_length: `text` will be checked against this length in addition\n                to the standard `Text` limit of 3000 characters.\n            allow_none: whether to accept `None` as a valid value for `text`.\n        \"\"\"\n        original_type = text.text_type if isinstance(text, Text) else None\n        type_ = (\n            TextType.PLAINTEXT\n            if force_plaintext\n            else original_type or TextType.MARKDOWN\n        )\n        if text is None:\n            if allow_none:\n                return None\n            raise InvalidUsageError(\"This field cannot have the value None or ''\")\n        if text and max_length and len(text) > max_length:\n            raise InvalidUsageError(\n                f\"`text` length ({len(text)}) exceeds `max_length` ({max_length})\"\n            )\n        if isinstance(text, str):\n            return Text(text=text, type_=type_)\n        if isinstance(text, Text):\n\n            return Text(\n                text=text.text, type_=type_, emoji=text.emoji, verbatim=text.verbatim\n            )\n        else:\n            raise InvalidUsageError(\n                f\"Can only coerce Text object from `str` or `Text`, not `{type(text)}`\"\n            )\n\n    def __str__(self) -> str:\n        return dumps(self._resolve())\n\n    def __len__(self) -> int:\n        return len(self.text)\n\n    def __eq__(self, other) -> bool:\n        return (\n            self.text_type == other.text_type\n            and self.text == other.text\n            and self.emoji == other.emoji\n            and self.vertbatim == other.verbatim\n        )\n
"},{"location":"reference/objects/#objects.Text.to_text","title":"to_text staticmethod","text":"
to_text(\n    text,\n    force_plaintext=False,\n    max_length=None,\n    allow_none=False,\n)\n

Coerces str or Text objects into Text objects.

Parameters:

Name Type Description Default text Optional[Union[str, Text]]

the str or Text object to ensure is in Text format.

required force_plaintext bool

if True, forces the str or Text object into a Text object with the type TextType.PLAINTEXT.

False max_length Optional[int]

text will be checked against this length in addition to the standard Text limit of 3000 characters.

None allow_none bool

whether to accept None as a valid value for text.

False Source code in slackblocks/objects.py
@staticmethod\ndef to_text(\n    text: Optional[Union[str, \"Text\"]],\n    force_plaintext: bool = False,\n    max_length: Optional[int] = None,\n    allow_none: bool = False,\n) -> Optional[\"Text\"]:\n    \"\"\"\n    Coerces `str` or `Text` objects into `Text` objects.\n\n    Args:\n        text: the `str` or `Text` object to ensure is in `Text` format.\n        force_plaintext: if `True`, forces the `str` or `Text` object\n            into a `Text` object with the type `TextType.PLAINTEXT`.\n        max_length: `text` will be checked against this length in addition\n            to the standard `Text` limit of 3000 characters.\n        allow_none: whether to accept `None` as a valid value for `text`.\n    \"\"\"\n    original_type = text.text_type if isinstance(text, Text) else None\n    type_ = (\n        TextType.PLAINTEXT\n        if force_plaintext\n        else original_type or TextType.MARKDOWN\n    )\n    if text is None:\n        if allow_none:\n            return None\n        raise InvalidUsageError(\"This field cannot have the value None or ''\")\n    if text and max_length and len(text) > max_length:\n        raise InvalidUsageError(\n            f\"`text` length ({len(text)}) exceeds `max_length` ({max_length})\"\n        )\n    if isinstance(text, str):\n        return Text(text=text, type_=type_)\n    if isinstance(text, Text):\n\n        return Text(\n            text=text.text, type_=type_, emoji=text.emoji, verbatim=text.verbatim\n        )\n    else:\n        raise InvalidUsageError(\n            f\"Can only coerce Text object from `str` or `Text`, not `{type(text)}`\"\n        )\n
"},{"location":"reference/objects/#objects.TextType","title":"TextType","text":"

Allowable types for Slack Text objects.

tradional 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.

Source code in slackblocks/objects.py
class TextType(Enum):\n    \"\"\"\n    Allowable types for Slack Text objects.\n\n    MARKDOWN: tradional markdown formatting, see\n        <https://api.slack.com/reference/surfaces/formatting#basic-formatting>\n    PLAINTEXT: simple Unicode text with no formatting (e.g. bold) features.\n\n    N.B: some usages of Text objects only allow the `PLAINTEXT` variety.\n    \"\"\"\n\n    MARKDOWN = \"mrkdwn\"\n    PLAINTEXT = \"plain_text\"\n
"},{"location":"reference/objects/#objects.Trigger","title":"Trigger","text":"

Contains information about a trigger.

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

Parameters:

Name Type Description Default url str

a link trigger URL, see https://api.slack.com/automation/triggers/link

required customizable_input_parameters Optional[Union[InputParameter, List[InputParameter]]]

a list of InputParameter objects which map to those parameters defined on the Workflow in which they are provided.

required Throws

InvalidUsageError: when any of the items in customizable_input_parameters is not a valid InputParameter.

Source code in slackblocks/objects.py
class Trigger(CompositionObject):\n    \"\"\"\n    Contains information about a trigger.\n\n    See: <https://api.slack.com/automation/triggers>.\n\n    Args:\n        url: a link trigger URL, see\n            <https://api.slack.com/automation/triggers/link>\n        customizable_input_parameters: a list of `InputParameter` objects\n            which map to those parameters defined on the Workflow in\n            which they are provided.\n\n    Throws:\n        InvalidUsageError: when any of the items in\n            `customizable_input_parameters` is not a valid `InputParameter`.\n    \"\"\"\n\n    def __init__(\n        self,\n        url: str,\n        customizable_input_parameters: Optional[\n            Union[InputParameter, List[InputParameter]]\n        ],\n    ) -> \"Trigger\":\n        super().__init__(type_=CompositionObjectType.TRIGGER)\n        self.url = url\n        self.customizable_input_parameters = coerce_to_list(\n            customizable_input_parameters, InputParameter, allow_none=True\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        trigger = {}  # Does not include type in JSON\n        trigger[\"url\"] = self.url\n        if self.customizable_input_parameters:\n            trigger[\"customizable_input_parameters\"] = [\n                parameter._resolve() for parameter in self.customizable_input_parameters\n            ]\n        return trigger\n
"},{"location":"reference/objects/#objects.Workflow","title":"Workflow","text":"

Contains information about a workflow.

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

Parameters:

Name Type Description Default trigger Trigger

a Trigger object that will initiate the workflow.

required Source code in slackblocks/objects.py
class Workflow(CompositionObject):\n    \"\"\"\n    Contains information about a workflow.\n\n    See <https://api.slack.com/automation/workflows>.\n\n    Args:\n        trigger: a `Trigger` object that will initiate the workflow.\n    \"\"\"\n\n    def __init__(self, trigger: Trigger) -> \"Workflow\":\n        super().__init__(type_=CompositionObjectType.WORKFLOW)\n        self.trigger = trigger\n\n    def _resolve(self) -> Dict[str, Any]:\n        workflow = {}  # Does not include type in JSON\n        workflow[\"trigger\"] = self.trigger._resolve()\n        return workflow\n
"},{"location":"reference/rich_text/","title":"Rich Text","text":"

Rich Text elements can be used to enhance text-based messages with code, list, quotations and formatted text (including options not available in traditional markdown like strikethrough).

These formatting elements can only be used within a RichTextBlock.

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

"},{"location":"reference/rich_text/#rich-text-elements-primitives","title":"Rich Text Elements (Primitives)","text":"

Rich text elements are the primitive elements used to populate the rich text object \"containers\", which are then fed into the RichTextBlock.

"},{"location":"reference/rich_text/#rich_text.elements.RichText","title":"RichText","text":"

The core unit of the rich text API. Allows for the formatting of text with visual styles like bolding, italics and strikethroughs. Combined with higher-level containers like RichTextSection, RichText can be used to create complicated and deeply nested rich text within Slack messages.

Parameters:

Name Type Description Default text str

the text content to render.

required bold Optional[bool]

whether to render the given text in bold font.

None italic Optional[bool]

whether to render the given text in italics.

None strike Optional[bool]

whether to render the given text with a \"strikethrough\".

None code Optional[bool]

whether to render the given text as an inline code snippet (monospaced).

None Source code in slackblocks/rich_text/elements.py
class RichText(RichTextElement):\n    \"\"\"\n    The core unit of the rich text API. Allows for the formatting of text\n        with visual styles like bolding, italics and strikethroughs.\n        Combined with higher-level containers like `RichTextSection`,\n        `RichText` can be used to create complicated and deeply nested\n        rich text within Slack messages.\n\n    Args:\n        text: the text content to render.\n        bold: whether to render the given text in bold font.\n        italic: whether to render the given text in italics.\n        strike: whether to render the given text with a \"strikethrough\".\n        code: whether to render the given text as an inline code snippet\n            (monospaced).\n    \"\"\"\n\n    def __init__(\n        self,\n        text: str,\n        bold: Optional[bool] = None,\n        italic: Optional[bool] = None,\n        strike: Optional[bool] = None,\n        code: Optional[bool] = None,\n    ) -> None:\n        super().__init__(type_=RichTextElementType.TEXT)\n        self.text = text\n        self.bold = bold\n        self.italic = italic\n        self.strike = strike\n        self.code = code\n\n    def _resolve(self) -> Dict[str, Any]:\n        rich_text = super()._resolve()\n        rich_text[\"text\"] = self.text\n        style = {}\n        if self.bold is not None:\n            style[\"bold\"] = self.bold\n        if self.italic is not None:\n            style[\"italic\"] = self.italic\n        if self.strike is not None:\n            style[\"strike\"] = self.strike\n        if self.code is not None:\n            style[\"code\"] = self.code\n        if style:\n            rich_text[\"style\"] = style\n        return rich_text\n
"},{"location":"reference/rich_text/#rich_text.elements.RichTextChannel","title":"RichTextChannel","text":"

Rich text rendering of a Slack channel (e.g. #general).

See: https://api.slack.com/reference/block-kit/blocks#channel-element-type

Parameters:

Name Type Description Default channel_id str

the ID of the channel to render. You can get this from the channel settings or the URL (if using Slack in the browser).

required bold Optional[bool]

whether to render the given channel in bold font.

None italic Optional[bool]

whether to render the given channel in italics.

None strike Optional[bool]

whether to render the given channel with a \"strikethrough\".

None highlight Optional[bool]

whether to give the channel a distinct highlight when rendered.

None client_highlight Optional[bool]

???

None unlink Optional[bool]

whether to remove the link to the channel from the channel when rendered.

None Source code in slackblocks/rich_text/elements.py
class RichTextChannel(RichTextElement):\n    \"\"\"\n    Rich text rendering of a Slack channel (e.g. #general).\n\n    See: <https://api.slack.com/reference/block-kit/blocks#channel-element-type>\n\n    Args:\n        channel_id: the ID of the channel to render. You can get this from\n            the channel settings or the URL (if using Slack in the browser).\n        bold: whether to render the given channel in bold font.\n        italic: whether to render the given channel in italics.\n        strike: whether to render the given channel with a \"strikethrough\".\n        highlight: whether to give the channel a distinct highlight when rendered.\n        client_highlight: ???\n        unlink: whether to remove the link to the channel from the channel when\n            rendered.\n    \"\"\"\n\n    def __init__(\n        self,\n        channel_id: str,\n        bold: Optional[bool] = None,\n        italic: Optional[bool] = None,\n        strike: Optional[bool] = None,\n        highlight: Optional[bool] = None,\n        client_highlight: Optional[bool] = None,\n        unlink: Optional[bool] = None,\n    ) -> None:\n        super().__init__(RichTextElementType.CHANNEL)\n        self.channel_id = channel_id\n        self.bold = bold\n        self.italic = italic\n        self.strike = strike\n        self.highlight = highlight\n        self.client_highlight = client_highlight\n        self.unlink = unlink\n\n    def _resolve(self) -> Dict[str, Any]:\n        channel = super()._resolve()\n        channel[\"channel_id\"] = self.channel_id\n        style = {}\n        if self.bold is not None:\n            style[\"bold\"] = self.bold\n        if self.italic is not None:\n            style[\"italic\"] = self.italic\n        if self.strike is not None:\n            style[\"strike\"] = self.strike\n        if self.highlight is not None:\n            style[\"highlight\"] = self.highlight\n        if self.client_highlight is not None:\n            style[\"client_highlight\"] = self.client_highlight\n        if self.unlink is not None:\n            style[\"unlink\"] = self.unlink\n        if style:\n            channel[\"style\"] = style\n        return channel\n
"},{"location":"reference/rich_text/#rich_text.elements.RichTextEmoji","title":"RichTextEmoji","text":"

A rich text element for displaying an emoji.

The emoji can either be one built in to Slack or a custom workspace emoji.

See: https://api.slack.com/reference/block-kit/blocks#emoji-element-type

Parameters:

Name Type Description Default name str

the unique name of the emoji to represent e.g. \"wave\".

required Throws

InvalidUsageError: if the emoji name provided is empty.

Source code in slackblocks/rich_text/elements.py
class RichTextEmoji(RichTextElement):\n    \"\"\"\n    A rich text element for displaying an emoji.\n\n    The emoji can either be one built in to Slack or a custom workspace emoji.\n\n    See: <https://api.slack.com/reference/block-kit/blocks#emoji-element-type>\n\n    Args:\n        name: the unique name of the emoji to represent e.g. \"wave\".\n\n    Throws:\n        InvalidUsageError: if the emoji `name` provided is empty.\n    \"\"\"\n\n    def __init__(self, name: str) -> None:\n        super().__init__(RichTextElementType.EMOJI)\n        self.name = validate_string(name, field_name=\"name\", min_length=1)\n\n    def _resolve(self) -> Dict[str, Any]:\n        emoji = super()._resolve()\n        emoji[\"name\"] = self.name\n        return emoji\n
"},{"location":"reference/rich_text/#rich_text.elements.RichTextLink","title":"RichTextLink","text":"

A rich text primitive to display links in text.

See: https://api.slack.com/reference/block-kit/blocks#link-element-type

Parameters:

Name Type Description Default url str

the url which the link will point to.

required text Optional[str]

the text to render with the link. If not provided, the raw URL will be used.

None unsafe Optional[bool]

whether the link is \"safe\".

None bold Optional[bool]

whether to render the given text in bold font.

None italic Optional[bool]

whether to render the given text in italics.

None strike Optional[bool]

whether to render the given text with a \"strikethrough\".

None code Optional[bool]

whether to render the given text as an inline code snippet (monospaced).

None Source code in slackblocks/rich_text/elements.py
class RichTextLink(RichTextElement):\n    \"\"\"\n    A rich text primitive to display links in text.\n\n    See: <https://api.slack.com/reference/block-kit/blocks#link-element-type>\n\n    Args:\n        url: the url which the link will point to.\n        text: the text to render with the link. If not provided, the raw URL\n            will be used.\n        unsafe: whether the link is \"safe\".\n        bold: whether to render the given text in bold font.\n        italic: whether to render the given text in italics.\n        strike: whether to render the given text with a \"strikethrough\".\n        code: whether to render the given text as an inline code snippet\n            (monospaced).\n    \"\"\"\n\n    def __init__(\n        self,\n        url: str,\n        text: Optional[str] = None,\n        unsafe: Optional[bool] = None,\n        bold: Optional[bool] = None,\n        italic: Optional[bool] = None,\n        strike: Optional[bool] = None,\n        code: Optional[bool] = None,\n    ) -> None:\n        super().__init__(type_=RichTextElementType.LINK)\n        self.url = url\n        self.text = text\n        self.unsafe = unsafe\n        self.bold = bold\n        self.italic = italic\n        self.strike = strike\n        self.code = code\n\n    def _resolve(self) -> Dict[str, Any]:\n        link = super()._resolve()\n        link[\"url\"] = self.url\n        if self.text is not None:\n            link[\"text\"] = self.text\n        if self.unsafe is not None:\n            link[\"unsafe\"] = self.unsafe\n        style = {}\n        if self.bold is not None:\n            style[\"bold\"] = self.bold\n        if self.italic is not None:\n            style[\"italic\"] = self.italic\n        if self.strike is not None:\n            style[\"strike\"] = self.strike\n        if self.code is not None:\n            style[\"code\"] = self.code\n        if style:\n            link[\"style\"] = style\n        return link\n
"},{"location":"reference/rich_text/#rich_text.elements.RichTextUser","title":"RichTextUser","text":"

Rich text element for representing users in RichTextBlocks.

See: https://api.slack.com/reference/block-kit/blocks#user-element-type.

Parameters:

Name Type Description Default user_id str

the Slack ID of the user in question, you can get these from users' profiles or Slack client requests.

required bold Optional[bool]

whether to render the given user in bold font.

None italic Optional[bool]

whether to render the given user in italics.

None strike Optional[bool]

whether to render the given user with a \"strikethrough\".

None highlight Optional[bool]

whether to give the user a distinct highlight when rendered.

None client_highlight Optional[bool]

???

None unlink Optional[bool]

whether to remove the link to the user from the channel when rendered.

None Source code in slackblocks/rich_text/elements.py
class RichTextUser(RichTextElement):\n    \"\"\"\n    Rich text element for representing users in\n        [`RichTextBlocks`](/slackblocks/latest/reference/blocks/#blocks.RichTextBlock).\n\n    See: <https://api.slack.com/reference/block-kit/blocks#user-element-type>.\n\n    Args:\n        user_id: the Slack ID of the user in question, you can get these\n            from users' profiles or Slack client requests.\n        bold: whether to render the given user in bold font.\n        italic: whether to render the given user in italics.\n        strike: whether to render the given user with a \"strikethrough\".\n        highlight: whether to give the user a distinct highlight when rendered.\n        client_highlight: ???\n        unlink: whether to remove the link to the user from the channel when\n            rendered.\n    \"\"\"\n\n    def __init__(\n        self,\n        user_id: str,\n        bold: Optional[bool] = None,\n        italic: Optional[bool] = None,\n        strike: Optional[bool] = None,\n        highlight: Optional[bool] = None,\n        client_highlight: Optional[bool] = None,\n        unlink: Optional[bool] = None,\n    ) -> None:\n        super().__init__(RichTextElementType.USER)\n        self.user_id = user_id\n        self.bold = bold\n        self.italic = italic\n        self.strike = strike\n        self.highlight = highlight\n        self.client_highlight = client_highlight\n        self.unlink = unlink\n\n    def _resolve(self) -> Dict[str, Any]:\n        user = super()._resolve()\n        user[\"user_id\"] = self.user_id\n        style = {}\n        if self.bold is not None:\n            style[\"bold\"] = self.bold\n        if self.italic is not None:\n            style[\"italic\"] = self.italic\n        if self.strike is not None:\n            style[\"strike\"] = self.strike\n        if self.highlight is not None:\n            style[\"highlight\"] = self.highlight\n        if self.client_highlight is not None:\n            style[\"client_highlight\"] = self.client_highlight\n        if self.unlink is not None:\n            style[\"unlink\"] = self.unlink\n        if style:\n            user[\"style\"] = style\n        return user\n
"},{"location":"reference/rich_text/#rich_text.elements.RichTextUserGroup","title":"RichTextUserGroup","text":"

Rich text element for representing groups of users in RichTextBlocks`.

See: https://api.slack.com/reference/block-kit/blocks#user-element-type.

Parameters:

Name Type Description Default user_group_id str

the Slack ID of the user group being represented.

required bold Optional[bool]

whether to render the given user in bold font.

None italic Optional[bool]

whether to render the given user in italics.

None strike Optional[bool]

whether to render the given user with a \"strikethrough\".

None highlight Optional[bool]

whether to give the user a distinct highlight when rendered.

None client_highlight Optional[bool]

???

None unlink Optional[bool]

whether to remove the link to the user from the channel when rendered.

None Source code in slackblocks/rich_text/elements.py
class RichTextUserGroup(RichTextElement):\n    \"\"\"\n    Rich text element for representing groups of users in\n        [`RichTextBlocks`](/slackblocks/latest/reference/blocks/#blocks.RichTextBlock)`.\n\n    See: <https://api.slack.com/reference/block-kit/blocks#user-element-type>.\n\n    Args:\n        user_group_id: the Slack ID of the user group being represented.\n        bold: whether to render the given user in bold font.\n        italic: whether to render the given user in italics.\n        strike: whether to render the given user with a \"strikethrough\".\n        highlight: whether to give the user a distinct highlight when rendered.\n        client_highlight: ???\n        unlink: whether to remove the link to the user from the channel when\n            rendered.\n    \"\"\"\n\n    def __init__(\n        self,\n        user_group_id: str,\n        bold: Optional[bool] = None,\n        italic: Optional[bool] = None,\n        strike: Optional[bool] = None,\n        highlight: Optional[bool] = None,\n        client_highlight: Optional[bool] = None,\n        unlink: Optional[bool] = None,\n    ) -> None:\n        super().__init__(RichTextElementType.USER_GROUP)\n        self.user_group_id = user_group_id\n        self.bold = bold\n        self.italic = italic\n        self.strike = strike\n        self.highlight = highlight\n        self.client_highlight = client_highlight\n        self.unlink = unlink\n\n    def _resolve(self) -> Dict[str, Any]:\n        user_group = super()._resolve()\n        user_group[\"user_group_id\"] = self.user_group_id\n        style = {}\n        if self.bold is not None:\n            style[\"bold\"] = self.bold\n        if self.italic is not None:\n            style[\"italic\"] = self.italic\n        if self.strike is not None:\n            style[\"strike\"] = self.strike\n        if self.highlight is not None:\n            style[\"highlight\"] = self.highlight\n        if self.client_highlight is not None:\n            style[\"client_highlight\"] = self.client_highlight\n        if self.unlink is not None:\n            style[\"unlink\"] = self.unlink\n        if style:\n            user_group[\"style\"] = style\n        return user_group\n
"},{"location":"reference/rich_text/#rich-text-objects-containers","title":"Rich Text Objects (Containers)","text":"

Rich text objects are containers for rich text elements.

These obejects form the contents of the RichTextBlock.

"},{"location":"reference/rich_text/#rich_text.objects.ListType","title":"ListType","text":"

An Enum that lists the available types of rich text lists.

  • ListType.BULLET: an unorderd (bulleted) list.
  • ListType.ORDERED: an ordered (numbered) list.
Source code in slackblocks/rich_text/objects.py
class ListType(Enum):\n    \"\"\"\n    An `Enum` that lists the available types of rich text lists.\n\n    - `ListType.BULLET`: an unorderd (bulleted) list.\n    - `ListType.ORDERED`: an ordered (numbered) list.\n    \"\"\"\n\n    BULLET = \"bullet\"\n    ORDERED = \"ordered\"\n\n    def all() -> List[str]:\n        return [list_type.value for list_type in ListType]\n
"},{"location":"reference/rich_text/#rich_text.objects.RichTextCodeBlock","title":"RichTextCodeBlock","text":"

A rich text element for representing blocks of code in RichTextBlocks.

This is roughly equivalent to the triple-backtick ```code``` syntax in markdown.

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

Parameters:

Name Type Description Default elements Union[RichTextElement, List[RichTextElement]]

one or more rich text primitive objexts (e.g. RichText).

required border Optional[int]

the thickness (in pixels) of the border around the code block.

None Throws

InvalidUsageError: if any of the items in elements aren't valid rich text elements.

Source code in slackblocks/rich_text/objects.py
class RichTextCodeBlock(RichTextObject):\n    \"\"\"\n    A rich text element for representing blocks of code in\n        [`RichTextBlocks`](reference/blocks/#blocks.RichTextBlock).\n\n    This is roughly equivalent to the triple-backtick \\`\\`\\``code`\\`\\`\\` syntax in markdown.\n\n    See: <https://api.slack.com/reference/block-kit/blocks#rich_text_preformatted>.\n\n    Args:\n        elements: one or more rich text primitive objexts\n            (e.g. [`RichText`](/slackblocks/latest/reference/rich_text/#rich_text.RichText)).\n        border: the thickness (in pixels) of the border around the code block.\n\n    Throws:\n        InvalidUsageError: if any of the items in `elements` aren't valid rich\n            text elements.\n    \"\"\"\n\n    def __init__(\n        self,\n        elements: Union[RichTextElement, List[RichTextElement]],\n        border: Optional[int] = None,\n    ) -> None:\n        super().__init__(type_=RichTextObjectType.PREFORMATTED)\n        self.elements = coerce_to_list(\n            elements,\n            (\n                RichText,\n                RichTextChannel,\n                RichTextEmoji,\n                RichTextLink,\n                RichTextUser,\n                RichTextUserGroup,\n            ),\n        )\n        self.border = border\n\n    def _resolve(self) -> Dict[str, Any]:\n        preformatted = super()._resolve()\n        preformatted[\"elements\"] = [element._resolve() for element in self.elements]\n        if self.border is not None:\n            preformatted[\"border\"] = self.border\n        return preformatted\n
"},{"location":"reference/rich_text/#rich_text.objects.RichTextList","title":"RichTextList","text":"

Renders to a HTML list containing rich text elements.

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

Parameters:

Name Type Description Default style Union[str, ListType]

one of ListType.BULLET or ListType.ORDERED.

required elements Union[RichTextSection, List[RichTextSection]]

a list of (possibly nested) RichTextSection elements. Each object in this list will be rendered as a list item.

required indent Optional[int]

indent (in pixels) of each list item.

None offset Optional[int]

offset (in pixels) of each list item.

0 border Optional[int]

thickness (in pixels) of the (optional) border around the list.

0 Throws

InvalidUsageError: if style is not a valid ListType or any of the items in elements isn't a valid RichTextSection.

Source code in slackblocks/rich_text/objects.py
class RichTextList(RichTextObject):\n    \"\"\"\n    Renders to a HTML list containing rich text elements.\n\n    See: <https://api.slack.com/reference/block-kit/blocks#rich_text_list>.\n\n    Args:\n        style: one of `ListType.BULLET` or `ListType.ORDERED`.\n        elements: a list of (possibly nested) `RichTextSection` elements.\n            Each object in this list will be rendered as a list item.\n        indent: indent (in pixels) of each list item.\n        offset: offset (in pixels) of each list item.\n        border: thickness (in pixels) of the (optional) border around the list.\n\n    Throws:\n        InvalidUsageError: if style is not a valid `ListType` or any of the\n            items in `elements` isn't a valid `RichTextSection`.\n    \"\"\"\n\n    def __init__(\n        self,\n        style: Union[str, ListType],\n        elements: Union[RichTextSection, List[RichTextSection]],\n        indent: Optional[int] = None,\n        offset: Optional[int] = 0,\n        border: Optional[int] = 0,\n    ) -> None:\n        super().__init__(type_=RichTextObjectType.LIST)\n        if isinstance(style, str):\n            if style in ListType.all():\n                self.style = style\n            else:\n                raise InvalidUsageError(f\"`style` must be one of [{ListType.all()}]\")\n        elif isinstance(style, ListType):\n            self.style = style.value\n        self.elements = coerce_to_list(elements, RichTextSection, min_size=1)\n        self.indent = validate_int(indent, allow_none=True)\n        self.offset = validate_int(offset, allow_none=True)\n        self.border = validate_int(border, allow_none=True)\n\n    def _resolve(self) -> Dict[str, Any]:\n        rich_text_list = super()._resolve()\n        rich_text_list[\"elements\"] = [element._resolve() for element in self.elements]\n        rich_text_list[\"style\"] = self.style\n        if self.indent is not None:\n            rich_text_list[\"indent\"] = self.indent\n        if self.offset is not None:\n            rich_text_list[\"offset\"] = self.offset\n        if self.border is not None:\n            rich_text_list[\"border\"] = self.border\n        return rich_text_list\n
"},{"location":"reference/rich_text/#rich_text.objects.RichTextQuote","title":"RichTextQuote","text":"

A rich text object for representing a block quote.

Block quotes are presented with a vertical bar to the left hand side of the text.

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

Parameters:

Name Type Description Default elements Union[RichTextElement, List[RichTextElement]]

one or more rich text primitive objexts (e.g. RichText).

required border Optional[int]

the thickness (in pixels) of the border around the code block.

None Source code in slackblocks/rich_text/objects.py
class RichTextQuote(RichTextObject):\n    \"\"\"\n    A rich text object for representing a block quote.\n\n    Block quotes are presented with a vertical bar to the left hand side of\n        the text.\n\n    See: <https://api.slack.com/reference/block-kit/blocks#rich_text_quote>\n\n    Args:\n        elements: one or more rich text primitive objexts\n            (e.g. [`RichText`](/slackblocks/latest/reference/rich_text/#rich_text.RichText)).\n        border: the thickness (in pixels) of the border around the code block.\n    \"\"\"\n\n    def __init__(\n        self,\n        elements: Union[RichTextElement, List[RichTextElement]],\n        border: Optional[int] = None,\n    ) -> None:\n        super().__init__(RichTextObjectType.QUOTE)\n        self.elements = coerce_to_list(\n            elements,\n            (\n                RichText,\n                RichTextChannel,\n                RichTextEmoji,\n                RichTextLink,\n                RichTextUser,\n                RichTextUserGroup,\n            ),\n        )\n        self.border = border\n\n    def _resolve(self) -> Dict[str, Any]:\n        quote = super()._resolve()\n        quote[\"elements\"] = [element._resolve() for element in self.elements]\n        if self.border is not None:\n            quote[\"border\"] = self.border\n        return quote\n
"},{"location":"reference/rich_text/#rich_text.objects.RichTextSection","title":"RichTextSection","text":"

The most basic rich text container object, which takes rich text elements and renders them when RichTextSection is passed to a RichTextBlock.

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

Parameters:

Name Type Description Default elements Union[RichTextElement, List[RichTextElement]]

one or more rich text elements that will form the content of the section. e.g. RichText, RichTextLink.

required Throws

InvalidUsageError: if any of the items passed to elements isn't a valid RichTextObject.

Source code in slackblocks/rich_text/objects.py
class RichTextSection(RichTextObject):\n    \"\"\"\n    The most basic rich text container object, which takes rich text elements\n        and renders them when `RichTextSection` is passed to a\n        [`RichTextBlock`](/slackblocks/latest/reference/blocks/#blocks.RichTextBlock).\n\n    See: <https://api.slack.com/reference/block-kit/blocks#rich_text_section>.\n\n    Args:\n        elements: one or more rich text elements that will form the content of the section.\n            e.g. `RichText`, `RichTextLink`.\n\n    Throws:\n        InvalidUsageError: if any of the items passed to `elements` isn't a valid\n            `RichTextObject`.\n    \"\"\"\n\n    def __init__(self, elements: Union[RichTextElement, List[RichTextElement]]) -> None:\n        super().__init__(type_=RichTextObjectType.SECTION)\n        self.elements = coerce_to_list(\n            elements,\n            class_=(\n                RichTextChannel,\n                RichTextEmoji,\n                RichTextLink,\n                RichText,\n                RichTextUser,\n                RichTextUserGroup,\n            ),\n            min_size=1,\n        )\n\n    def _resolve(self) -> Dict[str, Any]:\n        section = super()._resolve()\n        section[\"elements\"] = [element._resolve() for element in self.elements]\n        return section\n
"},{"location":"reference/utils/","title":"Utilities","text":"

This module collects various utility functions used for validating the input to Messages, Blocks, Elements and Objects.

"},{"location":"reference/utils/#utils.coerce_to_list","title":"coerce_to_list","text":"
coerce_to_list(\n    object_or_objects,\n    class_,\n    allow_none=False,\n    min_size=None,\n    max_size=None,\n)\n

Takes and object or list of objects and validates its contents, ensuring that the resulting object is a list.

Parameters:

Name Type Description Default object_or_objects Union[T, List[T]]

the Python object or objects to validate and convert to a list.

required class_ Union[Any, List[Any]]

the Python type (or class) of objects expected in the list.

required allow_none bool

whether or not None is a valid input (and thus output) option.

False min_size Optional[int]

if provided, the length of object_or_objects cannot be smaller than this.

None max_size Optional[int]

if provided, the length of object_or_objects cannot be larger than this.

None

Returns:

Type Description List[T]

object_or_objects if it was a valid list, [object_or_objects] if it was a valid object, or None if provided and allowed.

Throws

InvalidUsageError: if any of the validation checks fail.

Source code in slackblocks/utils.py
def coerce_to_list(\n    object_or_objects: Union[T, List[T]],\n    class_: Union[Any, List[Any]],\n    allow_none: bool = False,\n    min_size: Optional[int] = None,\n    max_size: Optional[int] = None,\n) -> List[T]:\n    \"\"\"\n    Takes and object or list of objects and validates its contents, ensuring that the\n    resulting object is a list.\n\n    Args:\n        object_or_objects: the Python object or objects to validate and convert to a list.\n        class_: the Python type (or class) of objects expected in the list.\n        allow_none: whether or not None is a valid input (and thus output) option.\n        min_size: if provided, the length of `object_or_objects` cannot be smaller than this.\n        max_size: if provided, the length of `object_or_objects` cannot be larger than this.\n\n    Returns:\n        `object_or_objects` if it was a valid list, `[object_or_objects]` if it was a valid\n            object, or `None` if provided and allowed.\n\n    Throws:\n        InvalidUsageError: if any of the validation checks fail.\n    \"\"\"\n    if object_or_objects is None and allow_none:\n        return None\n    if object_or_objects is None and not allow_none:\n        raise InvalidUsageError(\n            f\"Type of {object_or_objects} ({type(object_or_objects)})) is \"\n            f\"None should be type `{class_}`.\"\n        )\n\n    if isinstance(object_or_objects, List):\n        items = object_or_objects\n    else:\n        items = [\n            object_or_objects,\n        ]\n\n    for item in items:\n        if not isinstance(class_, Tuple):\n            class_ = (class_,)\n        if not isinstance(item, class_):\n            raise InvalidUsageError(\n                f\"Type of {item} ({type(item)})) inconsistent with expected type {class_}.\"\n            )\n\n    if items is not None:\n        length = len(items)\n        if min_size is not None and length < min_size:\n            raise InvalidUsageError(\n                f\"Size ({length}) of list of {type(class_)} is less than `min_size` ({min_size})\"\n            )\n\n        if max_size is not None and length > max_size:\n            raise InvalidUsageError(\n                f\"Size ({length}) of list of {type(class_)} exceeds `max_size` ({max_size})\"\n            )\n\n    return items\n
"},{"location":"reference/utils/#utils.is_hex","title":"is_hex","text":"
is_hex(string)\n

Determines whether a given string is a valid hexadecimal number.

Parameters:

Name Type Description Default string str

the string to examine for hex characters.

required

Returns:

Type Description bool

True if the string is a valid hexadecimal number, otherwise False.

Source code in slackblocks/utils.py
def is_hex(string: str) -> bool:\n    \"\"\"\n    Determines whether a given string is a valid hexadecimal number.\n\n    Args:\n        string: the string to examine for hex characters.\n\n    Returns:\n        `True` if the string is a valid hexadecimal number, otherwise `False`.\n    \"\"\"\n    return all(char in hexdigits for char in string)\n
"},{"location":"reference/utils/#utils.validate_action_id","title":"validate_action_id","text":"
validate_action_id(action_id, allow_none=False)\n

Action IDs are used in the handing of user interactivity within Slack blocks. This function checks that a given action_id is valid as per the requirements imposed by the Slack API.

See: https://api.slack.com/interactivity/handling

Parameters:

Name Type Description Default action_id str

the action_id string to validate for correctness as per the Slack API.

required allow_none bool

whether to accept None as a valid value for action_id.

False

Returns:

Type Description Optional[str]

The original value action_id if all validation checks pass.

Throws

InvalidUsageError if any of the validation checks fail.

Source code in slackblocks/utils.py
def validate_action_id(action_id: str, allow_none: bool = False) -> Optional[str]:\n    \"\"\"\n    Action IDs are used in the handing of user interactivity within Slack blocks.\n    This function checks that a given `action_id` is valid as per the requirements\n    imposed by the Slack API.\n\n    See: <https://api.slack.com/interactivity/handling>\n\n    Args:\n        action_id: the action_id string to validate for correctness as per the Slack API.\n        allow_none: whether to accept `None` as a valid value for `action_id`.\n\n    Returns:\n        The original value `action_id` if all validation checks pass.\n\n    Throws:\n        InvalidUsageError if any of the validation checks fail.\n    \"\"\"\n    if action_id is None:\n        if not allow_none:\n            raise InvalidUsageError(\"`action_id` cannot be None.\")\n    else:\n        length = len(action_id)\n        if length < 1:\n            raise InvalidUsageError(\"`action_id` cannot be empty.\")\n        if length > 255:\n            raise InvalidUsageError(\n                f\"`action_id` length ({length}) exceeds limit of 255 characters (id: {action_id}).\"\n            )\n    return action_id\n
"},{"location":"reference/utils/#utils.validate_int","title":"validate_int","text":"
validate_int(\n    num, min_value=None, max_value=None, allow_none=False\n)\n

Performs basic validation checks against a given integer.

Parameters:

Name Type Description Default num Union[int, None]

the number to validate.

required min_value Optional[int]

if num is less than this value, an error will be thrown.

None max_value Optional[int]

if num is greater than this value, an error will be thrown.

None allow_none bool

whether None is a valid value for num. If num is None allow_none is False, an error will be thrown.

False

Returns:

Type Description int

The original value of num if it passes all validation checks.

Throws

InvalidUsageError: if any of the validation checks fail.

Source code in slackblocks/utils.py
def validate_int(\n    num: Union[int, None],\n    min_value: Optional[int] = None,\n    max_value: Optional[int] = None,\n    allow_none: bool = False,\n) -> int:\n    \"\"\"\n    Performs basic validation checks against a given integer.\n\n    Args:\n        num: the number to validate.\n        min_value: if `num` is less than this value, an error will be thrown.\n        max_value: if `num` is greater than this value, an error will be thrown.\n        allow_none: whether `None` is a valid value for `num`. If `num` is `None`\n            `allow_none` is `False`, an error will be thrown.\n\n    Returns:\n        The original value of `num` if it passes all validation checks.\n\n    Throws:\n        InvalidUsageError: if any of the validation checks fail.\n    \"\"\"\n    if num is None and not allow_none:\n        raise InvalidUsageError(\"`num` is None, which is disallowed.\")\n    if min_value is not None:\n        if num < min_value:\n            raise InvalidUsageError(f\"{num} is less than the minimum {min_value}\")\n    if max_value is not None:\n        if num > max_value:\n            raise InvalidUsageError(f\"{num} is less than the minimum {max_value}\")\n    return num\n
"},{"location":"reference/utils/#utils.validate_string","title":"validate_string","text":"
validate_string(\n    string,\n    field_name,\n    max_length=None,\n    min_length=None,\n    allow_none=False,\n)\n

Performs basic validation actions (e.g. length checking) on a given string based on the provided criteria.

Parameters:

Name Type Description Default string Optional[str]

the string to validate

required field_name str

the name of the field the string belongs to (for error reporting purposes).

required min_length Optional[int]

if the string is less than this length, an error will be raised.

None max_length Optional[int]

if the string is greated than this length, an error will be raised.

None allow_none bool

whether None is a valid value for the string being validated.

False

Returns:

Type Description Optional[str]

The original string if it deemed to be valid (i.e. no errors are thrown).

Throws

InvalidUsageError: if any of the validation checks (length, None) fail.

Source code in slackblocks/utils.py
def validate_string(\n    string: Optional[str],\n    field_name: str,\n    max_length: Optional[int] = None,\n    min_length: Optional[int] = None,\n    allow_none: bool = False,\n) -> Optional[str]:\n    \"\"\"\n    Performs basic validation actions (e.g. length checking) on a given string\n    based on the provided criteria.\n\n    Args:\n        string: the string to validate\n        field_name: the name of the field the string belongs to (for error reporting purposes).\n        min_length: if the string is less than this length, an error will be raised.\n        max_length: if the string is greated than this length, an error will be raised.\n        allow_none: whether `None` is a valid value for the string being validated.\n\n    Returns:\n        The original string if it deemed to be valid (i.e. no errors are thrown).\n\n    Throws:\n        InvalidUsageError: if any of the validation checks (length, `None`) fail.\n    \"\"\"\n    if string is None:\n        if not allow_none:\n            raise InvalidUsageError(\n                f\"Expecting string for field `{field_name}`, cannot be None.\"\n            )\n    else:\n        length = len(string)\n        if min_length and length < min_length:\n            raise InvalidUsageError(\n                f\"Argument to field `{field_name}` ({length} characters) \"\n                f\"is less than minimum length of {min_length} characters\"\n            )\n        if max_length and length > max_length:\n            raise InvalidUsageError(\n                f\"Argument to field `{field_name}` ({length} characters) \"\n                f\"exceeds length limit of {max_length} characters\"\n            )\n    return string\n
"},{"location":"reference/views/","title":"Views","text":"

Views are app-customized visual areas within modals and Home tabs.

See: https://api.slack.com/reference/surfaces/views.

"},{"location":"reference/views/#views.HomeTabView","title":"HomeTabView","text":"

HomeTabViews are used with the views.publish Web API method.

See: https://api.slack.com/reference/surfaces/views#home.

Parameters:

Name Type Description Default blocks Union[Block, List[Block]]

A list of blocks that defines the content of the view (max 100).

required private_metadata Optional[str]

a string (max 3000 chars) that will be sent to your app in view_submission.

None callback_id Optional[str]

A string that will identify submissions of this view.

None external_id Optional[str]

A custom identifier that is unique within the views of a given Slack team.

None Source code in slackblocks/views.py
class HomeTabView(View):\n    \"\"\"\n    `HomeTabViews` are used with the `views.publish` Web API method.\n\n    See: <https://api.slack.com/reference/surfaces/views#home>.\n\n    Args:\n        blocks: A list of blocks that defines the content of the view (max 100).\n        private_metadata: a string (max 3000 chars) that will be sent to your app\n            in `view_submission`.\n        callback_id: A string that will identify submissions of this view.\n        external_id: A custom identifier that is unique within the views of a\n            given Slack team.\n    \"\"\"\n\n    def __init__(\n        self,\n        blocks: Union[Block, List[Block]],\n        private_metadata: Optional[str] = None,\n        callback_id: Optional[str] = None,\n        external_id: Optional[str] = None,\n    ) -> \"HomeTabView\":\n        super().__init__(\n            type=ViewType.HOME,\n            blocks=blocks,\n            private_metadata=private_metadata,\n            callback_id=callback_id,\n            external_id=external_id,\n        )\n
"},{"location":"reference/views/#views.ModalView","title":"ModalView","text":"

Modal views are used with the views.open, views.update and views.push Slack Web API methods.

See: https://api.slack.com/reference/surfaces/views#modal

Parameters:

Name Type Description Default title TextLike

heading that appears at the top left of the view.

required blocks Union[Block, List[Block]]

a list of blocks (max 100) that define the content of the view.

required close Optional[TextLike]

the text of the close button (max 24 chars) in the view. Must be Text.PLAINTEXT.

None submit Optional[TextLike]

the text of the submit button (max 24 chars) in the view. Must be Text.PLAINTEXT.

None private_metadata Optional[str]

a string (max 3000 chars) that will be sent to your app in view_submission.

None callback_id Optional[str]

A string that will identify submissions of this view.

None clear_on_close Optional[bool]

when True all views in the model will be cleared when it is closed.

False notify_on_close Optional[bool]

when True a view_closed event will be sent when the modal is closed.

False external_id Optional[str]

A custom identifier that is unique within the views of a given Slack team.

None submit_disabled Optional[bool]

when True disabled submitting the form until one or more inputs have been provided. Used only for configuaration models.

False Source code in slackblocks/views.py
class ModalView(View):\n    \"\"\"\n    Modal views are used with the `views.open`, `views.update` and `views.push`\n        Slack Web API methods.\n\n    See: <https://api.slack.com/reference/surfaces/views#modal>\n\n    Args:\n        title: heading that appears at the top left of the view.\n        blocks: a list of blocks (max 100) that define the content of the view.\n        close: the text of the close button (max 24 chars) in the view.\n            Must be `Text.PLAINTEXT`.\n        submit: the text of the submit button (max 24 chars) in the view.\n            Must be `Text.PLAINTEXT`.\n        private_metadata: a string (max 3000 chars) that will be sent to your app\n            in `view_submission`.\n        callback_id: A string that will identify submissions of this view.\n        clear_on_close: when `True` all views in the model will be cleared when\n            it is closed.\n        notify_on_close: when `True` a `view_closed` event will be sent when the\n            modal is closed.\n        external_id: A custom identifier that is unique within the views of a\n            given Slack team.\n        submit_disabled: when `True` disabled submitting the form until one or\n            more inputs have been provided. Used only for\n            [`configuaration models`](https://api.slack.com/reference/workflows/configuration-view).\n    \"\"\"\n\n    def __init__(\n        self,\n        title: TextLike,\n        blocks: Union[Block, List[Block]],\n        close: Optional[TextLike] = None,\n        submit: Optional[TextLike] = None,\n        private_metadata: Optional[str] = None,\n        callback_id: Optional[str] = None,\n        clear_on_close: Optional[bool] = False,\n        notify_on_close: Optional[bool] = False,\n        external_id: Optional[str] = None,\n        submit_disabled: Optional[bool] = False,\n    ):\n        super().__init__(\n            type=ViewType.MODAL,\n            blocks=blocks,\n            private_metadata=private_metadata,\n            callback_id=callback_id,\n            external_id=external_id,\n        )\n        self.title = Text.to_text(title, force_plaintext=True, max_length=24)\n        self.close = Text.to_text(\n            close, force_plaintext=True, max_length=24, allow_none=True\n        )\n        self.submit = Text.to_text(\n            submit, force_plaintext=True, max_length=24, allow_none=True\n        )\n        self.clear_on_close = clear_on_close\n        self.notify_on_close = notify_on_close\n        self.submit_disabled = submit_disabled\n\n    def _resolve(self) -> Dict[str, Any]:\n        modal_view = super()._resolve()\n        modal_view[\"title\"] = self.title._resolve()\n        if self.close:\n            modal_view[\"close\"] = self.close._resolve()\n        if self.submit:\n            modal_view[\"submit\"] = self.submit._resolve()\n        if self.clear_on_close:\n            modal_view[\"clear_on_close\"] = self.clear_on_close\n        if self.notify_on_close:\n            modal_view[\"notify_on_close\"] = self.notify_on_close\n        if self.submit_disabled:\n            modal_view[\"submit_disabled\"] = self.submit_disabled\n        return modal_view\n
"},{"location":"usage/installation/","title":"Installation","text":""},{"location":"usage/installation/#installing-slackblocks","title":"Installing slackblocks","text":"

You can install slackblocks using any Python package manager with access to PyPI. Installation commands for some of the more popular ones are included below.

pippoetryPipenv
pip install slackblocks\n
poetry add slackblocks\n
pipenv install slackblocks\n

slackblocks is a pure Python package and is published automatically to PyPI as Python wheels whenever a new version is released.

As of version `v0.1.0`` it has no dependencies outside of the Python standard library.

"},{"location":"usage/installation/#uninstalling-slackblocks","title":"Uninstalling slackblocks","text":"

If, for whatever reason, you need to remove slackblocks from your environment you can do so with the following commands:

pippoetryPipenv
pip uninstall slackblocks\n
poetry remove slackblocks\n
pipenv uninstall slackblocks\n
"},{"location":"usage/sending_messages/","title":"Sending Messages","text":"

slackblocks is designed primarily for use with either the slack-sdk or (legacy) slackclient Python packages. Usage of slackblocks remains identical regardless of which Slack client library you're using.

While there's nothing stopping you from sending the rendered messages directly with curl or requests, we recommend using the ** (dictionary unpacking)operator to unpack slackblocks Messages directly into the Slack client's chat_postMessage function.

An example of this is provided below along with the JSON result of rendering the message, an equivalent curl command, and finally the result of the message as it appears in the Slack user interface.

Python (slackblocks)JSON MessageEquivalent curl CommandSlack UI Output
from os import environ\nfrom slack import WebClient\nfrom slackblocks import Message, SectionBlock\n\n\nclient = WebClient(token=environ[\"SLACK_API_TOKEN\"])\nblock = SectionBlock(\"Hello, world!\")\nmessage = Message(channel=\"#general\", blocks=block)\n\nresponse = client.chat_postMessage(**message)\n

{\n    \"channel\": \"#general\",\n    \"mrkdwn\": true,\n    \"blocks\": [\n        {\n            \"type\": \"section\",\n            \"block_id\": \"992ceb6b-9ad4-496b-b8e6-1bd8a632e8b3\",\n            \"text\": {\n                \"type\": \"mrkdwn\",\n                \"text\": \"Hello, world!\"\n            }\n        }\n    ]\n}\n
* Note that the block_id field is a pseudorandomly generated UUID. You can pass a value to Block constructors should you desire deterministic Blocks.

curl -H \"Content-type: application/json\" \\\n--data '{\"channel\":\"#general\",\"blocks\":[{\"type\":\"section\", \"block_id\": \"992ceb6b-9ad4-496b-b8e6-1bd8a632e8b3\", \"text\":{\"type\":\"mrkdwn\",\"text\":\"Hello, world\"}}]}' \\\n-H \"Authorization: Bearer ${SLACK_API_TOKEN}\" \\\n-X POST https://slack.com/api/chat.postMessage\n

"},{"location":"usage/using_blocks/","title":"Using Blocks","text":""},{"location":"usage/using_blocks/#section-block","title":"Section Block","text":"

A section is one of the most flexible blocks available - it can be used as a simple text block, or with any of the available block elements.

Section blocks can also optionally be given an \"accessory,\" which is typically one of the interactive Elements.

Parameters:

Name Type Description Default text Optional[TextLike]

text to include in the block. Can be a string or Text object (of either mrkdwn or plaintext variety). Defaults to markdown if unspecified. One of either text or fields must be provided.

None block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None fields Optional[Union[TextLike, List[TextLike]]]

a list of text objects. One of either text or fields must be provided.

None accessory Optional[Element]

an optional Element object that will take a secondary place in the block (after or to the side of text or fields).

None Throws

InvalidUsageError: if any of the provided arguments fail validation checks.

slackblocksJSONSlack UI
from slackblocks import Checkboxes, Option, SectionBlock\n\nSectionBlock(\n    text=\"This is a section block with a checkbox accessory.\", \n    block_id=\"fake_block_id\"\n    accessory=CheckboxGroup(\n        action_id=\"checkboxes-action\",\n        options=[\n            Option(\n                text=\"*Your Only Option*\",\n                value=\"option_one\"\n            )\n        ]\n    )\n)\n
{\n    \"type\": \"section\",\n    \"block_id\": \"fake_block_id\",\n    \"text\": {\n        \"type\": \"mrkdwn\",\n        \"text\": \"This is a section block with a checkbox accessory.\"\n    },\n    \"accessory\": {\n        \"type\": \"checkboxes\",\n        \"options\": [\n            {\n                \"text\": {\n                    \"type\": \"mrkdwn\",\n                    \"text\": \"*Your Only Option*\"\n                },\n                \"value\": \"option_one\"\n            }\n        ],\n        \"action_id\": \"checkboxes-action\"\n    }\n}\n

"},{"location":"usage/using_blocks/#rich-text-block","title":"Rich Text Block","text":"

A RichTextBlock is used to provide easier rich text formatting than standard markdown text (e.g. in a SectionBlock) and access to text formatting features not available in traditional markdown (e.g. strikethrough). See the various rich text elements you can include here.

Parameters:

Name Type Description Default elements Union[RichTextObject, List[RichTextObject]]

a single rich text element or a list of those elements.

required block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None Throws

InvalidUsageError: if the elements in elements are not valid rich text elements.

slackblocksJSONSlack UI
from slackblock import RichTextBlock, RichTextSection, RichText\n\nRichTextBlock(\n    RichTextSection(\n        [\n            RichText(\n                \"You 'bout to witness hip-hop in its most purest\",\n                bold=True,\n            ),\n            RichText(\n                \"Most rawest form, flow almost flawless\",\n                strike=True,\n            ),\n            RichText(\n                \"Most hardest, most honest known artist\",\n                italic=True,\n            ),\n        ]\n    ),\n    block_id=\"fake_block_id\",\n)\n
{\n    \"type\": \"rich_text\",\n    \"block_id\": \"fake_block_id\",\n    \"elements\": [\n        {\n            \"type\": \"rich_text_section\",\n            \"elements\": [\n                {\n                    \"type\": \"text\",\n                    \"text\": \"You 'bout to witness hip-hop in its most purest\\n\",\n                    \"style\": {\n                        \"bold\": true\n                    }\n                },\n                {\n                    \"type\": \"text\",\n                    \"text\": \"Most rawest form, flow almost flawless\\n\",\n                    \"style\": {\n                        \"strike\": true\n                    }\n                },\n                {\n                    \"type\": \"text\",\n                    \"text\": \"Most hardest, most honest known artist\\n\",\n                    \"style\": {\n                        \"italic\": true\n                    }\n                }\n            ]\n        }\n    ]\n}\n

"},{"location":"usage/using_blocks/#header-block","title":"Header Block","text":"

A Header Block is a plain-text block that displays in a larger, bold font.

Parameters:

Name Type Description Default text Union[str, Text]

the text that will be rendered as a heading.

required block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None slackblocksJSONSlack UI
from slackblocks import HeaderBlock\n\nHeaderBlock(\n    \"This is a header block\",\n)\n
{\n    \"type\": \"header\",\n    \"text\": {\n        \"type\": \"plain_text\",\n        \"text\": \"This is a header block\",\n        \"emoji\": true\n    }\n}\n

"},{"location":"usage/using_blocks/#image-block","title":"Image Block","text":"

An Image Block contains a single graphic, accessed by URL.

Parameters:

Name Type Description Default image_url str

the URL pointing to the image file you want to display.

required alt_text Optional[str]

alternative text for accessibility purposes and when the image fails to load.

' ' title Optional[Union[Text, str]]

an optional text title to be presented with the image.

None block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None Throws

InvalidUsageError: when one or more of the provided args fails validation.

slackblocksJSONSlack UI
from slackblocks import ImageBlock\n\nImageBlock(\n    image_url=\"https://api.slack.com/img/blocks/bkb_template_images/beagle.png\",\n    alt_text=\"a beagle\",\n    title=\"dog\",\n    block_id=\"fake_block_id\",\n)\n
{\n    \"type\": \"image\",\n    \"block_id\": \"fake_block_id\",\n    \"image_url\": \"https://api.slack.com/img/blocks/bkb_template_images/beagle.png\",\n    \"alt_text\": \"a beagle\",\n    \"title\": {\n        \"type\": \"plain_text\",\n        \"text\": \"dog\"\n    }\n}\n

"},{"location":"usage/using_blocks/#input-block","title":"Input Block","text":"

A block that collects information from users - it can hold a plain-text input element, a checkbox element, a radio button element, a select menu element, a multi-select menu element, or a datepicker.

Parameters:

Name Type Description Default label TextLike

the name which identifies the input field.

required element Element

an interactive Element (e.g. a text field).

required dispatch_action bool

whether the Element should trigger the sending of a block_actions payload.

False block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None hint Optional[TextLike]

an optional additional guide on what input the user should prodive.

None optional bool

whether this input field may be empty when the user submits e.g. the modal.

False Throws

InvalidUsageError: when any of the provided arguments fail validation.

slackblocksJSONSlack UI
from slackblocks import InputBlock, Text, TextType, PlainTextInput\n\nInputBlock(\n    label=Text(\"Label\", type_=TextType.PLAINTEXT, emoji=True),\n    hint=Text(\"Hint\", type_=TextType.PLAINTEXT, emoji=True),\n    element=PlainTextInput(action_id=\"action\"),\n    block_id=\"fake_block_id\",\n    optional=True,\n)\n
{\n    \"type\": \"input\",\n    \"block_id\": \"fake_block_id\",\n    \"label\": {\n        \"type\": \"plain_text\",\n        \"text\": \"Label\",\n        \"emoji\": true\n    },\n    \"element\": {\n        \"type\": \"plain_text_input\",\n        \"action_id\": \"action\"\n    },\n    \"hint\": {\n        \"type\": \"plain_text\",\n        \"text\": \"Hint\",\n        \"emoji\": true\n    },\n    \"optional\": true\n}\n

"},{"location":"usage/using_blocks/#divider-block","title":"Divider Block","text":"

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

Parameters:

Name Type Description Default block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None slackblocksJSONSlack UI
from slackblocks import DividerBlock\n\nDividerBlock()\n
{\n    \"type\": \"divider\"\n}\n

"},{"location":"usage/using_blocks/#file-block","title":"File Block","text":"

Displays a remote file (e.g. a PDF).

For details on how remote files are exposed to Slack, see https://api.slack.com/messaging/files#adding.

Parameters:

Name Type Description Default external_id str

the ID assigned to the remote file when it was added to Slack.

required block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

required source str

always \"remote\" as per the Slack API (may change in the future).

'remote' slackblocksJSONSlack UI
from slackblocks import FileBlock\n\nFileBlock(\n    external_id=\"external_id\",\n    block_id=\"fake_block_id\",\n)\n
{\n    \"type\": \"file\",\n    \"external_id\": \"external_id\",\n    \"source\": \"remote\",\n    \"block_id\": \"fake_block_id\"\n}\n

* Note that this example comes from the Slack Web API docs.

"},{"location":"usage/using_blocks/#context-block","title":"Context Block","text":"

A ContextBlock displays contextul message info, including both images and text.

Parameters:

Name Type Description Default elements Optional[List[Union[Element, CompositionObject]]]

a list of Text objects and Image elements.

None block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None Throws

InvalidUsageError: when items in elements are not Text or Image or exceed 10 items.

slackblocksJSONSlack UI
from slackblocks import ContextBlock, Text\n\nContextBlock(\n    elements=[\n        Text(\"Hello, world!\"),\n    ], \n    block_id=\"fake_block_id\"\n)\n
{\n    \"type\": \"context\",\n    \"block_id\": \"fake_block_id\",\n    \"elements\": [\n        {\n            \"type\": \"mrkdwn\",\n            \"text\": \"Hello, world!\"\n        }\n    ]\n}\n

"},{"location":"usage/using_blocks/#actions-block","title":"Actions Block","text":"

A Block that is used to hold interactive elements (normally for users to interface with).

Parameters:

Name Type Description Default elements Optional[List[Element]]

a list of Elements (up to a maximum of 25).

None block_id Optional[str]

you can use this field to provide a deterministic identifier for the block.

None Throws

InvalidUsageError: if any of the items in elements are invalid.

slackblocksJSONSlack UI
ActionsBlock(\n    block_id=\"fake_block_id\",\n    elements=CheckboxGroup(\n        action_id=\"actionId-0\",\n        options=[\n            Option(text=\"*a*\", value=\"a\", description=\"*a*\"),\n            Option(text=\"*b*\", value=\"b\", description=\"*b*\"),\n            Option(text=\"*c*\", value=\"c\", description=\"*c*\"),\n        ],\n    ),\n)\n
{\n    \"type\": \"actions\",\n    \"block_id\": \"fake_block_id\",\n    \"elements\": [\n        {\n            \"type\": \"checkboxes\",\n            \"action_id\": \"actionId-0\",\n            \"options\": [\n                {\n                    \"text\": {\n                        \"type\": \"mrkdwn\",\n                        \"text\": \"*a*\"\n                    },\n                    \"value\": \"a\",\n                    \"description\": {\n                        \"type\": \"plain_text\",\n                        \"text\": \"*a*\"\n                    }\n                },\n                {\n                    \"text\": {\n                        \"type\": \"mrkdwn\",\n                        \"text\": \"*b*\"\n                    },\n                    \"value\": \"b\",\n                    \"description\": {\n                        \"type\": \"plain_text\",\n                        \"text\": \"*b*\"\n                    }\n                },\n                {\n                    \"text\": {\n                        \"type\": \"mrkdwn\",\n                        \"text\": \"*c*\"\n                    },\n                    \"value\": \"c\",\n                    \"description\": {\n                        \"type\": \"plain_text\",\n                        \"text\": \"*c*\"\n                    }\n                }\n            ]\n        }\n    ]\n}\n

"}]} \ No newline at end of file diff --git a/1.0.9/sitemap.xml.gz b/1.0.9/sitemap.xml.gz index 5074501..0db910c 100644 Binary files a/1.0.9/sitemap.xml.gz and b/1.0.9/sitemap.xml.gz differ diff --git a/1.0.9/usage/using_blocks/index.html b/1.0.9/usage/using_blocks/index.html index 8f8f405..d7a870f 100644 --- a/1.0.9/usage/using_blocks/index.html +++ b/1.0.9/usage/using_blocks/index.html @@ -881,7 +881,8 @@

Section Block

it can be used as a simple text block, or with any of the available block elements.

Section blocks can also optionally be given an "accessory," -which is typically one of the interactive Elements.

+which is typically one of the interactive +Elements.

@@ -947,8 +948,9 @@

Section Block

-

an optional Element object that will take a -secondary place in the block (after or to the side of text or fields).

+

an optional Element object that +will take a secondary place in the block (after or to the side of text or +fields).

@@ -1478,7 +1480,8 @@

Input Block

-

an interactive Element (e.g. a text field).

+

an interactive Element +(e.g. a text field).

@@ -1492,8 +1495,8 @@

Input Block

-

whether the Element should trigger the -sending of a block_actions payload.

+

whether the Element +should trigger the sending of a block_actions payload.

@@ -1957,7 +1960,8 @@

Actions Block

-

a list of Elements (up to a maximum of 25).

+

a list of Elements +(up to a maximum of 25).