Work with Requests

The following are Apex classes for working with Slack actions.

RequestContext Class 

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.

public override Slack.ActionHandler invoke(Map<String, Object> parameters, Slack.RequestContext context) {
        return Slack.ActionHandler.ack(new Handler(parameters, context));

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

public Slack.ActionPayload getActionPayload()

Return Value

Type: Slack.ActionPayload

getAppId() 

Gets the ID of the Slack app.

Signature

public String getAppId()

Return Value

Type: String

getChannelId() 

Gets the channel ID.

Signature

public String getChannelId()

Return Value

Type: String

getEnterpriseId() 

Gets the enterprise ID. See Look for enterprise IDs.

Signature

public String getEnterpriseId()

Return Value

Type: String

getFormData() 

Gets the form field values from the modal view.

Signature

public Map<String,Object> getFormData()

Return Value

Type: Map<String,Object>

getMessageContext() 

Gets the message context.

Signature

public Slack.MessageContext getMessageContext()

Return Value

Type: Slack.MessageContext

getTeamId() 

Signature

public String getTeamId()

Return Value

Type: String

getTriggerId() 

Signature

public String getTriggerId()

Return Value

Type: String

getUserId() 

Signature

public String getUserId()

Return Value

Type: String

getViewContext() 

Signature

public Slack.ViewContext getViewContext()

Return Value

Type: Slack.ViewContext


RequestContext.Builder Class 

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

public Slack.RequestContext.Builder actionPayload(Slack.ActionPayload actionPayload)

Parameters

actionPayload

Type: Slack.ActionPayload

Return Value

Type: Slack.RequestContext.Builder

appId(appId) 

Signature

public Slack.RequestContext.Builder appId(String appId)

Parameters

appId

Type: String

Return Value

Type: Slack.RequestContext.Builder

build() 

Returns an instance of the Slack.RequestContext object.

Signature

public Slack.RequestContext build()

Return Value

Type: Slack.RequestContext

channelId(channelId) 

Signature

public Slack.RequestContext.Builder channelId(String channelId)

Parameters

channelId

Type: String

Return Value

Type: Slack.RequestContext.Builder

enterpriseId(enterpriseId) 

Signature

public Slack.RequestContext.Builder enterpriseId(String enterpriseId)

Parameters

enterpriseId

Type: String

Return Value

Type: Slack.RequestContext.Builder

formData(formData) 

Signature

public Slack.RequestContext.Builder formData(Map<String,Object> formData)

Parameters

formData

Type: Map<String,Object>

Return Value

Type: Slack.RequestContext.Builder

messageContext(messageContext) 

Signature

public Slack.RequestContext.Builder messageContext(Slack.MessageContext messageContext)

Parameters

messageContext

Type: Slack.MessageContext

Return Value

Type: Slack.RequestContext.Builder

teamId(teamId) 

Signature

public Slack.RequestContext.Builder teamId(String teamId)

Parameters

teamId

Type: String

Return Value

Type: Slack.RequestContext.Builder

triggerId(triggerId) 

Signature

public Slack.RequestContext.Builder triggerId(String triggerId)

Parameters

triggerId

Type: String

Return Value

Type: Slack.RequestContext.Builder

userId(userId) 

Signature

public Slack.RequestContext.Builder userId(String userId)

Parameters

userId

Type: String

Return Value

Type: Slack.RequestContext.Builder

viewContext(viewContext) 

Signature

public Slack.RequestContext.Builder viewContext(Slack.ViewContext viewContext)

Parameters

viewContext

Type: Slack.ViewContext

Return Value

Type: Slack.RequestContext.Builder

Beta Feature

This feature is not generally available. It is not part of your purchased Services. This feature is subject to change, may be discontinued with no notice at any time in SFDC’s sole discretion, and SFDC may never make this feature generally available. Make your purchase decisions only on the basis of generally available products and features. This feature is made available on an AS IS basis and use of this feature is at your sole risk.