Work with Shortcuts

The following are Apex classes for working with shortcuts.

ShortcutDispatcher Class 

Defines the dispatcher for the shortcut you are handling.

Usage

When a user interacts with your shortcut, your app receives an interaction payload. Your handler processes that payload and then sends a response. See Handle Slack Actions.

To respond to an interaction payload, always send an acknowledgement response, follow up with a modal to confirm any action that occurs next. See Slack API: Responding to shortcuts.

ShortcutDispatcher Methods 

ShortcutDispatcher has the following method.

invoke(parameters, context) 

Invokes the action handler.

Signature

1public Slack.ActionHandler invoke(
2  Slack.ShortcutParameters parameters,
3  Slack.RequestContext context
4);

Parameters

parameters

Type: Slack.ShortcutParameters

The action parameters for the shortcut handler. The format is a Map<String, Object>.

context

Type: Slack.RequestContext

Describes the context in which a Slack action is invoked.

Return Value

Type: Slack.ActionHandler

Usage

To access the Slack context, use the invoke() method. This method is passed in by an instance of RequestContext. It 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.


ShortcutParameters Class 

Contains information about the shortcut.

ShortcutParameters Constructor 

The following are constructors for ShortcutParameters.

ShortcutParameters(callbackId) 

Creates an instance of the Slack.ShortcutParameters class with the specified callback ID.

Signature

1public ShortcutParameters(String callbackId)

Parameters

callbackId

Type: String

The ID sent in the interaction payload.

ShortcutParameters Methods 

The following are methods for ShortcutParameters.

getCallbackId() 

Signature

1public String getCallbackId()

Return Value

Type: String

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.