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.
Key | Type | Required | Description |
---|---|---|---|
description | String | No | A description of the app. Not used in code. |
commands | Object | No | A 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 / . |
globalShortcuts | Object | No | A 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. |
messageShortcuts | Object | No | A 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. |
events | Object | No | A 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
Key | Type | Required | Description |
---|---|---|---|
action | String | Yes | The address to an Apex class in the format apex__action__ClassName or apex__action__Namespace.ClassName bound to the command, shortcut, or event. |
title | String | No | Reserved for future use. |
description | String | No | A 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.