Add a persistent email inbox to Convex with reactive queries for AI agents - threads, labels, and messages sync automatically to your database.
npm install @agentmail/convexAgentmail provides a stateful email inbox for AI agents built on Convex. It persists email threads, full message bodies, labels, and delivery status directly in your Convex database with reactive queries. The component handles webhook ingestion, durable sending with retry logic, and provides first-class thread management so you can build email-based AI agents without rebuilding inbox infrastructure.
AgentMail Convex component provides a stateful email inbox where every message persists with thread_id and labels in your Convex database. Subscribe to listInboundMessages({ threadId }) to watch threads update reactively as new emails arrive.
Use useQuery with the AgentMail component to subscribe to inbox state changes in real-time. New mail appears instantly when AgentMail's webhook fires, eliminating the need to poll external email APIs.
Call agentmail.sendMessage() from mutations to queue emails with automatic retries through workpool actions. Track delivery status reactively by subscribing to the returned OutboundId.
Mount the webhook handler in convex/http.ts using agentmail.handleWebhook(). Events are automatically deduplicated by event_id and processed through isolated workpools to prevent blocking.
The AgentMail component creates isolated tables (inboxes, inboundMessages, outboundMessages, events) in your Convex database. All email data including full message bodies, attachments metadata, and thread relationships are stored locally and queryable with standard Convex queries.
Yes, the AgentMail component enables reactive email queries using standard Convex useQuery hooks. Subscribe to listInboundMessages({ threadId }) to watch thread updates in real-time as new messages arrive through webhooks.
The AgentMail component provides durable email sending through Convex mutations that enqueue messages to workpool actions with bounded retries. Delivery status transitions (pending, sent, delivered, bounced) are tracked as reactive queries you can subscribe to.
Configure an onMessageReceived callback that fires as an internal mutation when emails arrive. The callback receives both the message and complete thread context, allowing your AI agent to process emails with full conversation history without additional API calls.