---
schema_version: "1"
id: ad20354b2c2ee4faf843c8a5929bffa1560a2a645e0721bc682e6e23b2ea2147
title: SlackApp
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforce-slack-sdk/apex-slack-sdk/guides/api_meta/meta_slackapp.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-slack-sdk/guide/meta_slackapp.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: aa56dd088e1f19d1f37aded497272555f114aa5fc9ec6f122fc5a22b65500d6b
products:
  - Apex SDK for Slack (Beta)
---
# SlackApp

Represents a Slack app. This type extends the [MetadataWithContent](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_metadatawithcontent.htm) metadata type and inherits its `content` and `fullName` fields.

## Declarative Metadata File Suffix and Directory Location

The file suffix is `.slackapp` for the Slack app configuration file. The accompanying metadata file is named `YourAppName.slackapp-meta.xml`. The files are stored in the `slackapps` folder in the corresponding package directory.

## Version

Slack apps are available in API version 54.0 and later.

## Special Access Rules

To use this metadata type, your org must have Slack capabilities and packaging enabled. You must also [enable user permissions](https://developer.salesforce.com/docs/platform/salesforce-slack-sdk/setup-your-env.md) to connect Salesforce with Slack.

## Fields

| Field Name      | Field Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| --------------- | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `appKey`        | string       | Required. The app ID, as shown on the Slack app's Basic Information page.                                                                                                                                                                                                                                                                                                                                                                                      |
| `appToken`      | string       | Required. The app token, as shown on the Basic Information page. The app token starts with `xapp-` . Retrieving this field isn't supported. The app token is always returned as `*`.                                                                                                                                                                                                                                                                           |
| `botScopes`     | string       | The comma-separated list of scopes that determine what your app can access, as shown on the OAuth & Permissions page. For example, `chat:write` lets your app post messages. See [Slack API: Permission scopes](https://api.slack.com/scopes).                                                                                                                                                                                                                 |
| `clientKey`     | string       | Required. The client ID, as shown on the Basic Information page. Retrieving this field isn't supported. The client ID is always returned as `*`.                                                                                                                                                                                                                                                                                                               |
| `clientSecret`  | string       | Required. The client secret, as shown on the Basic Information page. See [Slack API: oauth.v2.access](https://api.slack.com/methods/oauth.v2.access). Retrieving this field isn't supported. The client secret is always returned as `*`.                                                                                                                                                                                                                      |
| `content`       | base64Binary | The page content. Base 64-encoded binary data. Prior to making an API call, client applications must encode the binary attachment data as base64. Upon receiving a response, client applications must decode the base64 data to binary. This conversion is usually handled for you by a SOAP client. This field is inherited from the MetadataWithContent component.                                                                                           |
| `fullName`      | string       | The developer name used as a unique identifier for API access. `fullName` can contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. This field is inherited from the [Metadata](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/docs/atlas.en-us.api_meta.meta/api_meta/metadata.htm) component. |
| `isProtected`   | boolean      | Indicates whether the Slack app is protected (true) or not (false). If true, only this package can reference the Slack app directly.                                                                                                                                                                                                                                                                                                                           |
| `masterLabel`   | string       | Required. Name of the Slack app that appears in the Salesforce user interface.                                                                                                                                                                                                                                                                                                                                                                                 |
| `signingSecret` | string       | Required. The string that Slack uses to sign the request. Retrieving this field isn't supported. The signing secret is always returned as `*`.                                                                                                                                                                                                                                                                                                                 |
| `userScopes`    | string       | The comma-separated list of scopes that access user data and act on behalf of users that authorize them. For example, `channels:write` manages a user's public channels and create new ones on a user's behalf. See [Slack API: Permission scopes](https://api.slack.com/scopes).                                                                                                                                                                              |

## Usage

`SlackApp` enables you to configure your app's info, configuration, and connection.

Create the following files:

- `<appname>.slackapp-meta.xml` defines your app connection, such as your app key and token.
- `<appname>.slackapp` defines your app handlers for slash commands, shortcuts, and event handlers in YAML format.

By default, posting to Slack on behalf of the app is restricted. If the app is protected, Apex references to the app, like `Slack.App.namespace.AppName`, fail at save time.

```java
// Don't do this
Slack.App.namespace.ProtectedAppName; // FAIL
// Do this instead
Slack.App.namespace.UnprotectedAppName;
Slack.App.MyAppName;
```

## Declarative Metadata Sample Definition

This is the definition of a Slack app in the `MySlackApp.slackapp-meta.xml` file.

**note:** Replace the `botScopes`, `userScopes`, and other field values with your own.

```xquery
<?xml version="1.0" encoding="UTF-8"?>
<SlackApp xmlns="http://soap.sforce.com/2006/04/metadata">
  <appKey>A01NQ710000</appKey>
  <appToken>xapp-1-A1191J583K2-2584222565523...</appToken>
  <botScopes>*</botScopes>
  <clientKey>62673491768.1771200000000</clientKey>
  <clientSecret>33fea01130000</clientSecret>
  <isProtected>false</isProtected>
  <masterLabel>My Slack App</masterLabel>
  <signingSecret>8f742231b10e8888abcd99yyyzzz85a5</signingSecret>
  <userScopes>*</userScopes>
</SlackApp>
```

The corresponding `MySlackApp.slackapp` configuration file in YAML format, which defines the commands and shortcut handlers. See [Define an App](https://developer.salesforce.com/docs/platform/salesforce-slack-sdk/build/app-definition.md).

```yml
description: Hello World Example App
commands:
  /apex-hello:
    action:
      definition: apex__action__SayHello
    title: Say Hello
    description: A command to say Hello
```

In the `/classes` directory, create the `SayHello.cls` Apex class and the `SayHello.cls-meta.xml` files. This class retrieves the `hello` example view definition. See [ViewDefinition](https://developer.salesforce.com/docs/platform/salesforce-slack-sdk/guide/meta_viewdefinition.md).

```java
// SayHello.cls
public class SayHello extends Slack.SlashCommandDispatcher {

    public override Slack.ActionHandler invoke(Slack.SlashCommandParameters parameters, Slack.RequestContext context) {
        return Slack.ActionHandler.modal(new Handler(parameters, context), 'Say Hello');
    }

    public class Handler implements Slack.ModalHandler {

        Slack.SlashCommandParameters parameters;
        Slack.RequestContext context;

        public Handler (Slack.SlashCommandParameters parameters, Slack.RequestContext context){
            this.parameters = parameters;
            this.context = context;
        }

        public Slack.ModalView call () {
            String name = parameters.getText();
            Slack.ViewReference viewReference = Slack.View.hello.get();
            viewReference.setParameter('name', name);
            Slack.ModalView modalView = new Slack.ModalView.builder()
                .viewReference(viewReference)
                .build();
            return modalView;
        }
    }
}
```

The `SayHello.cls-meta.xml` file looks like this.

```xquery
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>54.0</apiVersion>
    <status>Active</status>
</ApexClass>
```

## Wildcard Support in the Manifest File

This metadata type supports the wildcard character \* (asterisk) in the package.xml manifest file. For information about using the manifest file, see [Deploying and Retrieving Metadata with the Zip File](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/docs/atlas.en-us.api_meta.meta/api_meta/file_based_zip_file.htm).
