Public
Email → Claude API → email reply pipeline
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.

email-to-claude

Send an email → get a Claude response back as a reply.

How it works

  1. You email the val's assigned address
  2. The val forwards your email text to the Anthropic Messages API
  3. Claude's response is emailed back to you as a reply

Setup

1. Add your Anthropic API key

👉 Add ANTHROPIC_API_KEY here: https://www.val.town/x/jsomers/email-to-claude/environment-variables?key=ANTHROPIC_API_KEY

Get one at https://console.anthropic.com/settings/keys

👉 Add ALLOWED_SENDER here: https://www.val.town/x/jsomers/email-to-claude/environment-variables?key=ALLOWED_SENDER

Set this to your own email address so only you can trigger the val.

3. Add a system prompt (optional)

👉 Add CLAUDE_SYSTEM_PROMPT here: https://www.val.town/x/jsomers/email-to-claude/environment-variables?key=CLAUDE_SYSTEM_PROMPT

Copy your Claude.ai project's custom instructions here. Since the Anthropic API doesn't have direct access to Claude.ai projects, this is how you replicate the project's behavior.

4. Choose a model (optional)

👉 Add CLAUDE_MODEL here: https://www.val.town/x/jsomers/email-to-claude/environment-variables?key=CLAUDE_MODEL

Defaults to claude-sonnet-4-20250514. Other options: claude-opus-4-20250514, claude-3-5-haiku-20241022, etc.

Usage

Just send a plain-text email to the special email address. The email body becomes the prompt. You'll get a reply with Claude's response.

Notes

  • Each email is independent — there's no conversation history between messages (the API is stateless per call).
  • HTML-only emails may not parse well; plain text works best.
  • Max 30MB per incoming message (Val Town limit).