
This repository provides a Slack bot backend implemented in Python that uses Slack Bolt and Google Cloud's Vertex AI Gemini model via the Agent Development Kit. The bot responds to text, images, PDFs, plain text files, videos, and audio messages, while maintaining conversation context within Slack threads. It is designed to run on Cloud Run.
If you want to use the Google Gen AI SDK, please refer to this repository💡
- Responds to
@mention
messages in Slack channels. - Supports text, image, PDF, text file, video, and audio inputs from Slack messages. Files are fetched via authenticated URLs and sent to Gemini for multimodal understanding.
- Maintains conversation context by retrieving prior messages in a thread and sending them as conversation history to Gemini.
- Formats responses using Slack-compatible Markdown for rich text output.
- FastAPI-based web server suitable for Cloud Run.
- Deployment script for building and deploying to Cloud Run.
app/
main.py # FastAPI app and Slack Bolt handlers
agents/
comedian.py # ex: Comedian agent implementation
tools/
get_current_datetime.py # ex: Date/time utility tool
scripts/
deploy.sh # Helper script to deploy to Cloud Run
Dockerfile # Container definition for Cloud Run
requirements.txt # Python dependencies
llms.txt # ADK documentation for LLM reference
llms-full.txt # Extended ADK documentation for LLM context
- Python 3.13
- Google Cloud SDK with
gcloud
authenticated - Slack workspace admin privileges
- Install dependencies
python -m venv venv source venv/bin/activate pip install -r requirements.txt
- Configure environment variables
cp .env.example .env # edit .env and set your Slack and Google Cloud credentials # ALLOWED_SLACK_WORKSPACE is the Slack team ID to allow requests from
- Run the server
uvicorn app.main:fastapi_app --host 0.0.0.0 --port 8080 --reload
- Use a tunneling tool like
ngrok
to exposehttp://localhost:8080/slack/events
to Slack during development.
The Agent Development Kit includes a built-in web-based Development UI that you can run locally. It's a powerful tool for testing, debugging, and interacting with your agent during development. It provides a chat interface to send messages to your agent and inspect the results.
-
Start the ADK web server:
adk web
-
Interact with your agent: Open the local URL (usually
http://127.0.0.1:8000
) in your browser to use the Development UI.
- Create a new Slack app at https://api.slack.com/apps.
- Under OAuth & Permissions, add the following Bot Token scopes:
app_mentions:read
chat:write
channels:history
groups:history
im:history
mpim:history
files:read
- Install the app to your workspace to obtain
SLACK_BOT_TOKEN
andSLACK_SIGNING_SECRET
. - Enable Event Subscriptions and set the Request URL to
https://<your-cloud-run-service-url>/slack/events
. - Subscribe to bot events:
app_mention
. - Invite the bot to channels where you want to use it.
The repository includes a helper script to build the container and deploy to Cloud Run. Ensure your .env
contains SLACK_BOT_TOKEN
and SLACK_SIGNING_SECRET
before running:
Enable the Cloud Build API for your project:
gcloud services enable cloudbuild.googleapis.com
Then deploy:
./scripts/deploy.sh
The script will:
- Build the container image using Cloud Build.
- Deploy the image to Cloud Run.
- Set the required environment variables on the service.
After deployment, configure the Slack app's event subscription URL to the Cloud Run service URL.