slack_message

A friendly DSL for building rich Slack messages


Project maintained by jmmastey Hosted on GitHub Pages — Theme by mattgraham

Deleting Messages

Deleting a message is much like editing a message, only simpler. Just like when you edit a message, you’ll need a reference to the message you posted.

message = SlackMessage.post_to('#general') do
  text "Testing: #{SLACK_SECRET_KEY}"
end

Then you can simply call the delete method to make up for your mistakes.

SlackMessage.delete(message)

Important Note: It’s not possible to delete a message sent directly to a user. It’s also not possible to delete a scheduled message once it’s already posted. Don’t send anything you don’t want your boss to read.

As with editing a message, it’s possible to persist messages to redis / your database to be removed at a later date.

# initially
message = SlackMessage.post_to('#general') do
  text "Testing: #{SLACK_SECRET_KEY}"
end
redis_connection.set(self.message_cache_key, Marshal.dump(message))


# later
message = Marshal.load(redis_connection.get(self.message_cache_key))
SlackMessage.delete(message)

See the API documentation for chat.delete or chat.deleteScheduledMessage for more information on deleting messages.


Next: Mentions / Notifying Users