Go to Slack

message event

A message was sent to a channel

Compatibility: RTM Events API

Scopes:
channels:history, groups:history, im:history, mpim:history


A message is delivered from several sources:

A simple message is self explanatory:

{
    "type": "message",
    "channel": "C2147483705",
    "user": "U2147483697",
    "text": "Hello world",
    "ts": "1355517523.000005"
}

The channel property is the ID of the channel, private group or DM channel this message is posted in. The user property is the ID of the user speaking, the text property is the text spoken, and ts is the unique (per-channel) timestamp.

Messages can also include an attachments property, containing a list of attachment objects.

If the message has been edited after posting it will include an edited property, including the user ID of the editor, and the timestamp the edit happened. The original text of the message is not available. For example:

{
    "type": "message",
    "channel": "C2147483705",
    "user": "U2147483697",
    "text": "Hello, world!",
    "ts": "1355517523.000005",
    "edited": {
        "user": "U2147483697",
        "ts": "1355517536.000001"
    }
}

Message subtypes

Unlike other event types, message events can have a subtype. For example, this is a channel join message:

{
    "type": "message",
    "subtype": "channel_join",
    "text": "<@U023BECGF|bobby> has joined the channel",
    "ts": "1403051575.000407",
    "user": "U023BECGF"
}

They are structured in this way so that clients can either support them fully by having distinct behavior for each different subtype, or can fallback to a simple mode by just displaying the text of the message.

The full list of message subtypes is:

Event Description Works with
bot_message

A message was posted by an integration

RTM
channel_archive

A channel was archived

RTM
channel_join

A team member joined a channel

RTM
channel_leave

A team member left a channel

RTM
channel_name

A channel was renamed

RTM
channel_purpose

A channel purpose was updated

RTM
channel_topic

A channel topic was updated

RTM
channel_unarchive

A channel was unarchived

RTM
file_comment

A comment was added to a file

RTM
file_mention

A file was mentioned in a channel

RTM
file_share

A file was shared into a channel

RTM
group_archive

A group was archived

RTM
group_join

A team member joined a group

RTM
group_leave

A team member left a group

RTM
group_name

A group was renamed

RTM
group_purpose

A group purpose was updated

RTM
group_topic

A group topic was updated

RTM
group_unarchive

A group was unarchived

RTM
me_message

A /me message was sent

RTM Events API
message_changed

A message was changed

RTM Events API
message_deleted

A message was deleted

RTM Events API
message_replied

A message thread received a reply

RTM Events API
pinned_item

An item was pinned in a channel

RTM
reply_broadcast

A message thread's reply was broadcast to a channel

RTM Events API
unpinned_item

An item was unpinned from a channel

RTM

Hidden subtypes

Some subtypes have a special hidden property. These indicate messages that are part of the history of a channel but should not be displayed to users. Examples include records of message edits or deletes:

{
    "type": "message",
    "subtype": "message_deleted",
    "hidden": true,
    "channel": "C024BE91L",
    "ts": "1358878755.000001",
    "deleted_ts": "1358878749.000002",
    "event_ts": "1358878755.000002"
}

Hidden messages are only sent over the Real Time Messaging API. They will not appear as the latest property on channel, group or im objects. They will also not be returned in calls to channels.history, im.history or groups.history.

Stars, pins, and reactions

Messages can have several extra properties depending on whether or not they have been starred, pinned, or reacted to:

{
    "type": "message",
    "channel": "C2147483705",
    "user": "U2147483697",
    "text": "Hello world",
    "ts": "1355517523.000005",
    "is_starred": true,
    "pinned_to": ["C024BE7LT", ...],
    "reactions": [
        {
            "name": "astonished",
            "count": 3,
            "users": [ "U1", "U2", "U3" ]
        },
        {
            "name": "facepalm",
            "count": 1034,
            "users": [ "U1", "U2", "U3", "U4", "U5" ]
        }
    ]
}

The is_starred property is present and true if the calling user has starred the message, else it is omitted.

The pinned_to array, if present, contains the IDs of any channels to which the message is currently pinned.

The reactions property, if present, contains any reactions that have been added to the message and gives information about the type of reaction, the total number of users who added that reaction and a (possibly incomplete) list of users who have added that reaction to the message. The users array in the reactions property might not always contain all users that have reacted (we limit it to X users, and X might change), however count will always represent the count of all users who made that reaction (i.e. it may be greater than users.length). If the authenticated user has a given reaction then they are guaranteed to appear in the users array, regardless of whether count is greater than users.length or not.

Message events in the Events API

This exact event type is defined differently in the Events API. Depending on your associated OAuth scope or the channels your bot user belongs to, you must subscribe to one of the following events instead:

The semantics for the events are the same as those described here — you're still receiving an event of type message.

Not all message subtypes are deliverable in the Events API.

Events API compatibility

Subscribe to this event via the Events API.

Events of this type will be wrapped in metadata when sent via the Events API.