This Slack chatbot app template provides a customizable solution for integrating AI-powered conversations into your Slack workspace using DigitalOcean's GenAI Platform. Deploy the app on DigitalOcean App Platform for a fully managed experience.
- Interact with the bot by mentioning it in conversations and threads
- Send direct messages to the bot for private interactions
- Use the
/ask-sailor
command to communicate with the bot in channels where it hasn't been added - Use the
/sailor-summary
command to have Sailor summarize a Slack thread and DM you an AI generated summary - Utilize a custom function for integration with Workflow Builder to summarize messages
- Select your preferred AI model from the app home to customize responses
- Seamless integration with DigitalOcean GenAI Platform
- Choice of state storage (optional):
- File-based state store creates a file in /data per user to store preferences
- Redis state store for distributed deployments (recommended for App Platform)
- A Slack workspace where you have permissions to install apps
- Access to the DigitalOcean GenAI Platform
- Open https://api.slack.com/apps/new and choose "From an app manifest"
- Choose the workspace you want to install the application to
- Copy the contents of manifest.json into the text box that says
*Paste your manifest code here*
(within the JSON tab) and click Next - Review the configuration and click Create
- Click Install to Workspace and Allow on the screen that follows. You'll be redirected to the App Configuration dashboard.
Before running the app, store these environment variables:
- From your app's configuration page, go to OAuth & Permissions and copy the Bot User OAuth Token (
SLACK_BOT_TOKEN
) - From Basic Information, create an app-level token with the
connections:write
scope (SLACK_APP_TOKEN
) - Get your DigitalOcean GenAI API key from the DigitalOcean dashboard (
GENAI_API_KEY
) - Set your GenAI API URL, append
/api/v1
(GENAI_API_URL
)
# Set environment variables
export SLACK_BOT_TOKEN=<your-bot-token>
export SLACK_APP_TOKEN=<your-app-token>
export GENAI_API_KEY=<your-genai-api-key>
export GENAI_API_URL=<your-genai-api-url> # https://agent-<id>.ondigitalocean.app/api/v1
# Clone this project
git clone https://github.com/DO-Solutions/slack-digitalocean-genai-agent
# Navigate to the project directory
cd bolt-python-ai-chatbot
# Setup python virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Start your local server
python3 app.py
This application can be easily deployed to DigitalOcean App Platform:
- Fork or clone this repository to your GitHub account
- In the DigitalOcean control panel, go to App Platform and create a new app
- Connect your GitHub repository
- Configure the environment variables (
SLACK_BOT_TOKEN
,SLACK_APP_TOKEN
,GENAI_API_KEY
,GENAI_API_URL
) - Optionally add a Redis database component for state storage
- Deploy the application
The /ai
directory contains the core AI functionality:
ai_constants.py
: Defines constants used throughout the AI module/providers/__init__.py
: Contains utility functions for handling API responses and available providers
The GenAI provider enables communication with DigitalOcean's GenAI Platform through an OpenAI-compatible API.
For App Platform deployments, we recommend using the Redis state storage option:
# Set Redis connection string
export REDIS_URL=<your-redis-connection-string>
Example with DigitalOcean Managed Redis:
export REDIS_URL=rediss://default:password@hostname.db.ondigitalocean.com:25061
While DigitalOcean GenAI is the primary focus, this template also supports other AI providers:
To use OpenAI models, add your API key:
export OPENAI_API_KEY=<your-api-key>
For Anthropic models, configure your API key:
export ANTHROPIC_API_KEY=<your-api-key>
You can create a custom provider by extending the base class in ai/providers/base_api.py
and updating ai/providers/__init__.py
to include your implementation.