Skip to main content

Dify Slack Bot: Your AI Knowledge Assistant

·2 mins

This guide will walk you through setting up a powerful AI-powered knowledge bot for your Slack workspace using Dify.

Part 1: Creating Your Slack App #

Step 1: Create a New Slack App #

Visit the Slack API portal and click Create New App.

Create New App

Step 2: Choose “From a Manifest” #

Select this option to configure your app using our pre-built manifest.

From Manifest

Step 3: Select Your Workspace #

Choose workspace Education Group (or your workspace) and click Next.

Select Workspace

Step 4: Configure App Manifest #

Copy and paste the following YAML manifest:

display_information:
  name: oa-knowledge-bot
features:
  bot_user:
    display_name: oa-knowledge-bot
    always_online: false
oauth_config:
  scopes:
    bot:
      - app_mentions:read
      - im:history
      - incoming-webhook
      - im:write
      - chat:write
      - channels:join
settings:
  event_subscriptions:
    bot_events:
      - app_mention
      - message.im
  interactivity:
    is_enabled: true
  org_deploy_enabled: false
  socket_mode_enabled: true
  token_rotation_enabled: false

Update YAML
Manifest Configuration

Step 5: Review and Create #

Review the summary and click Create to finalize your app.

Review Summary
Creation Confirmation

🎉 Congratulations! You’ve successfully created your Slack app.

Step 6: Generate App-Level Token #

Scroll down to App-Level Tokens and click Generate Token and Scopes.

Generate App Token

Step 7: Configure Token Settings #

  1. Enter a descriptive Token Name (e.g., “Dify Bot Connection”)
  2. Add the connections:write scope
  3. Click Generate

Token Configuration

Step 8: Save Your SLACK_APP_TOKEN #

Copy and securely store this token - you’ll need it later.

Copy App Token

Step 9: Install App to Workspace #

Navigate to OAuth & Permissions in the left menu.

OAuth & Permissions

Click Install to Workspace (or your workspace name).

Install to Workspace

Step 10: Authorize the App #

Select the channel(s) where you want the bot to operate and click Allow.

Connect Channel
Allow Access

Step 11: Save Your SLACK_BOT_TOKEN #

Copy and securely store the Bot User OAuth Token - you’ll need this for configuration.

Bot Token

Part 2: Obtaining Your Dify API Key #

Access your Dify dashboard and generate an API key for your knowledge base.

Dify Dashboard
Dify API Key

Part 3: Deploying Your Dify Slack Bot #

Step 1: Clone the Repository #

git clone https://github.com/graysonchen/dify-bot.git
git checkout stable
cd dify-bot

Step 2: Configure Environment Variables #

cp .env.example .env

Edit the .env file with your credentials:

DIFY_API_BASE_URL=http://dify.leonx.cloud/v1
DIFY_API_KEY=your_dify_api_key_here

SLACK_BOT_TOKEN=xoxb-xxxxxxxxxxxxxxx-xxxxxxxxxxxxxxx-xxxxxxxxxxxxxxx
SLACK_APP_TOKEN=xapp-1-xxxxxxxxxxxxxxx-xxxxxxxxxxxxxxx-xxxxxxxxxxxxxxx

Step 3: Build the Docker Image #

docker build . -t pinkbanana/bot:latest

Step 4: Run the Bot #

# Development environment
docker run -itd --env-file .env --name=dify-slack pinkbanana/bot:latest
docker update --restart=always dify-slack

# Production commands
docker stop dify-slack-prod
docker start dify-slack-prod

What’s Next? #

Once deployed, your AI knowledge bot will be available in your Slack workspace. You can:

  • Ask questions directly to the bot in DMs
  • Mention the bot in channels it’s been added to
  • Get instant answers from your knowledge base

Enjoy your new AI-powered assistant!