Work with Requests
The following are Apex classes for working with Slack actions.
Describes the context in which a particular Slack action is invoked.
Usage
RequestContext
exposes information about the source of the action in Slack, performs custom logic, and obtains the correct Slack client to respond to Slack based on the request. Each action type receives different information in its RequestContext
.
See Shortcuts and Slash Commands.
RequestContext Methods
The following are methods for RequestContext
.
getActionPayload()
Gets the action payload, such as the action name or type.
Signature
Return Value
Type: Slack.ActionPayload
getAppId()
Gets the ID of the Slack app.
Signature
Return Value
Type: String
getChannelId()
Gets the channel ID.
Signature
Return Value
Type: String
getEnterpriseId()
Gets the enterprise ID. See Look for enterprise IDs.
Signature
Return Value
Type: String
getFormData()
Gets the form field values from the modal view.
Signature
Return Value
Type: Map<String,Object>
getMessageContext()
Gets the message context.
Signature
Return Value
Type: Slack.MessageContext
getTeamId()
Signature
Return Value
Type: String
getTriggerId()
Signature
Return Value
Type: String
getUserId()
Signature
Return Value
Type: String
getViewContext()
Signature
Return Value
Type: Slack.ViewContext
Contains methods to build an instance of the Slack.RequestContext
class.
A Builder object is obtained by invoking one of the RequestContext.Builder
methods defined by the RequestContext
class.
RequestContext.Builder Methods
The following are methods for RequestContext.Builder
.
actionPayload(actionPayload)
Signature
Parameters
actionPayload
Type: Slack.ActionPayload
Return Value
Type: Slack.RequestContext.Builder
appId(appId)
Signature
Parameters
appId
Type: String
Return Value
Type: Slack.RequestContext.Builder
build()
Returns an instance of the Slack.RequestContext
object.
Signature
Return Value
Type: Slack.RequestContext
channelId(channelId)
Signature
Parameters
channelId
Type: String
Return Value
Type: Slack.RequestContext.Builder
enterpriseId(enterpriseId)
Signature
Parameters
enterpriseId
Type: String
Return Value
Type: Slack.RequestContext.Builder
formData(formData)
Signature
Parameters
formData
Type: Map<String,Object>
Return Value
Type: Slack.RequestContext.Builder
messageContext(messageContext)
Signature
Parameters
messageContext
Type: Slack.MessageContext
Return Value
Type: Slack.RequestContext.Builder
teamId(teamId)
Signature
Parameters
teamId
Type: String
Return Value
Type: Slack.RequestContext.Builder
triggerId(triggerId)
Signature
Parameters
triggerId
Type: String
Return Value
Type: Slack.RequestContext.Builder
userId(userId)
Signature
Parameters
userId
Type: String
Return Value
Type: Slack.RequestContext.Builder
viewContext(viewContext)
Signature
Parameters
viewContext
Type: Slack.ViewContext
Return Value
Type: Slack.RequestContext.Builder