Apex SDK for Slack (Beta)
Documentation Changelog
Enable Slack for Salesforce Beta
Set Up Your Development Environment
Set Up Your SFDX Project
Deploy a Slack App
Sample Apex SDK for Slack App
After you set up your development environment, configure your project definitions and create a scratch org for your first Slack app.
To configure your SFDX project definition:
Open the project in VS Code.
Update sfdx-project.json with the login URL for your Dev Hub org. Use the my.salesforce version (Classic) of the URL, not a Lightning Experience one. For example, https://my-dev-domain.my.salesforce.com.
1"sfdcLoginUrl": "https://<my_domain>.my.salesforce.com",Set sourceApiVersion to 54.0 or later.
1"sourceApiVersion": "54.0",Scratch orgs simplify your Slack app development and drive developer productivity and collaboration. You can only have 3 active orgs at once. By default, you can create up to 6 scratch orgs a day.
Scratch orgs are short-lived, development, and testing orgs that are similar to your production and sandbox orgs.
Note
To create a scratch org:
Sign up and configure the scratch org using the scratch org definition in project-scratch-def.json, and run this command.
1sf org create scratch --definition-file config/project-scratch-def.json --alias scratch1 --set-default --duration-days 30--alias sets an alias for your scratch org username so that you can refer to it with a simpler name from other commands.--set-default sets this org as the default scratch org for your project so that you don’t have to specify the target org with commands that require it.--duration-days sets the duration of the scratch org to the maximum of 30 days, after which it’s deleted and you lose access to it.After you create your scratch org, you can see it in your org list known to the CLI by running sf org list.
To see how many scratch orgs you’re using, run sf org list limits --target-org <DevHub org username or alias> and search for ActiveScratchOrgs and DailyScratchOrgs in the output table. Alternatively, to view your Active scratch orgs, go to the App Launcher in Lightning Experience, enter Scratch to find All Scratch Orgs and Scratch Org Info.
Tip
Capture your scratch org user information.
1sf org generate password --target-org scratch1--target-org specifies your scratch org username. You can find this information in Scratch Org Info. Alternatively, use the scratch1 alias you created earlier.1sf org display user --target-org scratch1Assign Slack permission sets to your scratch org user.
sf org open. Since you set this scratch org as the default using the --set-default flag in an earlier step, SFDX stores your authentication token and uses it to log in for you.You must also accept the Salesforce for Slack Beta Terms and Conditions to use Apex SDK for Slack in a scratch org.
Important
Confirm your SFDX setup.
SayHello.cls in force-app/main/default/classes. Copy and paste this code, and then save the file.1// SayHello.cls
2public class SayHello {
3 public String hello() {
4 return 'Hello World!';
5 }
6}SayHello.cls-meta.xml in force-app/main/default/classes. Copy and paste this code, and then save the file.1<?xml version="1.0" encoding="UTF-8"?>
2<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3 <apiVersion>54.0</apiVersion>
4 <status>Active</status>
5</ApexClass>1sf project deploy startWhen you deploy successfully, a summary is displayed. Next, deploy a Slack app to your scratch org.
If you receive an expired access or refresh token error, check that your scratch org is still valid and not expired.
Tip
Beta Feature