Modifying messages

A message captures a specific moment in time. But if you're an app, you might want to publish messages that communicate something that changes over time. Perhaps its the progress of a long running database request, or maybe just a simple message asking a user to wait for the response of an external API request.

In these cases and others, it's useful to have a way to modify messages from their original form. Slack apps are able to update and delete messages via simple to use APIs.


Updating messages

Any non-ephemeral message may possibly be updated by an app, by using the chat.update API method.

The process for using this API is largely the same as that for sending messages, but there are a few small differences:

  • You can't move a message, so the channel parameter is used as an identifier for the target message to update, not as a way to update the conversation a message is in.
  • Ephemeral messages can't be updated in this way.
  • An app can't just update every message in a conversation - only ones posted by the authenticated user of the token being used, including those posted as the app. The same applies to bot users, where you use a bot user token. Read the API reference for more information.

Updating messages using response_url

When a user interacts with an interactive element in a message, a payload containing a response_url will be sent to the app that published the interactive message.

This response_url can be used to publish new messages. It can also be used to update the original interactive message, regardless of whether it was an ephemeral message or not.

Read our interactive messages guide for more details on how to update messages using response_url.


Deleting messages

The chat.delete API method offers apps the powerful ability to delete messages, using the same permissions as those used to send messages:

POST https://slack.com/api/chat.delete
Content-type: application/json
Authorization: Bearer YOUR_TOKEN_HERE
{
  "channel": "PARENT_CHANNEL_ID",
  "ts": "MESSAGE_TO_DELETE"
}

The right for an app to delete a message depends on a few caveats:

  • If using a standard user's user token, only messages posted by that user, or those posted as the app, may be deleted.
  • If using a workspace admin user's user token, most messages in that workspace can be deleted.
  • If using a bot user token, only messages posted by that bot user, or those posted as the app, may be deleted.
  • Ephemeral messages can't be deleted in this way.

If the message has some threaded replies, then those replies will be left in the conversation, with a placeholder informing viewers about the deleted message:

This message was deleted placeholder, showing orphaned replies

Deleting messages using response_url

When a user interacts with an interactive element in a message, a payload containing a response_url will be sent to the app that published the interactive message.

This response_url can be used to publish new messages in response. It can also be used to delete the original interactive message, regardless of whether it was an ephemeral message or not.

Read our interactive messages guide for more details on how to delete messages using response_url.