Send message
The difference between chat.postMessage
and chat.sendMessage
is that chat.sendMessage
allows for passing a value for _id
and the other one doesn't. Also, chat.sendMessage
only sends it to one channel whereas the other one allows for sending to more than one channel at a time.
IMPORTANT
You can only send alias
and avatar
properties if your user has the message-impersonate
permission. We implemented this rule to avoid users impersonating other users. By default, only the bot
role has this permission, but that can be changed in Administration -> Permissions -> message-impersonate.
URL | Requires Auth | HTTP Method |
---|---|---|
|
|
|
Payload
Argument | Example | Required | Description |
---|---|---|---|
| Required | A message object containing all message data. | |
| Optional | An array to define which URL previews should be retrieved from each message. |
Some important things to note about previewUrls
include:
If the
previewUrls
array is empty, no URL will be previewed.If the
previewUrls
parameter isn't sent, all URLs (up to a maximum of five external URLs) will be previewed.If the message contains attachments or quotes, no URL is previewed.
Internal URLs are not considered in the
previewUrls
array.A maximum of five external URLs is previewed per message. If there are more than 5 external URLs, no URL is previewed.
URLs that include the same text as the Site URL are referred to as Internal URLs.
Message Object
Argument | Example | Required | Description |
---|---|---|---|
|
| Optional | The _id of message. |
|
| Required | The room id of where the message is to be sent. |
|
| Optional | The message's id to create a thread. |
|
| Optional | The text of the message to send, is optional because of attachments. |
|
| Optional | This will cause the message's name to appear as the given alias, but your username will still display. Require the |
|
| Optional | If provided, this will make the avatar on this message be an emoji. Emoji Cheetsheet |
|
| Optional | Used when replying in a thread. Message will be sent in channel also if value is |
|
| Optional | If provided, this will make the avatar use the provided image url. Require the |
|
| Optional | See the below section, Attachments Detail, for details. |
|
| Optional | Add message blocks, see blocks details below. |
Blocks Detail
A message block is an array of objects with any of the following properties. A Blocks can have many sections:
type
text
fields
Attachments Detail
The attachment is an array of objects with any of the following properties. One attachment can have many sections, including:
General
Author Information
Title Information
Image
Audio
Video
Table/Fields
Property | Example | Section | Description |
---|---|---|---|
|
| General | The color you want the order on the left side to be, any value background-css supports. |
|
| General | The text to display for this attachment, it is different than the message's text. |
|
| General | Displays the time next to the |
|
| General | An image that displays to the left of the |
|
| General | Only applicable if the |
|
| General | Causes the image, audio, and video sections to be hiding when collapsed is true. |
|
| Author | Name of the author. |
|
| Author | Providing this makes the author name clickable and points to this link. |
|
| Author | Displays a tiny icon to the left of the Author's name. |
|
| Title | Title to display for this attachment, displays under the author. |
|
| Title | Providing this makes the title clickable, pointing to this link. |
|
| Title | When this is true, a download icon appears and clicking this saves the link to file. |
|
| Image | The image to display, will be "big" and easy to see. |
|
| Audio | Audio file to play, only supports what html audio does. |
|
| Video | Video file to play, only supports what html video does. |
|
| Fields | An array of Attachment Field Objects. |
Attachment Field Objects
The field property of the attachments allows for "tables" or "columns" to be displayed on messages.
Property | Example | Required | Description |
---|---|---|---|
| true | Optional Default: | Whether this field should be a short field. |
|
| Required | The title of this field. |
|
| Required | The value of this field, displayed underneath the title value. |
Message Object Example
Example Call
Example Call with PreviewURLs
Example Result
Change Log
Version | Description |
---|---|
2.4.0 | Added validation on user's identity |
0.60.0 | Added |
6.4.0 | Add |
Last updated