Define an App

Define your app using the SlackApp metadata type. In your SFDX project, create the app definition in the slackapps folder.

An app definition includes:

  • <appname>.slackapp: The configuration file that contains the app handlers for slash commands, shortcuts, and event handlers in YAML format
  • <appname>.slackapp-meta.xml: The metadata file that contains connection settings to communicate with Slack

Bind an action to handle each command, shortcut, and event in your app.

An action executes when a Slack request is received. Actions are assigned to hooks in app metadata and events in a view.

This example app configuration binds actions to several commands, a global shortcut, a message shortcut, and an event.

The app configuration includes the following keys.

KeyTypeRequiredDescription
descriptionStringNoA description of the app. Not used in code.
commandsObjectNoA map of slash command keys to action bindings that handle the slash commands. Define a key for each slash command that you defined in your Slack app at api.slack.com/apps. A slash command must start with /.
globalShortcutsObjectNoA map of global shortcut callback ID keys to action bindings that handle the global shortcuts. Define a key for each global shortcut that you defined in your Slack app at api.slack.com/apps.
messageShortcutsObjectNoA map of message shortcut callback ID keys to action bindings that handle the message shortcuts. Define a key for every message shortcut that you defined in your Slack app at api.slack.com/apps.
eventsObjectNoA map of event keys to action bindings that handle the events. Define a key for each event that your Slack app subscribes to at api.slack.com/apps.

An action binding is an object that represents a command, global shortcut, message shortcut, or event.

The action binding is specified by the following keys.

Keys

KeyTypeRequiredDescription
actionStringYesThe address to an Apex class in the format apex__action__ClassName or apex__action__Namespace.ClassName bound to the command, shortcut, or event.
titleStringNoReserved for future use.
descriptionStringNoA description of the action binding. Not used in code.

Configure your Apex SDK for Slack app to communicate with the Slack app. In the slackapps folder, create a file called <appname>.slackapp-meta.xml, where <appname> matches the <appname>.slackapp file.

For field information, see SlackApp metadata type.