Email Digest Summarizer

Click to zoom
Email Digest Summarizer
Fetch unread Gmail emails, summarize each with AI, and post a curated digest to a Slack channel in one click.
Email Digest Summarizer is an automation that fetches unread emails from your Gmail inbox via IMAP, uses OpenAI to summarise each message, and delivers a clean digest report to a Slack channel.
What it does
- Email fetching: Retrieves unread Gmail messages via IMAP with
fetch-emails - AI summarisation: Passes each email through OpenAI (
gpt-4o-mini) for a concise summary viasummarize-content - Content processing:
process-contentorchestrates the fetch → summarise loop for all emails - Slack delivery: Formats all summaries into a rich Slack message and posts it to a channel via
send-digest - Full pipeline:
content-digestties everything together: process all emails then send the digest
Environment variables (.env / keyring on apps)
| Variable | Purpose |
|---|---|
HABITS_OPENAI_API_KEY | OpenAI API key for content summarisation |
HABITS_GMAIL_IMAP_HOST | IMAP host (e.g. imap.gmail.com) |
HABITS_GMAIL_IMAP_PORT | IMAP port (typically 993 for SSL) |
HABITS_GMAIL_IMAP_USER | Gmail address to read emails from |
HABITS_GMAIL_IMAP_APP_PASSWORD | Gmail App Password for the IMAP account |
HABITS_SLACK_BOT_TOKEN | Slack Bot User OAuth Token (xoxb-...) |
HABITS_SLACK_DIGEST_CHANNEL | Slack channel ID to post the digest to |
How to set up
- Copy
.env.exampleto.envand fill in your credentials. - For Gmail, enable 2-Step Verification and generate a 16-character App Password for
HABITS_GMAIL_IMAP_APP_PASSWORD. - Create a Slack app, add
chat:writeandchannels:readbot scopes, install it to your workspace, and copy thexoxb-token. - Invite the bot to your target channel and copy the Channel ID into
HABITS_SLACK_DIGEST_CHANNEL. - Run
content-digestfor a full email digest, or enable auto-fetch for continuous monitoring.
Tech stack
- habits framework for workflow orchestration
- OpenAI (
@ha-bits/bit-openai) for natural-language email summarisation - IMAP (
@ha-bits/bit-email) for Gmail inbox access - Slack (
@ha-bits/bit-slack) for digest delivery
Run Your .habit File
Run on Mobile
- [ ] Download the Cortex App from store or the downloads page
- [ ] Open the Cortex App on your device
- [ ] Tap "Open Habit" or "+" button
- [ ] Select your
.habitfile from your device storage - [ ] The habit will be loaded and ready to run
Run on Desktop
- [ ] Download the Cortex App for your platform from the downloads page
- [ ] Install and open the Cortex App
- [ ] Click "Open Habit" or drag & drop your
.habitfile - [ ] The habit will be loaded and ready to run
- [ ] Optional: Place a
.envfile in the same directory as your.habitfile to override environment variables
Run on Server
Run your .habit file as a server using the Cortex CLI:
bash
# Install and run in one command
npx @ha-bits/cortex --config ./your-app.habit- [ ] Make sure Node.js 20+ is installed
- [ ] Run the command above with your
.habitfile path - [ ] Server will start on the specified port (default: 3000)
- [ ] Access the app at
http://localhost:3000 - [ ] Optional: Place a
.envfile next to your.habitfile - it will automatically override any embedded environment variables
Run Serverless
For serverless or containerized deployments, we recommend using Docker:
bash
# Using Docker (recommended for serverless)
docker run -p 3000:3000 -v $(pwd)/your-app.habit:/app/habit.habit \
node:20-alpine npx @ha-bits/cortex --config /app/habit.habit --host 0.0.0.0Or create a Dockerfile:
dockerfile
FROM node:20-alpine
WORKDIR /app
COPY your-app.habit ./
COPY .env ./ # Optional: include environment variables
RUN npm install -g @ha-bits/cortex
EXPOSE 3000
CMD ["cortex", "--config", "./your-app.habit", "--host", "0.0.0.0"]- [ ] Create a Dockerfile or use the Docker run command above
- [ ] Deploy to your preferred cloud provider (AWS, GCP, Azure, etc.)
- [ ] Configure environment variables via your cloud provider's secrets management
- [ ] Set up health checks at
/habits/base/apiendpoint
Workflow Visualization
Requirements
- OPENAI_API_KEY (OpenAI API key)
- GMAIL_IMAP_HOST (IMAP host for Gmail)
- GMAIL_IMAP_PORT (IMAP port for Gmail)
- GMAIL_IMAP_USER (Gmail address to read emails from)
- GMAIL_IMAP_APP_PASSWORD (Gmail App Password for the IMAP account)
- SLACK_BOT_TOKEN (Slack Bot User OAuth Token)
- SLACK_DIGEST_CHANNEL (Slack channel ID to post the digest to)
Quick Start
Run using the Habits CLI wrapper, recommended if you develop local Habits
# First, download the example files
npx habits@latest cortex --config ./email-digest-summarizer/stack.yamlGet in touch
Want this habit running in your environment?
This habit is a starting point. Tell us about your stack and we'll help you get it working exactly the way your team needs.
