Send messages to channels or users on your workspace.
Note: 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
Change Log
Version | Description |
---|---|
6.8.0 | Allow custom fields in messages |
2.4.1 | Document existing method to post reply/threaded messages |
2.4.0 | Added validation on user's identity |
0.49.0 | The channel can now be a room's id. |
0.48.0 | Information about the sent message is now returned. |
0.17.0 | Messages aren't always processed as from BOT and urls are parsed by default. |
0.14.0 | Internally using processWebhookMessage which enabled more features. |
0.13.0 | Added |
The authToken
of the authenticated user.
The userId
of the authenticated user.
{
"alias": "Gruggy",
"avatar": "http://res.guggy.com/logo_128.png",
"channel": "#general",
"emoji": ":smirk:",
"roomId": "Xnb2kLD2Pnhdwe3RH",
"text": "Sample message",
"attachments": [
{
"audio_url": "http://www.w3schools.com/tags/horse.mp3",
"author_icon": "https://avatars.githubusercontent.com/u/850391?v=3",
"author_link": "https://rocket.chat/",
"author_name": "Bradley Hilton",
"collapsed": false,
"color": "#ff0000",
"fields": [
{
"short": true,
"title": "Test",
"value": "Testing out something or other"
},
{
"short": true,
"title": "Another Test",
"value": "[Link](https://google.com/) something and this and that."
}
],
"image_url": "http://res.guggy.com/logo_128.png",
"message_link": "https://google.com",
"text": "Yay for gruggy!",
"thumb_url": "http://res.guggy.com/logo_128.png",
"title": "Attachment Example",
"title_link": "https://youtube.com",
"title_link_download": true,
"ts": "2016-12-09T16:53:06.761Z",
"video_url": "http://www.w3schools.com/tags/movie.mp4"
}
]
}
This will cause the message's name to appear as the given alias, but your username will still be displayed.
If provided, the avatar will be displayed as the provided image URL.
If provided, the avatar will be displayed as an emoji.
The room ID or an array of room IDs where the message is to be sent. You can use channel name or username. The channel name must have the #
prefix. @
refers to username.
The message text to send, it is optional because of attachments.
Displays a tiny icon to the left of the author's name.
Providing this makes the author's name clickable and points to the provided link.
Name of the author.
Causes the image, audio, and video sections to be displayed as collapsed when set to true.
Whether this field should be a short field.
The title of this field.
The value of this field, displayed underneath the title value.
The image to display, will be big and easy to see.
Only applicable if the ts
field is provided, as it makes the time clickable to this link.
The text to display for this attachment, it is different than the message's text.
An image that displays to the left of the text, looks better when this is relatively small.
Title to display for this attachment, displays under the author.
Providing this makes the title clickable, pointing to this link.
When this is true, a download icon appears and clicking this saves the link to file.
Displays the time next to the text portion.
The message ID of the original message to reply to or to create a thread on.
You can add custom fields for messages. For example, set priorities for messages.
You must enable this option and define the validation in the workspace settings. See the Message settings for further information.
This will cause the message's name to appear as the given alias, but your username will still be displayed.
If provided, the avatar will be displayed as the provided image URL.
The channel ID or an array of channel IDs where the message is to be sent. You can use channel name or username. The channel name must have the #
prefix. @
refers to username.
If provided, the avatar will be displayed as an emoji.
The message text to send, it is optional because of attachments.
Displays a tiny icon to the left of the author's name.
Providing this makes the author's name clickable and points to the provided link.
Name of the author.
Causes the image, audio, and video sections to be displayed as collapsed when set to true.
Whether this field should be a short field.
The title of this field.
The value of this field, displayed underneath the title value.
The image to display, will be big and easy to see.
Only applicable if the ts
field is provided, as it makes the time clickable to this link.
The text to display for this attachment, it is different than the message's text.
An image that displays to the left of the text, looks better when this is relatively small.
Title to display for this attachment, displays under the author.
Providing this makes the title clickable, pointing to this link.
When this is true, a download icon appears and clicking this saves the link to file.
Displays the time next to the text portion.
You can add custom fields for messages. For example, set priorities for messages.
You must enable this option and define the validation in the workspace settings. See the Message settings for further information.
OK
{
"ts": "1481748965123",
"channel": "general",
"message": {
"alias": "",
"msg": "This is a test!",
"parseUrls": true,
"groupable": false,
"ts": "2016-12-14T20:56:05.117Z",
"u": {
"_id": "y65tAmHs93aDChMWu",
"username": "graywolf336"
},
"rid": "GENERAL",
"_updatedAt": "2016-12-14T20:56:05.119Z",
"_id": "jC9chsFddTvsbFQG7"
},
"success": true
}
Bad Request
{
"success": false,
"error": "[invalid-channel]",
"errorType": "invalid-channel"
}
Unauthorized
{
"status": "error",
"message": "You must be logged in to do this."
}