A Slack bot that uses Ollama's local LLM capabilities to provide AI-powered responses and thread summarization. Name suggestions are welcome :)
-
Public Summary: Get a summary of any Slack thread that's visible to all users
@BotName summarize threador
@BotName thread summary -
Private Summary: Get a thread summary that's only visible to you
@BotName summarize thread privateor
@BotName thread summary me only
- The bot can respond to general questions and engage in conversations
- Uses local LLM through Ollama for responses
- All responses are context-aware and thread-based
- Ollama installed on your machine
- Python 3.8 or higher
- A Slack workspace where you can install apps
-
Go to api.slack.com/apps
-
Click "Create New App"
- Choose "From scratch"
- Name your app
- Select your workspace
-
Under "Basic Information":
- Note down the "Signing Secret"
- Scroll down to "App-Level Tokens"
- Click "Generate Token and Scopes"
- Add the
connections:writescope - Name the token and create it
- Save the generated app token (starts with
xapp-)
-
Under "OAuth & Permissions":
- Add the following Bot Token Scopes:
app_mentions:readchannels:historychat:writegroups:historyim:historympim:historyusers:read
- Install the app to your workspace
- Save the Bot User OAuth Token (starts with
xoxb-)
- Add the following Bot Token Scopes:
-
Under "Socket Mode":
- Enable Socket Mode
-
Under "Event Subscriptions":
- Enable Events
- Subscribe to bot events:
- Add
app_mentions
- Add
- Clone this repository:
git clone https://github.com/yourusername/slack-ollama.git
cd slack-ollama- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: .\venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Create a
.envfile in the project root:
SLACK_BOT_TOKEN=xoxb-your-bot-token
SLACK_SIGNING_SECRET=your-signing-secret
SLACK_APP_TOKEN=xapp-your-app-token
OLLAMA_MODEL=llama3.2:latest
OLLAMA_HOST=http://localhost:11434- Start Ollama and pull the required model:
ollama run llama3.2:latest- Run the bot:
python agent.py- Invite the bot to a channel:
/invite @YourBotName
- Mention the bot with your request:
- For general questions:
@BotName How does photosynthesis work? - For thread summaries:
@BotName summarize thread - For private thread summaries:
@BotName summarize thread private
- For general questions:
The bot provides clear error messages for common issues:
- Missing permissions
- Unable to access thread history
- Connection issues with Ollama
- Invalid commands
The bot is built using:
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request