AI‑Powered Slack Bot – ThreadDigest
This project involved building a serverless Slack bot, ThreadDigest, that uses OpenAI’s GPT models to produce concise summaries of conversations. The bot responds to slash commands and @mentions, fetches recent messages and returns summaries in near real time. The architecture leverages AWS Lambda to run on demand without persistent infrastructure, and integrates Slack’s Events API and Slash Commands using Lambda function URLs for simplicity. Key contributions Slack bot that responds to /summary commands and @mentions, summarizing messages from channels and threads. Event‑driven architecture with AWS Lambda (Python 3.11) and no persistent infrastructure. Integration with Slack Events API and Slash Commands via Lambda Function URLs. Secure credential management using AWS Secrets Manager. Robust signature verification, message parsing, retry logic and error handling. Support for dynamic user and channel name resolution. App Home interface built using Slack Block Kit for onboarding and quick help. Highlights Natural‑language summaries in Slack with near real‑time performance. Clean, minimal deployment with no external dependencies. Hands‑on experience with the Slack platform, OpenAI API and serverless operations. How It Works A user sends a command (@mention or /summary) to the bot Slack sends an event to AWS Lambda, which triggers a Lambda function Lambda verifies the request signature and processes the Slack event The bot fetches relevant conversation history using the Slack API It sends messages to the OpenAI API for summarization The generated summary is posted back to Slack Implementation Slack part Go to https://api.slack.com/apps Create a new app (from scratch) Enable the following: App Home: Enable Home Tab Event Subscriptions: Enable and provide AWS Lambda function URL endpoint Bot Token Scopes: app_mentions:read # Allow the bot to read messages where it's mentioned channels:history # Read message history from public channels channels:read # List public channels in the workspace chat:write # Post messages as the bot commands # Enable use of slash commands (e.g., /summary) groups:history # Read message history from private groups groups:read # List private groups the bot is a member of im:history # Read message history from direct messages im:write # Send direct messages as the bot users:read # Read basic user info (for name resolution in summaries) Events to Subscribe: app_home_opened # Triggered when a user opens the App Home tab app_mention # Triggered when the bot is mentioned in a channel message.channels # Triggered for new messages in public channels message.im # Triggered for new messages in direct messages (IMs) Install the app to your workspace and retrieve the OAuth token (starts with “xoxb-…”) and Slack signing secret OpenAI Part Generate OpenAI API token (starting with “sk-…”) AWS Part Navigate to AWS Secrets Manager and create a secret { "slack_bot_token": "xoxb-...", "openai_api_key": "sk-...", "slack_signing_secret": "..." } Create IAM role for Lambda function with permissions secretsmanager:GetSecretValue lambda:InvokeFunction Attach these inline policies to the role: ...