• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
project logo

petermillspaugh

duck

BYOA (Bring Your Own Agent) to Slack
Public
Like
duck
Home
Code
4
lib
5
README.md
H
events.ts
prompt.md
Environment variables
4
Branches
1
Pull requests
Remixes
History
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
…
Viewing readonly version of main branch: v189
View latest version
README.md

duck: Slack agent

BYOA (Bring Your Own Agent) to Slack.

Setup

It should only take 10-15 minutes to get your agent responding to DMs and `@mentions in Slack.

  1. Go to api.slack.com/apps to create a Slack app
  2. Click "Create New App" and choose "From scratch"
  3. Under OAuth & Permissions, add the following bot token scopes:
    • app_mentions:read
    • assistant:write
    • channels:history
    • chat:write
    • im:history
    • im:write
  4. Install the app to your workspace (button under OAuth Tokens subsection)
  5. Under App Home > Show Tabs > Chat Tab, check "Allow users to send Slash commands and messages from the chat tab"
  6. Remix this val if you haven't already
  7. Add your environment variables in your val sidebar:
    1. VAL_TOWN_API_TOKEN from Settings > API tokens
    2. SLACK_BOT_TOKEN in your Slack app: OAuth & Permissions > OAuth Tokens > Bot User OAuth Token
    3. SLACK_SIGNING_SECRET in your Slack app: from Basic Information > Signing Secret
    4. ANTHROPIC_API_KEY from the Anthropic console
  8. Copy your HTTP url in events.ts (note: you can add a custom subdomain), then in your Slack app paste it under Event Subscriptions > Request URL
  9. In your Slack app under Events Subscription > Enable Events > Subscribe to bot events, add app_mention, assistant_thread_started, and message.im

Architecture

duck/
├── events.ts         # HTTP entry point (Hono app, Slack event router)
├── prompt.md         # System prompt for your agent
├── README.md
└── lib/
    ├── generate-response.ts         # AI core (Claude + MCP + web search)
    ├── handle-app-mention.ts        # Handles @mentions in channels and threads
    ├── handle-message.ts            # Handles DMs in assistant (Slack app) threads
    ├── handle-thread-started.ts     # Greeting + suggested prompts on new assistant thread
    └── slack-utils.ts               # Slack client and utils

Models

This template uses Claude Sonnet 4.6 directly in lib/generate-response.ts, which requires setting an ANTHROPIC_API_KEY environment variable. Alternatively, you could use a gateway to switch between models easily, like the Vercel AI Gateway or the Kilo Gateway.

Tools

This agent comes with the following tools:

  1. Anthropic web search
  2. Val Town MCP server

You should of course edit and add your own tools! That's the whole point of BYOA :)

Version pinning

This val uses pinned imports (latest package version as of 2/19/26) to avoid breaking changes:

  1. @slack/web-api@7.14.1
  2. hono@4.12.0
  3. ai@6.0.92
  4. @ai-sdk/anthropic@3.0.45
  5. @ai-sdk/mcp@1.0.21

Why duck?

It's "duck" as in rubber duck debugging. But you can call your agent whatever you'd like!

Credits

This val is based on Vercel's Slackbot Agent Guide, adapted for Val Town.

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.