---
schema_version: "1"
id: abec95e02786012ec172ca26e333e0225ee94e92beff82f12a10cb40f297c30e
title: Work with Shortcuts
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforce-slack-sdk/apex-slack-sdk/guides/apex_ref/apex_ref_shortcut.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-slack-sdk/guide/apex_ref_shortcut.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 9b68e0a62597e3daa11ca74865668baac0b4473987b71f3626efe2188f395724
products:
  - Apex SDK for Slack (Beta)
---
# 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](https://developer.salesforce.com/docs/platform/salesforce-slack-sdk/build/actions.md).

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](https://api.slack.com/interactivity/shortcuts/using#shortcut_response).

### ShortcutDispatcher Methods

`ShortcutDispatcher` has the following method.

#### invoke(parameters, context)

Invokes the action handler.

**Signature**

```java
public Slack.ActionHandler invoke(
  Slack.ShortcutParameters parameters,
  Slack.RequestContext context
);
```

**Parameters**

_parameters_

Type: [Slack.ShortcutParameters](https://developer.salesforce.com/docs/platform/salesforce-slack-sdk/guide/apex_ref_shortcut.md)

The action parameters for the shortcut handler. The format is a `Map<String, Object>`.

_context_

Type: [Slack.RequestContext](https://developer.salesforce.com/docs/platform/salesforce-slack-sdk/guide/apex_ref_requestcontext.md)

Describes the context in which a Slack action is invoked.

**Return Value**

Type: [Slack.ActionHandler](https://developer.salesforce.com/docs/platform/salesforce-slack-sdk/guide/apex_ref_dispatchers.md)

**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**

```java
public ShortcutParameters(String callbackId)
```

**Parameters**

_callbackId_

Type: String

The ID sent in the interaction payload.

### ShortcutParameters Methods

The following are methods for `ShortcutParameters`.

#### getCallbackId()

**Signature**

```java
public String getCallbackId()
```

**Return Value**

Type: String
