A modular Python package for fetching and summarizing chat history from Discord or Slack channels using AI.
example.mp4
โ ๏ธ Beta Notice: This package is currently in beta. While core functionality works, some features may be unstable or incomplete. Use at your own discretion and expect potential breaking changes in future releases.
Transform your Discord and Slack conversations into actionable insights! This package provides:
๐ฅ Fetch all messages from Discord/Slack channels since any date
๐งต Include messages from threads within channels
๐ค Generate intelligent summaries using local or remote LLMs
๐พ Save both full chat history and summaries to files
๐ญ Chat interactively with your conversation history
๐ง Import into your own projects and build cool things with it (bots, web apps, etc.)
- Discord and Slack channel integration
- Thread support - automatically collects messages from all threads
- User reference standardization - clean, readable output
- Smart summarization based on timespan:
๐ Project Event Update(0-2 days)๐ Periodical Digest(3-6 days)๐ Full Project Status Summary(7+ days)
- Model flexibility - local models (Ollama) or remote (OpenAI)
- User-friendly output - replaces IDs with actual usernames
- Chat with your history - ask questions about conversations
- Colorful terminal output with clear visual cues
- Graceful exit handling - no more ugly tracebacks
- Export formats - markdown files with accurate timestamps
- Modular architecture - clean separation of concerns
- Python package - easy integration into other projects
- Explicit token handling - no hidden environment dependencies
- Extensible design - perfect for building bots and web apps
Originally created for personal use as a CLI application, this package has been refactored to also work as an importable Python package for your own projects.
1. Clone and Install
git clone https://github.com/yourusername/what-the-chat.git
cd what-the-chat2. Choose Installation Method
๐ฏ Option A: Using pixi (recommended)
pixi install๐ Option B: Using pip
pip install -e .3. Setup Environment
Create a .env file with your tokens:
DISCORD_TOKEN=your_discord_bot_token
SLACK_TOKEN=your_slack_bot_token
OPENAI_API_KEY=your_openai_api_key # Only needed for remote modelsAdd to your own projects:
pip install git+https://github.com/ulfaslak/what-the-chat.gitGet a 30-day summary with interactive chat:
# Using pixi
pixi run python apps/launch_cli.py --since-days 30 --channel 123456789012345678 --chat
# Or direct script execution
python apps/launch_cli.py --since-days 30 --channel 123456789012345678 --chatSlack channels:
python apps/launch_cli.py --since-days 30 --platform slack --channel general --chatโจ What happens:
- ๐ฅ Fetches messages from the specified channel for the last 30 days
- ๐ค Generates an intelligent summary of the chat history
- ๐ฌ Starts an interactive chat session for Q&A
Save everything for later analysis:
python apps/launch_cli.py --since-days 30 --channel 123456789012345678 \
--dump-file ./output --dump-collected-chat-history๐ Creates:
discord_history_summary_[channel]_[dates].md- AI-generated summarydiscord_history_[channel]_[dates].md- Full conversation log
Switch to powerful cloud models:
python apps/launch_cli.py --since-days 30 --channel 123456789012345678 \
--model-source remote --model gpt-4oBuild What The Chat into your own applications:
import os
from datetime import datetime, timedelta
from what_the_chat import DiscordPlatform, SlackPlatform, SummarizationService, ChatService
# Get tokens and API keys explicitly
discord_token = os.getenv("DISCORD_TOKEN") # or however you manage secrets
slack_token = os.getenv("SLACK_TOKEN")
openai_api_key = os.getenv("OPENAI_API_KEY")
# Discord example with explicit token
discord = DiscordPlatform(discord_token)
since_date = datetime.now() - timedelta(days=7)
# Fetch Discord messages (in an async context)
chat_history, first_date = await discord.fetch_messages_with_token(channel_id, since_date)
user_mapping = discord.get_user_mapping()
# Or Slack example with explicit token
slack = SlackPlatform(slack_token)
chat_history, first_date = slack.fetch_messages_with_token("general", since_date)
user_mapping = slack.get_user_mapping()
# Generate summary with explicit API key
summarizer = SummarizationService(model_source="remote", model="gpt-4o", api_key=openai_api_key)
summary = summarizer.generate_summary(chat_history, user_mapping)
# Start interactive chat with explicit API key
chat_service = ChatService(model_source="remote", model="gpt-4o", api_key=openai_api_key)
chat_service.start_interactive_session(chat_history, user_mapping)
# For local models, no API key needed
local_summarizer = SummarizationService(model_source="local", model="deepseek-r1-distill-qwen-7b")
local_summary = local_summarizer.generate_summary(chat_history, user_mapping)| Argument | Description | Required | Default |
|---|---|---|---|
--since-days |
๐ Number of days to look back | โ | - |
--platform |
๐ Platform (discord/slack) | - | discord |
--channel |
๐บ Channel ID or name | โ | - |
--model-source |
๐ง Model source (local/remote) | - | local |
--model |
๐ค Specific model name | - | deepseek-r1-distill-qwen-7b |
--dump-file |
๐พ Save summary to file | - | - |
--dump-collected-chat-history |
๐ Save full chat history | - | false |
--chat |
๐ฌ Start interactive chat | - | false |
Once you're in the chat session, use these commands:
| Command | Description |
|---|---|
help |
๐ Show available commands |
exit, quit, q |
๐ End chat gracefully |
summary |
๐ Generate new summary |
users |
๐ฅ List all users in chat |
Ctrl+C |
โก Quick exit |
๐ฎ Discord Bot Setup
- Create a Discord application at Discord Developer Portal
- Create a bot for your application
- Enable the following intents:
- โ Message Content Intent
- Generate a token for your bot
- Invite the bot with Read Message History permissions
๐ผ Slack Bot Setup
- Create a Slack app at Slack API
- Add these OAuth scopes:
- โ
channels:history- read public channels - โ
groups:history- read private channels - โ
im:history- read direct messages - โ
mpim:history- read group direct messages - โ
users:read- get user information
- โ
- Install the app to your workspace
- Copy the Bot User OAuth Token to your
.envfile asSLACK_TOKEN
This package includes a comprehensive test suite with automated CI/CD:
# Run all tests
pixi run -e test pytest tests/ -v
# Run with coverage
pixi run -e test pytest tests/ --cov=what_the_chat --cov-report=term
# Run specific test file
pixi run -e test pytest tests/test_models.py -v- โ GitHub Actions CI - Automated testing using pixi environments
- โ Test Coverage - Reports sent to Codecov
- โ Package Installation - Verifies pixi installation and imports work
- โ Import Validation - Ensures all classes import correctly
- โ Dependency Caching - Fast CI with pixi environment caching
- โ Python Version Management - pixi automatically manages Python versions
Status badges in the header show real-time build and coverage status!
Contributions are most welcome! Please feel free to submit a Pull Request.
โญ If this project helped you, please consider giving it a star! โญ