# Set Up Your Development Environment

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

To set up Salesforce DX tools:

1. [Set up VS Code.](https://code.visualstudio.com/)
2. [Install the Salesforce Extension Pack for VS Code.](https://marketplace.visualstudio.com/items?itemName=salesforce.salesforcedx-vscode) Salesforce Extension Pack provides features for working with the Salesforce CLI, Apex, and other Salesforce Platform features.
3. [Install Salesforce CLI.](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_install_cli.htm)

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

- [Set Up Your Development Environment](#set-up-your-development-environment)
  - [Set Up Your Dev Hub Org](#set-up-your-dev-hub-org)
  - [Enable User Permissions](#enable-user-permissions)
  - [Authenticate to Your Dev Hub Org](#authenticate-to-your-dev-hub-org)
  - [See Also](#see-also)

## Set Up Your Dev Hub Org

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

:::important
You must also [accept the Salesforce for Slack Beta Terms and Conditions](/docs/platform/salesforce-slack-sdk/guide/enable-beta.md) to use Apex SDK for Slack.
:::

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

1. [Create a Developer Edition (DE) org](https://developer.salesforce.com/signup) if you don't already have one.
2. [Enable My Domain](https://help.salesforce.com/s/articleView?id=xcloud.domain_name_rename.htm\&type=5). 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](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_setup_enable_devhub.htm) and select the **Enable Unlocked Packages and Second-Generation Managed Packages** option.

:::note
If you're working with second-generation managed packaging (2GP), see [Distribute Slack Apps](/docs/platform/salesforce-slack-sdk/guide/packaging.md).
:::

## Enable User Permissions

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. Save your changes.
4. Click **Manage Assignments** and assign the permission to your admin user.
5. Click **Done**.

## Authenticate to Your Dev Hub Org

To authenticate to your org from the CLI:

1. Use a terminal to cd to a location.

2. Create an SFDX project by using this command.

   ```bash
   sf project generate --name <project_name>
   ```

3. Go to your project.

   ```bash
   cd <project_name>
   ```

4. Authenticate to your org.

   ```bash
   sf org login web --alias devhub --set-default-dev-hub --instance-url https://<my_domain>.my.salesforce.com
   ```

   - `org login web` opens a browser and uses 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.

:::tip
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](/docs/platform/salesforce-slack-sdk/guide/run-sfdx.md).

## See Also

- [Enable Dev Hub Features in Your Org](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_setup_enable_devhub.htm)
- [External Client Apps and Connected Apps](https://help.salesforce.com/s/articleView?id=xcloud.external_integrations.htm\&type=5)
