> ## Documentation Index
> Fetch the complete documentation index at: https://docs.heygaia.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Slack bot

> Create a Slack app with Socket Mode and run GAIA's Slack bot from source against your local API.

The Slack bot uses Socket Mode: it opens a connection to Slack instead of receiving webhooks, so it needs no public URL.

Do the [shared bot setup](https://docs.heygaia.io/bots/overview.md#shared-setup) first. You also need a Slack workspace where you are an admin.

## Step 1: Create a Slack App

1. Go to [api.slack.com/apps](https://api.slack.com/apps)
2. Click **Create New App → From scratch**
3. Give your app a name and select your workspace

## Step 2: Enable Socket Mode

1. In the sidebar, go to **Socket Mode**
2. Toggle **Enable Socket Mode** on
3. Generate an **App-Level Token** with the `connections:write` scope
4. Copy the token, it starts with `xapp-`

## Step 3: Configure Bot Permissions

1. Go to **OAuth & Permissions**
2. Under **Bot Token Scopes**, add:
   * `chat:write`
   * `commands`
   * `im:history`
   * `im:read`
   * `im:write`
3. Under **User Token Scopes**, add:
   * `identity.basic`
4. Under **Redirect URLs**, add:
   ```
   http://localhost:8000/api/v1/platform-auth/slack/callback
   https://your-api-domain.com/api/v1/platform-auth/slack/callback
   ```
5. Click **Install App to Workspace** (or **Reinstall** if already installed)
6. Copy the **Bot User OAuth Token** (starts with `xoxb-`)
7. Copy the **Client ID** and **Client Secret** from **Basic Information**
8. Copy the **Signing Secret** from **Basic Information**

## Step 4: Register Slash Commands

Go to **Slash Commands** and create each command in the [Commands Reference](https://docs.heygaia.io/bots/commands.md). Leave the Request URL blank.

## Step 5: Configure Environment Variables

In `apps/bots/.env`:

```bash theme={null}
SLACK_BOT_TOKEN=xoxb-your-bot-token
SLACK_APP_TOKEN=xapp-your-app-token
SLACK_SIGNING_SECRET=your-signing-secret
```

For OAuth account linking, also add to `apps/api/.env`:

```bash theme={null}
SLACK_OAUTH_CLIENT_ID=your_client_id
SLACK_OAUTH_CLIENT_SECRET=your_client_secret
```

These enable users to link their Slack account from the GAIA web app settings page.

## Step 6: Start the Bot

```bash theme={null}
nx dev bot-slack
```

## Troubleshooting

| Problem | Solution |
| - | - |
| Bot doesn't respond | Check Socket Mode is enabled and all tokens are correct |
| Command not found | Verify slash commands are created in the Slack app dashboard, then reinstall the app |
| Authentication fails | Check that `GAIA_BOT_API_KEY` is identical in `apps/bots/.env` and `apps/api/.env` |

## Things to try next

* [Automate Gmail and Slack with GAIA](https://heygaia.io/automate/gmail-slack)
* [Automate Slack and Notion with GAIA](https://heygaia.io/automate/slack-notion)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.