Set Up Your Development Environment

Use Salesforce DX tools for an integrated development experience. Make sure you have a Slack workspace that you can deploy apps to.

To set up Salesforce DX tools:

  1. Set up Visual Studio Code.
  2. Install the Salesforce Extension Pack for Visual Studio Code. Salesforce Extension Pack provides powerful features for working with the Salesforce CLI, Apex, and other Salesforce platform features.
  3. Install Salesforce CLI.

Next, get your Salesforce org ready for Slack development by following these steps.

A Dev Hub org enables you to create and manage scratch orgs.

You must also accept the Salesforce for Slack Beta Terms and Conditions to use Apex SDK for Slack.

To set up a Dev Hub org with My Domain enabled:

  1. Create a Developer Edition (DE) org if you don't already have one.
  2. Enable My Domain. An email is sent to you when the domain is ready. Log in from your domain and deploy the domain to users.
  3. Enable Dev Hub in your org and select the Enable Unlocked Packages and Second-Generation Managed Packages option.

If you're working with second-generation managed packaging (2GP), see Distribute Slack Apps.

To enable user permission for developing Slack apps:

  1. From Setup, in the Quick Find box, enter Permission, and then select Permission Sets.
  2. Select an existing permission set, or create one.
  3. Under System Permissions, enable permission Connect Salesforce with Slack. If you're working with second-generation packages, enable permission Create and Update Second-Generation Packages as well. Click Save.
  4. Click Manage Assignments and assign the permission to your admin user.
  5. Click Done.

To authenticate to your org from the CLI:

  1. Use a terminal to cd to a location.

  2. Create an SFDX project using this command.

  3. Go to your project.

  4. Authenticate to your org.

    • org login web opens a browser using the URL specified by --instance-url. Use the my.salesforce version (Classic) of the URL, not a Lightning Experience one.
    • --alias sets an alias for your Dev Hub org username so that you can refer to it with a simpler name from other commands.
    • --set-default-dev-hub sets this org as the default Dev Hub org for your project so that you can omit the target Dev Hub org for commands that require it.
  5. Log in with the username and password from the org you just made. Allow access to the org from the CLI.

The command exits in your shell when the authentication is successful.

You can see your authenticated orgs by running sf org list. If you must authenticate to your dev hub org again, run sf org login web --set-default-dev-hub.

Now that you authenticated to your Dev Hub org, you can run your Slack app with Apex.