A Discord bot that automatically summarizes IT articles and blog posts using OpenAI's GPT models. Built with TypeScript, Express, and Discord Interactions.
- 🤖 AI-powered article summarization using OpenAI GPT-3.5-turbo
- 🏷️ Automatic tag generation based on article content
- 📖 Extracts and summarizes web articles using Cheerio
- 💡 Generates "Why it's interesting" explanations
- 🔄 Regenerate summaries with one click
- ✏️ Edit summaries through interactive modals
- 🎨 Rich embeds with formatted output
- Node.js >= 18
- npm
- Discord Application with bot token
- OpenAI API Key
- ngrok or similar service for local development
- Docker and Docker Compose for local Redis server
- Optional: Upstash Redis account for production Redis
npm installUsing Docker Compose, you can quickly spin up a local Redis server:
docker-compose up -d- Go to the Discord Developer Portal
- Click "New Application" and give it a name
- Go to the "Bot" section and click "Add Bot"
- Under the bot's token section, click "Reset Token" and copy it (this is your
DISCORD_TOKEN) - Go to "OAuth2" > "General"
- Copy your Application ID (this is your
APP_ID) - Copy your Public Key (this is your
PUBLIC_KEY)
- Copy your Application ID (this is your
- Go to "OAuth2" > "URL Generator"
- Select scopes:
botandapplications.commands - Select bot permissions:
Send Messages,Use Slash Commands,Embed Links - Copy the generated URL and invite the bot to your test server
- Select scopes:
-
Copy
.env.exampleto.env:cp .env.example .env
-
Edit
.envand fill in your values:# Discord Configuration APP_ID=your_application_id DISCORD_TOKEN=your_bot_token PUBLIC_KEY=your_public_key GUILD_ID=your_test_server_id # Optional: for faster command registration during development # OpenAI Configuration OPENAI_API_KEY=your_openai_api_key # Redis Configuration (optional, for production) UPSTASH_REDIS_REST_URL=your_upstash_redis_rest_url UPSTASH_REDIS_REST_TOKEN=your_upstash_redis_rest_token
Where to find these values:
APP_ID: Discord Developer Portal > Your App > General Information > Application IDDISCORD_TOKEN: Discord Developer Portal > Your App > Bot > TokenPUBLIC_KEY: Discord Developer Portal > Your App > General Information > Public KeyGUILD_ID: Right-click your Discord server > Copy Server ID (requires Developer Mode)OPENAI_API_KEY: OpenAI API KeysUPSTASH_REDIS_REST_URLandUPSTASH_REDIS_REST_TOKEN: From your Upstash Redis database dashboard (if using Upstash)
Discord requires a public HTTPS endpoint for interactions. Use ngrok to expose your local server:
# Install ngrok
npm install -g ngrok
# or download from https://ngrok.com/download
# Authenticate (one-time setup)
ngrok config add-authtoken YOUR_NGROK_TOKEN
# Start ngrok tunnel
ngrok http 3000Copy the HTTPS URL (e.g., https://abc123.ngrok-free.app)
- Go to your Discord Application in the Developer Portal
- Navigate to "General Information"
- Set Interactions Endpoint URL to:
https://your-ngrok-url.ngrok-free.app/interactions - Discord will verify the endpoint (make sure your bot is running!)
npm run devThe server will start on http://localhost:3000
Then run ngrok as described above to expose it publicly.
After making changes to commands, register them with Discord:
npm run registerNote: If you set GUILD_ID, commands will be registered to that specific server (instant). Without it, commands are registered globally (takes up to 1 hour to propagate).
Once the bot is running and invited to your server:
Use the slash command /summarize in any channel:
/summarize url:https://marmelab.com/blog/2025/12/08/supabase-edge-function-transaction-rls.html
The bot will:
- Fetch the article content
- Generate automatic tags
- Create a summary
- Explain why it's interesting
- Display everything in a formatted embed with interactive buttons
- Make sure you ran
npm run register - If using
GUILD_ID, commands appear instantly in that server only - Global commands take up to 1 hour to appear
- Try kicking and re-inviting the bot
- Check that
PUBLIC_KEYin.envmatches your Discord application - Ensure the interaction endpoint URL is correct
- Verify ngrok is running and URL hasn't changed
- Check that
npm run devis running - Verify ngrok tunnel is active
- Check server logs for errors
- Ensure
OPENAI_API_KEYis valid## API Costs
The bot makes 3 OpenAI API calls per summarization:
- Tag generation (~50 tokens)
- Summary generation (~300 tokens)
- Interest explanation (~200 tokens)
Estimated cost per summary: ~$0.001 - $0.002 (using GPT-3.5-turbo)
MIT