Slack v0.12.0 Slack.Web.Chat

Summary

Functions

delete(channel, ts, optional_params \\ %{})

Deletes a message.

Required Params

  • channel - Channel containing the message to be deleted.
  • ts - Timestamp of the message to be deleted. ex: 1405894322.002768

Errors the API can return:

  • cant_delete_message - Authenticated user does not have permission to delete this message.
  • channel_not_found - Value passed for channel was invalid.
  • compliance_exports_prevent_deletion - Compliance exports are on, messages can not be deleted
  • message_not_found - No message exists with the requested timestamp.
post_message(channel, text, optional_params \\ %{})

Sends a message to a channel.

Required Params

  • channel - Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. See below for more details.
  • text - Text of the message to send. See below for an explanation of formatting. ex: Hello world

Optional Params

  • as_user - Pass true to post the message as the authed user, instead of as a bot. Defaults to false. See authorship below. ex: true
  • attachments - Structured message attachments. ex: [{"pretext": "pre-hello", "text": "text-world"}]
  • icon_emoji - emoji to use as the icon for this message. Overrides icon_url. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below. ex: :chart_with_upwards_trend:
  • icon_url - URL to an image to use as the icon for this message. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below. ex: http://lorempixel.com/48/48
  • link_names - Find and link channel names and usernames. ex: 1
  • parse - Change how messages are treated. Defaults to none. See below. ex: full
  • unfurl_links - Pass true to enable unfurling of primarily text-based content. ex: true
  • unfurl_media - Pass false to disable unfurling of media content. ex: false
  • username - Set your bot’s user name. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below. ex: My Bot

Errors the API can return:

  • channel_not_found - Value passed for channel was invalid.
  • is_archived - Channel has been archived.
  • msg_too_long - Message text is too long
  • no_text - No message text provided
  • not_in_channel - Cannot post user messages to a channel they are not in.
  • rate_limited - Application has posted too many messages, read the Rate Limit documentation for more information
update(channel, text, ts, optional_params \\ %{})

Updates a message.

Required Params

  • channel - Channel containing the message to be updated.
  • text - New text for the message, using the default formatting rules. ex: Hello world
  • ts - Timestamp of the message to be updated. ex: 1405894322.002768

Optional Params

  • as_user - Pass true to update the message as the authed user. Bot users in this context are considered authed users. ex: true
  • attachments - Structured message attachments. ex: [{"pretext": "pre-hello", "text": "text-world"}]
  • link_names - Find and link channel names and usernames. Defaults to none. This parameter should be used in conjunction with parse. To set link_names to 1, specify a parse mode of full. ex: 1
  • parse - Change how messages are treated. Defaults to client, unlike chat.postMessage. See below. ex: none

Errors the API can return:

  • cant_update_message - Authenticated user does not have permission to update this message.
  • channel_not_found - Value passed for channel was invalid.
  • edit_window_closed - The message cannot be edited due to the team message edit settings
  • message_not_found - No message exists with the requested timestamp.
  • msg_too_long - Message text is too long
  • no_text - No message text provided