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:
- Set up Visual Studio Code.
- 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.
- 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:
- Create a Developer Edition (DE) org if you don't already have one.
- 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.
- 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:
- From Setup, in the Quick Find box, enter Permission, and then select Permission Sets.
- Select an existing permission set, or create one.
- 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.
- Click Manage Assignments and assign the permission to your admin user.
- Click Done.
To authenticate to your org from the CLI:
-
Use a terminal to cd to a location.
-
Create an SFDX project using this command.
-
Go to your project.
-
Authenticate to your org.
org login web
opens a browser using the URL specified by--instance-url
. Use themy.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.
-
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.