mirror of
https://github.com/tiennm99/danswer-docs.git
synced 2026-06-17 16:48:30 +00:00
97 lines
3.6 KiB
Plaintext
97 lines
3.6 KiB
Plaintext
---
|
|
title: Slack Bot Setup
|
|
description: "How to set up a Slack bot to automatically answer questions"
|
|
---
|
|
|
|
## How it works
|
|
|
|
Danswer will connect to your Slack instance via Web Sockets, and listen for relevant messages.
|
|
|
|
Slack will only send us messages for channels where DanswerBot has been manually added to. For all
|
|
channel messages (not messages inside a thread), Danswer will consider the question, search through
|
|
all available documents, and try to come up with an answer. If it finds an answer, it will respond to
|
|
the message in the **thread** as follows:
|
|
|
|

|
|
|
|
Since we are using Web Sockets, Danswer is able to initiate the connection. This means that this is able
|
|
to work even if you are running Danswer inside a firewall protected VPC.
|
|
|
|
## Setting up
|
|
|
|
### Authorization
|
|
|
|
**Note:** You must be an admin of the Slack workspace to set up the Slack bot.
|
|
|
|
1. Navigate and sign in to [https://api.slack.com/apps](https://api.slack.com/apps).
|
|
2. Create a new Slack app:
|
|
- Click the **Create New App** button in the top right.
|
|
- Select **From an app manifest** option.
|
|
- Select the relevant workspace from the dropdown and click **Next**.
|
|
|
|

|
|
|
|
3. Copy the following manifest into the text box
|
|
|
|
```
|
|
display_information:
|
|
name: DanswerBot
|
|
description: I help answer questions!
|
|
features:
|
|
bot_user:
|
|
display_name: DanswerBot
|
|
always_online: true
|
|
oauth_config:
|
|
scopes:
|
|
bot:
|
|
- channels:history
|
|
- channels:read
|
|
- groups:history
|
|
- channels:join
|
|
- app_mentions:read
|
|
- chat:write
|
|
settings:
|
|
event_subscriptions:
|
|
bot_events:
|
|
- app_mention
|
|
- message.channels
|
|
interactivity:
|
|
is_enabled: true
|
|
org_deploy_enabled: false
|
|
socket_mode_enabled: true
|
|
token_rotation_enabled: false
|
|
```
|
|
|
|
5. Click the **Create** button.
|
|
6. Generate an `App-level Token`, following the guide [here](https://api.slack.com/apis/connections/socket#token).
|
|
Add the `connections:write` scope to the app-level token and click **Generate**.
|
|
Copy this somewhere safe for now, as you will need this later to initiate the Web Socket-based connection to Slack.
|
|
7. In the app page, navigate to the **OAuth & Permissions** tab under the **Features** header.
|
|
8. Under **OAuth Tokens for Your Workspace**, select `Install to Workspace` and Allow the app.
|
|

|
|
9. Copy the **Bot User OAuth Token**, this will be needed later to enable us to respond to messages as DanswerBot.
|
|
|
|
### Setting Env variables
|
|
|
|
**Note:** Currently, Slack bot setup is only suppported out of the box for the docker compose based deployment.
|
|
Please contact us if you are deploying Danswer in some other way, we'd be happy to help you set up the Slack bot!
|
|
|
|
1. [OPTIONAL] SSH into the box where you are hosting Danswer. If running locally, ignore this step.
|
|
2. Navigate to `danswer/deployment/docker_compose.
|
|
3. Open up the `.env` file using your favorite editor and add the following two lines:
|
|
```
|
|
DANSWER_BOT_SLACK_APP_TOKEN=<APP_TOKEN_HERE>
|
|
DANSWER_BOT_SLACK_BOT_TOKEN=<BOT_TOKEN_HERE>
|
|
```
|
|
4. Restart the background service with one of the following:
|
|
```
|
|
# if running locally
|
|
docker compose -f docker-compose.dev.yml -p danswer-stack up background -d --force-recreate
|
|
|
|
# if running on a machine in the cloud for production use
|
|
docker compose -f docker-compose.prod.yml -p danswer-stack up background -d --build --force-recreate
|
|
```
|
|
5. Wait a few minutes for the background component to restart, and voila you're done!
|
|
You should be able to add DanswerBot to a channel of your choosing,
|
|
ask a question, and get a response!
|