Work with Chat Messages
The following are Apex classes for the Slack chat
API methods.
Many of these classes enable your Slack app to post a message using the bot token or user token based on the scopes required on the Slack API methods. See Bot Token and User Token Scopes.
Sends a request to delete a message.
Usage
See Slack’s chat.delete method.
The following are methods for ChatDeleteRequest
.
Builds a request object that's used when executing the API call.
Signature
Return Value
Type: Slack.ChatDeleteRequest.Builder
Deletes a message.
Usage
See Slack’s chat.delete method.
This class contains standard response methods.
The following are methods for ChatDeleteResponse
.
The channel containing the message to be deleted.
Signature
Return Type
Type: String
Signature
Return Value
Type: String
Gets the timestamp of the message to be deleted.
Signature
Return Value
Type: String
Signature
Parameters
channel
Type: String
The channel containing the message to be deleted.
Return Value
Type: void
Signature
Parameters
deprecatedArgument
Type: String
Return Value
Type: void
Signature
Parameters
ts
Type: String
Return Value
Type: void
Sends a request to delete a pending scheduled message from the queue.
Usage
See Slack’s chat.deleteScheduledMessage method.
The following are methods for ChatDeleteScheduledMessageRequest
.
Builds a request object that's used when executing the API call.
Signature
Return Value
Type: Slack.ChatDeleteScheduledMessageRequest.Builder
Contains methods to build an instance of the Slack.ChatDeleteScheduledMessageRequest
class.
A Builder object is obtained by invoking one of the ChatDeleteScheduledMessageRequest.Builder
methods defined by the ChatDeleteScheduledMessageRequest
class.
The following are methods for ChatDeleteScheduledMessageRequest.Builder
. These methods are optional unless specified otherwise.
Required. Builds an instance of Slack.ChatDeleteScheduledMessageRequest
.
Signature
Return Value
Type: Slack.ChatDeleteScheduledMessageRequest
Required. The channel that the scheduled message is posting to.
Signature
Parameters
channel
Type: String
Return Value
Type: Slack.ChatDeleteScheduledMessageRequest.Builder
Required. The ID that's returned from a call to ChatScheduleMessageRequest.
Signature
Parameters
scheduledMessageId
Type: String
Return Value
Type: Slack.ChatDeleteScheduledMessageRequest.Builder
Deletes a pending scheduled message from the queue.
Usage
See Slack’s chat.deleteScheduledMessage method.
This class contains standard response methods.
Sends a request to retrieve a permalink URL.
Usage
See Slack’s chat.getPermalink method.
The following are methods for ChatGetPermalinkRequest
.
Signature
Return Value
Type: Slack.ChatGetPermalinkRequest.Builder
Contains methods to build an instance of the Slack.ChatGetPermalinkRequest
class.
A Builder object is obtained by invoking one of the ChatGetPermalinkRequest.Builder
methods defined by the ChatGetPermalinkRequest
class.
These classes are optional unless specified otherwise.
The following are methods for ChatGetPermalinkRequest.Builder
.
Required. Builds an instance of Slack.ChatGetPermalinkRequest
.
Signature
Return Value
Type: Slack.ChatGetPermalinkRequest
Required. The ID of the conversation or channel containing the message.
Signature
Parameters
channel
Type: String
Return Value
Type: Slack.ChatGetPermalinkRequest.Builder
Required. The message's timestamp value, uniquely identifying it within a channel.
Signature
Parameters
messageTs
Type: String
Return Value
Type: Slack.ChatGetPermalinkRequest.Builder
Retrieves a permalink URL.
Usage
See Slack’s chat.getPermalink method.
This class contains standard response methods.
The following are methods for ChatGetPermalinkResponse
.
Signature
Return Value
Type: String
Signature
Return Value
Type: String
Signature
Parameters
channel
Type: String
Return Value
Type: void
Signature
Parameters
permalink
Type: String
Return Value
Type: void
Sends a request to share a me message into a channel.
Usage
See Slack’s chat.meMessage method.
Consider using chat:write
scope on the user token only in response to an inciting user action and inform users that a message will be posted on their behalf. See Sending messages as other entities.
The following are methods for ChatMeMessageRequest
.
Builds a request object that's used when executing the API call.
Signature
Return Value
Type: Slack.ChatMeMessageRequest.Builder
Contains methods to build an instance of the Slack.ChatMeMessageRequest
class.
A Builder object is obtained by invoking one of the ChatMeMessageRequest.Builder
methods defined by the ChatMeMessageRequest
class.
The following are methods for ChatMeMessageRequest.Builder
.
Required. Builds an instance of Slack.ChatMeMessageRequest
.
Signature
Return Value
Type: Slack.ChatMeMessageRequest
Required. The ID or name of the channel to send message to, which can be a public channel, private group or IM channel.
Signature
Return Value
Type: Slack.ChatMeMessageRequest.Builder
Required. Text of the message to send.
Signature
Parameters
text
Type: String
Return Value
Type: Slack.ChatMeMessageRequest.Builder
Shares a me message into a channel.
Usage
See Slack’s chat.meMessage method.
This class contains standard response methods.
The following are methods for ChatMeMessageResponse
.
The channel ID or name where the me message is shared.
Signature
Return Value
Type: String
Gets the timestamp of the me message.
Signature
Return Value
Type: String
Sets the channel ID or name to send the message to, which can be a public or private group or IM channel.
Signature
Return Value
Type: void
Sets the timestamp on the me message.
Signature
Parameters
ts
Type: String
Return Value
Type: void
Sends a request to send an ephemeral message to a user in a channel.
Usage
See Slack’s chat.postEphemeral method.
Consider using chat:write
scope on the user token only in response to an inciting user action inform users that a message will be posted on their behalf. See Sending messages as other entities.
The following are methods for ChatPostEphemeralRequest
.
Builds a request object that's used when executing the API call.
Signature
Return Value
Type: Slack.ChatPostEphemeralRequest.Builder
Contains methods to build an instance of the Slack.ChatPostEphemeralRequest
class.
A Builder object is obtained by invoking one of the ChatPostEphemeralRequest.Builder
methods defined by the ChatPostEphemeralRequest
class.
The following are methods for ChatPostEphemeralRequest.Builder
. These methods are optional unless specified otherwise.
Signature
Parameters
attachmentsAsString
Type: String
Return Value
Type: Slack.ChatPostEphemeralRequest.Builder
Required. Builds an instance of Slack.ChatPostEphemeralRequest
.
Signature
Return Value
Type: Slack.ChatPostEphemeralRequest
Required. The ID or name of the channel, private group, or IM channel to send message to.
Signature
Parameters
channel
Type: String
Return Value
Type: Slack.ChatPostEphemeralRequest.Builder
The emoji to use the icon for this message. Overrides the icon URL. Use an icon emoji with the chat:write:bot
scope only. Otherwise, this is ignored.
Signature
Parameters
iconEmoji
Type: String
Return Value
Type: Slack.ChatPostEphemeralRequest.Builder
URL to an image to use as the icon for this message. Use an icon URL with the chat:write:bot
scope only. Otherwise, this is ignored.
Signature
Parameters
iconUrl
Type: String
Return Value
Type: Slack.ChatPostEphemeralRequest.Builder
Find and link channel names and usernames.
Signature
Parameters
linkNames
Type: Boolean
Return Value
Type: Slack.ChatPostEphemeralRequest.Builder
Changes how messages are treated. Defaults to none
. See Formatting.
Signature
Parameters
parse
Type: String
Return Value
Type: Slack.ChatPostEphemeralRequest.Builder
Required. Text of the message. See Using text with blocks or attachments.
Signature
Parameters
text
Type: String
Return Value
Type: Slack.ChatPostEphemeralRequest.Builder
Signature
Parameters
threadTs
Type: String
Return Value
Type: Slack.ChatPostEphemeralRequest.Builder
Required. The ID of the user receiving the ephemeral message. This user belongs in the channel specified by channel(channel)
.
Signature
Parameters
user
Type: String
Return Value
Type: Slack.ChatPostEphemeralRequest.Builder
The bot’s username. Must be used with the chat:write:bot
scope.
Signature
Parameters
username
Type: String
Return Value
Type: Slack.ChatPostEphemeralRequest.Builder
Signature
Parameters
viewReference
Type: Slack.ViewReference
Return Value
Type: Slack.ChatPostEphemeralRequest.Builder
Sends an ephemeral message to a user in a channel.
Usage
See Slack’s chat.postEphemeral method.
This class contains standard response methods.
The following are methods for ChatPostEphemeralResponse
.
Signature
Return Value
Type: String
Signature
Return Value
Type: String
Signature
Parameters
deprecatedArgument
Type: String
Return Value
Type: void
Sets the timestamp on the message.
Signature
Parameters
messageTs
Type: String
Return Value
Type: void
Sends a request to post a message to a channel.
Usage
See Slack’s chat.postMessage method.
In this example, the PostMessage
action runs when a user enters your slash command. The ViewReference
gets the selection
view to display a select menu. When the value on the select menu changes, it calls an Apex slackHomeViewSelectChanged
action that's specified on its onchange definition
key. Finally, the apphome
view is published with the selected value.
The selection
view looks like this.
Changing the value on the select menu calls the slackHomeViewSelectChanged
Apex action, which extends ActionDispatcher.
The apphome
view looks like this.
Consider using chat:write
scope on the user token only in response to an inciting user action and inform users that a message will be posted on their behalf. See Sending messages as other entities.
The following are methods for ChatPostMessageRequest
.
Signature
Return Value
Type: Slack.ChatPostMessageRequest.Builder
Contains methods to build an instance of the Slack.ChatPostMessageRequest
class.
A Builder object is obtained by invoking one of the ChatPostMessageRequest.Builder
methods defined by the ChatPostMessageRequest
class.
The following are methods for ChatPostMessageRequest.Builder
. These methods are optional unless specified otherwise.
Required if text(text)
isn't used. Describes the content of the message. A JSON-based array of structured attachments, presented as a URL-encoded string. If this method is used, text(text)
is fallback text for notifications only.
Signature
Parameters
attachmentsAsString
Type: String
Return Value
Type: Slack.ChatPostMessageRequest.Builder
Required. Builds an instance of Slack.ChatPostMessageRequest
.
Signature
Return Value
Type: Slack.ChatPostMessageRequest
Required. The ID or name of the channel, private group, or IM channel to send the message to. See Slack's channels usage info.
Signature
Parameters
channel
Type: String
Return Value
Type: Slack.ChatPostMessageRequest.Builder
The emoji to use the icon for this message. Overrides the icon URL. Use an icon emoji with the chat:write:customize
scope only. Otherwise, this is ignored.
Signature
Parameters
iconEmoji
Type: String
Return Value
Type: Slack.ChatPostMessageRequest.Builder
URL to an image to use as the icon for this message. Use an icon URL with the chat:write:customize
scope only. Otherwise, this is ignored.
Parameters
iconUrl
Type: String
Return Value
Type: Slack.ChatPostMessageRequest.Builder
Signature
Parameters
linkNames
Type: Boolean
Return Value
Type: Slack.ChatPostMessageRequest.Builder
Specifies whether Slack markup parsing is enabled. Defaults to enabled (true).
Signature
Parameters
mrkdwn
Type: Boolean
Return Value
Type: Slack.ChatPostMessageRequest.Builder
Changes how messages are treated. See Formatting messages.
Signature
Parameters
parse
Type: String
Return Value
Type: Slack.ChatPostMessageRequest.Builder
Signature
Parameters
replyBroadcast
Type: Boolean
Return Value
Type: Slack.ChatPostMessageRequest.Builder
Required only if attachmentsAsString()
isn't used. If attachmentsAsString()
is used, text(text)
is fallback text for notifications only.
Signature
Parameters
text
Type: String
Return Value
Type: Slack.ChatPostMessageRequest.Builder
Signature
Parameters
threadTs
Type: String
Return Value
Type: Slack.ChatPostMessageRequest.Builder
Signature
Parameters
unfurlLinks
Type: Boolean
Return Value
Type: Slack.ChatPostMessageRequest.Builder
Signature
Parameters
unfurlMedia
Type: Boolean
Return Value
Type: Slack.ChatPostMessageRequest.Builder
Signature
Parameters
username
Type: String
Return Value
Type: Slack.ChatPostMessageRequest.Builder
Signature
Parameters
viewReference
Type: Slack.ViewReference
Return Value
Type: Slack.ChatPostMessageRequest.Builder
Posts a message to a channel.
Usage
See Slack’s chat.postMessage method.
This class contains standard response methods.
The following are methods for ChatPostMessageResponse
.
Gets the ID or name of the channel, private group, or IM channel to send the message to.
Signature
Return Value
Type: String
Signature
Return Value
Type: String
Signature
Return Value
Type: Slack.Message
Signature
Return Value
Type: Slack.ErrorResponseMetadata
Signature
Return Value
Type: String
Signature
Parameters
channel
Type: String
Return Value
Type: void
Signature
Parameters
deprecatedArgument
Type: String
Return Value
Type: void
Signature
Parameters
message
Type: Slack.Message
Return Value
Type: void
Signature
Parameters
responseMetadata
Type: Slack.ErrorResponseMetadata
Return Value
Type: void
Signature
Parameters
ts
Type: String
Return Value
Type: void
Sends a request to return a list of scheduled messages.
Usage
See Slack’s chat.scheduleMessages.list method.
The following are methods for ChatScheduledMessagesListRequest
.
Builds a request object that's used when executing the API call.
Signature
Return Value
Type: Slack.ChatScheduledMessagesListRequest.Builder
Contains methods to build an instance of the Slack.ChatScheduledMessagesListRequest
class.
A Builder object is obtained by invoking one of the ChatScheduledMessagesListRequest.Builder
methods defined by the ChatScheduledMessagesListRequest
class.
The following are methods for ChatScheduledMessagesListRequest.Builder
. These methods are optional unless specified otherwise.
Required. Builds an instance of Slack.ChatScheduledMessagesListRequest
.
Signature
Return Value
Type: Type: Slack.ChatScheduledMessagesListRequest
Signature
Parameters
channel
Type: String
Return Value
Type: Slack.ChatScheduledMessagesListRequest.Builder
Signature
Parameters
cursor
Type: String
Return Value
Type: Slack.ChatScheduledMessagesListRequest.Builder
Signature
Parameters
latest
Type: String
Return Value
Type: Slack.ChatScheduledMessagesListRequest.Builder
Signature
Parameters
limitValue
Type: Integer
Return Value
Type: Slack.ChatScheduledMessagesListRequest.Builder
Signature
Parameters
oldest
Type: String
Return Value
Type: Slack.ChatScheduledMessagesListRequest.Builder
Signature
Parameters
teamId
Type: String
Return Value
Type: Slack.ChatScheduledMessagesListRequest.Builder
Returns a list of scheduled messages.
This class contains standard response methods.
The following are methods for ChatScheduledMessagesListResponse
.
Signature
Return Value
Type: Slack.ResponseMetadata
Signature
Return Value
Type: List<Slack.ChatScheduledMessagesListResponse.ScheduledMessage>
Signature
Parameters
responseMetadata
Type: Slack.ResponseMetadata
Return Value
Type: void
Signature
Parameters
scheduledMessages
Type: List<Slack.ChatScheduledMessagesListResponse.ScheduledMessage>
Return Value
Type: void
The following are methods for ChatScheduledMessagesListResponse.ScheduledMessage
.
Gets the ID of the channel where the scheduled messages are posted to.
Signature
Return Value
Type: String
Gets the timestamp of when the scheduled message was created.
Signature
Return Value
Type: Integer
Gets the ID of the scheduled message.
Signature
Return Value
Type: String
Gets the timestamp of when the message is to be posted.
Signature
Return Value
Type: Integer
Gets the content of the message.
Signature
Return Value
Type: String
Sets the ID of the channel for which to post the scheduled message.
Signature
Parameters
channelId
Type: String
Return Value
Type: void
Sets the timestamp for when the scheduled message was created.
Signature
Parameters
dateCreated
Type: Integer
Return Value
Type: void
Signature
Parameters
id
Type: String
Return Value
Type: void
Sets the timestamp for when the message is scheduled to be posted.
Signature
Parameters
postAt
Type: Integer
Return Value
Type: void
Signature
Parameters
text
Type: String
Return Value
Type: void
Sends a request to schedule a message to be sent to a channel.
Usage
See Slack’s chat.scheduleMessage method.
Consider using chat:write
scope on the user token only in response to an inciting user action and inform users that a message will be posted on their behalf. See Sending messages as other entities.
The following are methods for ChatScheduleMessageRequest
.
Builds a request object that's used when executing the API call.
Signature
Return Value
Type: Slack.ChatScheduleMessageRequest.Builder
Contains methods to build an instance of the Slack.ChatScheduleMessageRequest
class.
A Builder object is obtained by invoking one of the ChatScheduleMessageRequest.Builder
methods defined by the ChatScheduleMessageRequest
class.
The following are methods for ChatScheduleMessageRequest.Builder
. These methods are optional unless specified otherwise.
Signature
Parameters
attachmentsAsString
Type: String
Return Value
Type: Slack.ChatScheduleMessageRequest.Builder
Required. Builds an instance of Slack.ChatScheduleMessageRequest
.
Signature
Return Value
Type: Slack.ChatScheduleMessageRequest
Required. The ID or name of the channel, private group, or DM channel to send the message to. See Slack's channels usage info.
Signature
Parameters
channel
Type: String
Return Value
Type: Slack.ChatScheduleMessageRequest.Builder
Signature
Parameters
linkNames
Type: Boolean
Return Value
Type: Slack.ChatScheduleMessageRequest.Builder
Changes how messages are treated. See chat.postMessage.
Signature
Parameters
parse
Type: String
Return Value
Type: Slack.ChatScheduleMessageRequest.Builder
Required. Sets the Unix EPOCH timestamp for when the message is scheduled to be posted.
Signature
Parameters
postAt
Type: Integer
Return Value
Type: Slack.ChatScheduleMessageRequest.Builder
Signature
Parameters
replyBroadcast
Type: Boolean
Return Value
Type: Slack.ChatScheduleMessageRequest.Builder
Required. The text for the message. If you include an optional viewReference to render the message, Slack will use "text" as a fallback string. See Slack's text usage info.
Signature
Parameters
text
Type: String
Return Value
Type: Slack.ChatScheduleMessageRequest.Builder
Signature
Parameters
threadTs
Type: String
Return Value
Type: Slack.ChatScheduleMessageRequest.Builder
Signature
Parameters
unfurlLinks
Type: Boolean
Return Value
Type: Slack.ChatScheduleMessageRequest.Builder
Signature
Parameters
unfurlMedia
Type: Boolean
Return Value
Type: Slack.ChatScheduleMessageRequest.Builder
Signature
Parameters
viewReference
Type: Slack.ViewReference
Return Value
Type: Slack.ChatScheduleMessageRequest.Builder
Schedules a message to be sent to a channel.
Usage
See Slack’s chat.scheduleMessage method.
This class contains standard response methods.
The following are methods for ChatScheduleMessageResponse
.
Signature
Return Value
Type: String
Signature
Return Value
Type: Slack.ChatScheduleMessageResponse.ScheduledMessage
Signature
Return Value
Type: Integer
Signature
Return Value
Type: String
Signature
Parameters
channel
Type: String
Return Value
Type: void
Signature
Parameters
message
Type: Slack.ChatScheduleMessageResponse.ScheduledMessage
Return Value
Type: void
Signature
Parameters
postAt
Type: Integer
Return Value
Type: void
Signature
Parameters
scheduledMessageId
Type: String
Return Value
Type: void
The following are methods for ChatScheduleMessageResponse.ScheduledMessage
.
Signature
Return Value
Type: String
Signature
Return Value
Type: Slack.BotProfile
Signature
Return Value
Type: String
Signature
Return Value
Type: String
Signature
Return Value
Type: String
Signature
Return Value
Type: String
Signature
Parameters
botId
Type: String
Return Value
Type: void
Signature
Parameters
botProfile
Type: Slack.BotProfile
Return Value
Type: void
Signature
Parameters
team
Type: String
Return Value
Type: void
Signature
Parameters
text
Type: String
Return Value
Type: void
Signature
Parameters
type
Type: String
Return Value
Type: void
Signature
Parameters
user
Type: String
Return Value
Type: void
Sends a request to update a message.
Usage
See Slack’s chat.update method.
Consider using chat:write
scope on the user token only in response to an inciting user action and give users a heads up that the message will be updated on their behalf. See Sending messages as other entities.
The following are methods for ChatUpdateRequest
.
Builds a request object that's used when executing the API call.
Signature
Return Value
Type: Slack.ChatUpdateRequest.Builder
Contains methods to build an instance of the Slack.ChatUpdateRequest
class.
A Builder object is obtained by invoking one of the ChatUpdateRequest.Builder
methods defined by the ChatUpdateRequest
class.
The following are methods for ChatUpdateRequest.Builder
. These methods are optional unless specified otherwise.
Signature
Parameters
attachmentsAsString
Type: String
Return Value
Type: Slack.ChatUpdateRequest.Builder
Required. Builds an instance of Slack.ChatUpdateRequest
.
Signature
Return Value
Type: Slack.ChatUpdateRequest
Required. The channel containing the message to be updated.
Signature
Parameters
channel
Type: String
Return Value
Type: Slack.ChatUpdateRequest.Builder
Signature
Parameters
linkNames
Type: Boolean
Return Value
Type: Slack.ChatUpdateRequest.Builder
Signature
Parameters
parse
Type: String
Return Value
Type: Slack.ChatUpdateRequest.Builder
Signature
Parameters
text
Type: String
Return Value
Type: Slack.ChatUpdateRequest.Builder
Required. The timestamp of the message to be updated.
Signature
Parameters
ts
Type: String
Return Value
Type: Slack.ChatUpdateRequest.Builder
Signature
Parameters
viewReference
Type: Slack.ViewReference
Return Value
Type: Slack.ChatUpdateRequest.Builder
Updates a message.
This class contains standard response methods.
The following are methods for ChatUpdateResponse
.
The channel containing the message to be updated.
Signature
Return Type
Type: String
Signature
Return Value
Type: String
Signature
Return Value
Type: Slack.Message
The text of the message.
Signature
Return Type
Type: String
Gets the timestamp of the message to be updated.
Signature
Return Value
Type: String
Signature
Parameters
channel
Type: String
The channel containing the message to be deleted.
Return Value
Type: void
Signature
Parameters
deprecatedArgument
Type: String
Return Value
Type: void
Signature
Parameters
message
Type: Slack.Message
Return Value
Type: void
Signature
Parameters
ts
Type: String
Return Value
Type: void