Learn AI
    ↑↓ navigate Enter open Esc close Open with ⌘K or /

    25 min

    Build · A Slack channel digest bot

    A bot that posts a daily summary to a Slack channel. Real API tokens, real scheduling. ~25 min.

    You'll build a real Slack bot that posts a daily channel summary. Different shape than the existing builds: this one uses two API tokens (Slack + an LLM), reads real channel data, and gets scheduled.

    0 of 9 steps
    1

    Create a Slack app + bot user

    Once-per-bot setup. Skip if you've done this before.

    1. Create New App → From scratch. Name it (e.g. "Daily Digest").
    2. Pick the workspace you want it in. Apps can be created in a personal workspace first; install in others later.
    3. Under OAuth & Permissions, add these Bot Token Scopes:
      • channels:history — read public channel messages
      • chat:write — post messages
    4. Click Install to Workspace. Approve.
    You should see

    You see a Bot User OAuth Token starting with xoxb-. Copy it.

    2

    Add the bot to a channel

    The bot can only read channels it's a member of. In your test channel, type /invite @Daily Digest (or whatever you named it).

    You should see

    Slack confirms: "added Daily Digest to #channel".

    3

    Get the channel ID

    In Slack, right-click the channel name → View channel details. The ID at the bottom looks like C0123ABC456.

    4

    Make a project folder + .env file

    Shell
    mkdir ~/slack-digest && cd ~/slack-digest
    cat > .env <<'EOF'
    SLACK_BOT_TOKEN=xoxb-...your-token...
    ANTHROPIC_API_KEY=sk-ant-...
    EOF
    echo ".env" > .gitignore
    You should see

    Folder exists. .env is gitignored (never commit it).

    5

    Open your coding CLI and paste the build prompt

    Run claude / codex / aider in the folder. Paste:

    Build prompt
    Write a Node.js script bot.js that:
    
    - Reads SLACK_BOT_TOKEN and ANTHROPIC_API_KEY from env (.env via dotenv).
    - Fetches the last 24h of messages from a channel ID passed as arg.
      - Use https://slack.com/api/conversations.history with limit=200, oldest=<24h ago>
      - Auth via Authorization: Bearer ${SLACK_BOT_TOKEN}
    - Calls Claude with the messages joined by newlines, system prompt:
        "You are a TL;DR bot. Read this Slack channel transcript and produce a 3-bullet summary suitable
         for posting back to the channel. Each bullet starts with an emoji. Keep it under 80 words."
    - Posts the summary to the same channel via chat.postMessage.
    
    Single file. dotenv + node:18 fetch. No frameworks. Print every Slack API response so I can see failures.
    
    Then add a package.json with a "start" script. Run with: node bot.js C123ABC456 (a channel id).
    6

    Approve the writes and the install

    The CLI will:

    • Write bot.js (~80 lines)
    • Write package.json with the @anthropic-ai/sdk + dotenv deps
    • Run npm install — allow it
    You should see

    Done in ~30 seconds. node bot.js C0123ABC456 runs without crashing.

    7

    Test it

    Run on your test channel:

    Shell
    node bot.js C0123ABC456
    You should see

    The bot posts a 3-bullet summary to the channel within a few seconds. If you see an error, paste it back to the CLI — it'll diagnose. Common gotchas: not_in_channel (re-invite the bot), missing_scope (check OAuth scopes).

    8

    Add --dry-run

    Iterate in the CLI:

    Iteration 1
    Add a --dry-run flag. When set, print the summary to stdout instead of posting it. Useful for testing before pointing it at a real channel.
    You should see

    node bot.js C0123ABC456 --dry-run prints to stdout, doesn't post.

    9

    Schedule it (pick one path)

    Ask the CLI for the three scheduling options:

    Iteration 2
    Show me three ways to schedule this for daily 9am runs:
    1. macOS launchd (plist)
    2. Linux cron (crontab line)
    3. A GitHub Actions workflow that runs on schedule and pipes the SLACK_BOT_TOKEN from a secret
    
    For each, show the exact file or command I'd run.

    Recommended: GitHub Actions if you want zero machines to manage; cron if you have a server already; launchd if you only need it while your Mac is on.

    You should see

    The bot posts a daily summary at 9am without you doing anything.

    What you just learned. Real bots are 80% glue code (API tokens, env vars, scheduling) and 20% AI. The hard part is the surface area — Slack's API, Anthropic's API, wherever you deploy. The LLM call itself is a one-liner. Apply this template to any SaaS-with-API (Linear, Notion, Discord, Telegram, Email) — same shape every time.