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.
An AI agent powered by Claude with web search, deployed on Val Town.
- Responds to
@mentionsin channels and threads, with full thread history as context - Acts as a Slack assistant in DMs (Chat tab), with greeting + suggested prompts
- Powered by Claude Sonnet 4.6 with Anthropic's built-in web search tool
- One-click Slack app setup — no manual scope or event configuration
- Easily extensible: swap models, add tools, change prompts
- Remix this val if you haven't already.
- Visit your val's HTTP endpoint (the
/route) to see the setup page, then click Create Slack App. The app's manifest — scopes, events, and webhook URL — is pre-filled, so just click Next → pick workspace → Create. - Install to Workspace in the Slack app's Install App tab.
- Paste 3 secrets into your val's
environment variables
(the slots are already created — just fill the values):
SLACK_BOT_TOKEN— Slack app → OAuth & Permissions → Bot User OAuth Token (xoxb-...)SLACK_SIGNING_SECRET— Slack app → Basic Information → Signing SecretANTHROPIC_API_KEY— from the Claude console
- (Optional) Set the bot's icon at Slack app → Basic Information → Display Information → App icon. The manifest can't carry an icon — it has to be uploaded manually. Square PNG, 512×512+.
- DM the bot — open the Slack app, click Messages, and chat. The conversation maintains thread context automatically.
@mentionin a channel — the bot replies in a thread on your message. Follow-ups in that thread also get full thread context.
⚠️ Invite the bot to the channel first (
/invite @AI Slackbot). Without channel membership, the bot receives the mention event but can't read thread history, and will only see your single mention as context.
ai-slackbot/
├── events.ts # HTTP entry point: setup page + Slack event router
├── prompt.md # System prompt for your agent
├── README.md
└── lib/
├── generate-response.ts # AI core (Claude + web search)
├── handle-app-mention.ts # @mentions in channels and threads
├── handle-message.ts # DMs in assistant (Chat tab) threads
├── handle-thread-started.ts # Greeting + suggested prompts on new assistant thread
└── slack-utils.ts # Slack client, request verification, thread fetching
Slack POSTs events to /events. The handler verifies the signature, looks up
the bot's user ID, and dispatches based on event type. Long-running work runs
fire-and-forget so the 3-second Slack ack window isn't blocked.
- Swap the model or model provider →
lib/generate-response.ts(uses the Vercel AI SDK, so any provider works) - Edit the system prompt →
prompt.md - Add tools (database queries, knowledge bases, custom APIs) → extend the
toolsobject inlib/generate-response.ts. See the AI SDK tools docs. - Change greeting or suggested prompts in DMs →
lib/handle-thread-started.ts - Change Slack scopes, events, or app metadata → edit the
manifestobject at the top ofevents.ts. Re-create the Slack app from the updated setup page.
This val uses pinned imports to avoid breaking changes:
@slack/web-api@7.14.1hono@4.12.0ai@6.0.92@ai-sdk/anthropic@3.0.45
Based on Vercel's Slackbot Agent Guide and Pete Millspaugh's pmillspaugh/duck, both adapted for Val Town.