Use this pre-built prompt with your AI agent to build with the Resend Chat SDK adapter.
@resend/chat-sdk-adapter package is a Vercel Chat SDK adapter that turns email into a two-way communication channel via Resend. Receive inbound emails through webhooks, reply through the Resend API, and let the adapter handle threading automatically.
The adapter is open source and available on GitHub.
Prerequisites
To get started, you’ll need to:- Create an API key
- Verify your domain
- Set up webhooks for
email.receivedevents - Enable receiving on your domain
1. Install
2. Configure the adapter
Create a Resend adapter and pass it to the Chat SDK.Set
RESEND_API_KEY and RESEND_WEBHOOK_SECRET as environment variables. You can also pass apiKey and webhookSecret directly in the config — explicit values take precedence over env vars.Configuration options
| Parameter | Type | Required | Description |
|---|---|---|---|
fromAddress | string | Yes | Sender email address |
fromName | string | No | Display name for the From header |
apiKey | string | No | Resend API key. Falls back to RESEND_API_KEY env var |
webhookSecret | string | No | Webhook signing secret. Falls back to RESEND_WEBHOOK_SECRET env var |
3. Handle inbound emails
Register handlers for incoming emails.onNewMention fires when a new thread starts, and onSubscribedMessage fires for follow-up emails in threads you’ve subscribed to.
4. Forward webhooks
Point your Resend webhooks to your server’s/webhook endpoint. The adapter verifies the signature and parses the payload.
Request object. If you’re using Node.js http, convert IncomingMessage to a Request first — see the basic example for a full working server.
For webhook setup details, see Managing Webhooks and Verify Webhook Requests.
How threading works
The adapter resolves threads using standardMessage-ID, In-Reply-To, and References email headers. Reply chains are automatically grouped into Chat SDK threads — no extra configuration needed.
Features
Card Emails
Send rich HTML emails with structured card elements.
Attachments
Handle inbound email attachments.
Proactive Outreach
Start new email threads without waiting for inbound.