{"_note":"Machine-readable build plan from AgentMail. For the visual version open https://www.agentmail.to/build","kind":"blueprint","tldr":"One AgentMail inbox on your domain, webhook on arrival, agent labels and replies in thread, drafts anything sensitive.","title":"Shared company mailbox run by one agent","summary":"Keep hello@ on your own domain and put an agent behind it that triages, replies in thread, and leaves a draft whenever it is unsure.","stack":[{"name":"AgentMail","role":"The hello@ inbox, threading, labels, drafts, webhooks","why":"Receiving and replying in thread are first class"},{"name":"Claude or GPT","role":"Classification and reply drafting","why":"Handles messy free-form email well"},{"name":"Your API server","role":"Webhook handler and agent loop","why":"Signature verification plus idempotent processing"},{"name":"Postgres","role":"Thread state, processed message ids, audit log","why":"Stops double replies on webhook retries"},{"name":"Slack","role":"Human notification channel","why":"Urgent threads need eyes fast"}],"steps":["Verify your domain in AgentMail and publish the SPF, DKIM, DMARC and MX records.","Create one inbox with username hello and a client_id for safe retries.","Point your MX or forwarding so mail for hello@ lands in that inbox.","Register a message.received webhook, verify Svix signatures, dedupe on message id.","Classify each message, apply labels like sales, support, billing, needs-human.","Reply in thread for known categories, create a draft for everything else."],"agentmailSetup":["client.domains.create(\"yourcompany.com\"), publish the returned records, poll until verified.","client.inboxes.create(username=\"hello\", domain=\"yourcompany.com\", client_id=\"shared-hello-v1\").","client.webhooks.create(url=..., event_types=[\"message.received\"], inbox_ids=[inbox_id]).","Verify deliveries with the Svix library using the webhook signing secret and the raw body.","Read message.extracted_text so quoted history is not fed to the model.","Reply with client.inboxes.messages.reply, or client.inboxes.drafts.create(in_reply_to=message_id) for review.","Track state with labels: add replied, needs-human, resolved, remove unreplied.","Optional: inbox-level receive block list entries for known spam senders."],"ideas":[],"options":[],"resources":[{"label":"Shared company mailbox for one agent","url":"https://agentmail.to/use-case/ai-agent-that-reads-a-shared-inbox","kind":"use-case"},{"label":"Webhooks overview","url":"https://docs.agentmail.to/webhooks-overview","kind":"docs"},{"label":"Using custom domains","url":"https://docs.agentmail.to/custom-domains","kind":"docs"},{"label":"Drafts for human review","url":"https://docs.agentmail.to/drafts","kind":"docs"},{"label":"Idempotent inbound email for agents","url":"https://agentmail.to/blog/idempotent-inbound-email-for-agents","kind":"blog"}],"agentPrompt":"---\nproject: Shared company mailbox run by one agent\nbuilt_with: AgentMail\ndocs: https://docs.agentmail.to\nllms: https://docs.agentmail.to/llms.txt\n---\n\n# Goal\nRun a single shared company address, hello@yourcompany.com, behind one AI agent. The agent receives every inbound message through a webhook, classifies it into a small set of categories, answers routine questions in thread from a knowledge base, and creates a draft reply for anything sensitive or ambiguous so a human can review and send. Labels carry the state of each thread so nothing is answered twice and a person can filter for what still needs attention. The mailbox keeps full thread history, so the agent always replies with the conversation in context rather than treating each message as a standalone event.\n\n# Architecture\n- AgentMail inbox hello@yourcompany.com on a verified custom domain, one inbox for the whole company address.\n- Webhook subscribed to message.received, scoped to that inbox, signature verified with Svix and the raw request body.\n- Handler writes the message id to Postgres first and exits early if it is already present, so retries do not send a second reply.\n- Agent step reads extracted_text, classifies into sales, support, billing, vendor or other, and attaches labels to the thread.\n- Known categories: agent retrieves from the knowledge base and calls messages.reply so the answer stays in the same thread.\n- Unknown, sensitive or high value: agent calls drafts.create with in_reply_to, applies needs-human, and posts a Slack message with a link.\n- Reviewer edits and calls drafts.send; the handler swaps needs-human for replied.\n- Daily job lists threads labeled unreplied older than 24 hours and chases them in Slack.\n\n# Stack\n- AgentMail: The hello@ inbox, threading, labels, drafts, webhooks\n- Claude or GPT: Classification and reply drafting\n- Your API server: Webhook handler and agent loop\n- Postgres: Thread state, processed message ids, audit log\n- Slack: Human notification channel\n\n# AgentMail setup\n1. Install SDK: `pip install agentmail` / `npm i agentmail`\n2. client.domains.create(\"yourcompany.com\"), publish the returned records, poll until verified.\n3. client.inboxes.create(username=\"hello\", domain=\"yourcompany.com\", client_id=\"shared-hello-v1\").\n4. client.webhooks.create(url=..., event_types=[\"message.received\"], inbox_ids=[inbox_id]).\n5. Verify deliveries with the Svix library using the webhook signing secret and the raw body.\n6. Read message.extracted_text so quoted history is not fed to the model.\n7. Reply with client.inboxes.messages.reply, or client.inboxes.drafts.create(in_reply_to=message_id) for review.\n8. Track state with labels: add replied, needs-human, resolved, remove unreplied.\n9. Optional: inbox-level receive block list entries for known spam senders.\n\n# Build steps\n1. Verify your domain in AgentMail and publish the SPF, DKIM, DMARC and MX records.\n2. Create one inbox with username hello and a client_id for safe retries.\n3. Point your MX or forwarding so mail for hello@ lands in that inbox.\n4. Register a message.received webhook, verify Svix signatures, dedupe on message id.\n5. Classify each message, apply labels like sales, support, billing, needs-human.\n6. Reply in thread for known categories, create a draft for everything else.\n\n# Acceptance checks\n- A test email to hello@ produces a labeled thread and a reply or draft within 60 seconds.\n- Replaying the same webhook delivery twice results in exactly one outbound message.\n- A message the classifier scores as low confidence creates a draft and a Slack alert, and sends nothing.\n- Replies land in the original thread in Gmail and Outlook, not as new conversations.\n- Domain shows SPF, DKIM, DMARC and MX all verified before any production send.\n\n# Notes\n- Generated by agentmail.to/build. Verify API details against the docs before shipping.\n","suggestions":[{"label":"Add approval by email","prompt":"Change the design so reviewers approve drafts by replying to an email instead of using Slack"},{"label":"Keep support@ in Gmail","prompt":"We already run support@ in Google Workspace, how do I move just the mailbox behind it to AgentMail?"},{"label":"Split into several addresses","prompt":"Split this into sales@, support@ and billing@ with a routing agent in front"}],"note":null,"human":"https://www.agentmail.to/build","followUp":{"method":"POST","url":"https://www.agentmail.to/api/build-chat","headers":{"Accept":"application/json","Content-Type":"application/json"},"body":{"messages":[{"role":"user","content":"How would I build shared company mailbox for one agent with AgentMail?"},{"role":"assistant","content":"One AgentMail inbox on your domain, webhook on arrival, agent labels and replies in thread, drafts anything sensitive.\n[blueprint] Shared company mailbox run by one agent: Keep hello@ on your own domain and put an agent behind it that triages, replies in thread, and leaves a draft whenever it is unsure. (fit strong)\nNodes: senders=Inbound mail (source); inbox=hello@ inbox (agentmail); hook=Webhook (tool); agent=Triage agent (agent); kb=Knowledge base (tool); slack=Slack alert (destination); human=Reviewer (human)\nEdges: senders->inbox [inbound email]; inbox->hook [message.received]; hook->agent [event]; agent->kb [lookup]; agent->inbox [reply or draft]; agent->slack [urgent ping]; human->inbox [send draft]\nStack: AgentMail (The hello@ inbox, threading, labels, drafts, webhooks); Claude or GPT (Classification and reply drafting); Your API server (Webhook handler and agent loop); Postgres (Thread state, processed message ids, audit log); Slack (Human notification channel)\nSteps: 1. Verify your domain in AgentMail and publish the SPF, DKIM, DMARC and MX records. 2. Create one inbox with username hello and a client_id for safe retries. 3. Point your MX or forwarding so mail for hello@ lands in that inbox. 4. Register a message.received webhook, verify Svix signatures, dedupe on message id. 5. Classify each message, apply labels like sales, support, billing, needs-human. 6. Reply in thread for known categories, create a draft for everything else.\nAgentMail setup: client.domains.create(\"yourcompany.com\"), publish the returned records, poll until verified. client.inboxes.create(username=\"hello\", domain=\"yourcompany.com\", client_id=\"shared-hello-v1\"). client.webhooks.create(url=..., event_types=[\"message.received\"], inbox_ids=[inbox_id]). Verify deliveries with the Svix library using the webhook signing secret and the raw body. Read message.extracted_text so quoted history is not fed to the model. Reply with client.inboxes.messages.reply, or client.inboxes.drafts.create(in_reply_to=message_id) for review. Track state with labels: add replied, needs-human, resolved, remove unreplied. Optional: inbox-level receive block list entries for known spam senders.\nTemplates: support-agent, approval-inbox, docs-assistant"},{"role":"user","content":"<your follow-up, for example: swap Slack for Teams, or: build idea 2>"}]},"note":"Send the whole history each time, up to 10 user messages. No state is kept between calls."}}