Skip to content

Commit 65a2603

Browse files
author
Shane DeWael
committed
Add Block Kit example
1 parent 7589d39 commit 65a2603

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

docs-src/basic_usage.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,55 @@ See `chat.postEphemeral <https://api.slack.com/methods/chat.postEphemeral>`_ for
5959

6060
--------
6161

62+
Customizing a message layout
63+
-----------------------
64+
The chat.postMessage method takes an optional blocks argument that allows you to customize the layout of a message.
65+
Blocks for Web API methods are all specified in a single object literal, so just add additional keys for any optional argument.
66+
67+
To send a message to a channel, use the channel's ID. For IMs, use the user's ID.
68+
69+
.. code-block:: python
70+
71+
sc.api_call(
72+
"chat.postMessage",
73+
channel="C0XXXXXX",
74+
blocks=[
75+
{
76+
"type": "section",
77+
"text": {
78+
"type": "mrkdwn",
79+
"text": "Danny Torrence left the following review for your property:"
80+
}
81+
},
82+
{
83+
"type": "section",
84+
"text": {
85+
"type": "mrkdwn",
86+
"text": "<https://example.com|Overlook Hotel> \n :star: \n Doors had too many axe holes, guest in room " +
87+
"237 was far too rowdy, whole place felt stuck in the 1920s."
88+
},
89+
"accessory": {
90+
"type": "image",
91+
"image_url": "https://images.pexels.com/photos/750319/pexels-photo-750319.jpeg",
92+
"alt_text": "Haunted hotel image"
93+
}
94+
},
95+
{
96+
"type": "section",
97+
"fields": [
98+
{
99+
"type": "mrkdwn",
100+
"text": "*Average Rating*\n1.0"
101+
}
102+
]
103+
}
104+
]
105+
)
106+
107+
**Note:** You can use the `Block Kit Builder <https://api.slack.com/tools/block-kit-builder>`for a playground where you can prototype your message's look and feel.
108+
109+
--------
110+
62111
Replying to messages and creating threads
63112
------------------------------------------
64113
Threaded messages are just like regular messages, except thread replies are grouped together to provide greater context

0 commit comments

Comments
 (0)