{"_note":"Machine-readable build plan from AgentMail. For the visual version open https://www.agentmail.to/build","kind":"blueprint","tldr":"Give each client a dedicated inbox in its own pod, parse receipts and bills on arrival, sync to the ledger, hold risky replies as drafts.","title":"Accounting intake and bookkeeping agent","summary":"One inbox per client turns receipt forwarding and document chasing into an automated pipeline with a human sign-off step.","stack":[{"name":"AgentMail","role":"Inbox per client, attachments, drafts, webhooks","why":"Receiving and replying in thread is the whole job"},{"name":"Claude or GPT","role":"Classification and field extraction","why":"Reads messy vendor emails and PDFs"},{"name":"QuickBooks or Xero API","role":"Ledger of record","why":"Where the bookkeeping actually lands"},{"name":"Postgres or Supabase","role":"Document index and chase state","why":"Tracks what is missing per client per month"},{"name":"Cron worker","role":"Month-end chaser job","why":"Drives scheduled follow-ups on open items"}],"steps":["Create a pod per client, then an inbox in that pod.","Register a message.received webhook scoped to those pods.","On arrival, read extracted_text and pull attachment text for PDFs.","Have the model classify: receipt, bill, statement, question, other.","Write clean records to Postgres and push entries to the ledger.","Reply confirming, or ask for the missing field in thread."],"agentmailSetup":["Add a custom domain per client or a shared firm domain, then verify DNS.","client.pods.create(client_id=\"tenant-<your-client-id>\") for idempotent tenant mapping.","client.pods.inboxes.create(pod_id, username=\"books\", display_name=\"<Client> Bookkeeping\").","Create a webhook on message.received scoped with pod_ids so events route per client.","Verify Svix signatures on the endpoint and dedupe on svix-id.","Use inboxes.messages.get_attachment for PDFs, and extracted_text for reply bodies.","Create a receive allow list per inbox so only the client's domains can send in.","For tax-sensitive replies, use inboxes.drafts.create and send only after approval."],"ideas":[],"options":[],"resources":[{"label":"AI agents for accounting","url":"https://agentmail.to/use-case/ai-agents-for-accounting","kind":"use-case"},{"label":"Pods for multi-tenant isolation","url":"https://docs.agentmail.to/documentation/core-concepts/pods","kind":"docs"},{"label":"Attachments","url":"https://docs.agentmail.to/attachments","kind":"docs"},{"label":"Webhooks overview","url":"https://docs.agentmail.to/webhooks-overview","kind":"docs"},{"label":"Drafts for human review","url":"https://docs.agentmail.to/drafts","kind":"docs"}],"agentPrompt":"---\nproject: Accounting intake and bookkeeping agent\nbuilt_with: AgentMail\ndocs: https://docs.agentmail.to\nllms: https://docs.agentmail.to/llms.txt\n---\n\n# Goal\nBuild an accounting agent that gives every client a dedicated email address for forwarding receipts, bills and statements. When mail arrives, the agent classifies it, extracts vendor, amount, date, currency and tax fields from the body and attachments, files the original document, creates the matching entry in QuickBooks or Xero, and replies in thread to confirm or to ask for whatever is missing. A scheduled job chases outstanding month-end documents per client. Anything tax-sensitive or above a value threshold becomes a draft that a human accountant approves before it is sent or posted.\n\n# Architecture\n- AgentMail pod per client, with one or more inboxes inside it, so no client's mail or threads are visible to another tenant.\n- Custom domain per client (or a firm domain with subdomains) so sending reputation is scoped deliberately.\n- message.received webhook scoped by pod_ids, pointing at a single handler that resolves pod to tenant via client_id.\n- Handler: verify Svix signature, dedupe on svix-id, enqueue the message id for processing.\n- Worker: fetch the message, read extracted_text, download attachments, run OCR or text extraction, call the LLM for structured extraction.\n- Writer: upsert a document row in Postgres, then create the bill or expense in QuickBooks or Xero, storing the external id.\n- Responder: if confident and below threshold, reply in thread confirming; if fields are missing, reply asking for them; if tax-sensitive, create a draft and notify the accountant.\n- Chaser: nightly cron reads open month-end checklists per client and sends or follows up in the existing thread.\n\n# Stack\n- AgentMail: Inbox per client, attachments, drafts, webhooks\n- Claude or GPT: Classification and field extraction\n- QuickBooks or Xero API: Ledger of record\n- Postgres or Supabase: Document index and chase state\n- Cron worker: Month-end chaser job\n\n# AgentMail setup\n1. Install SDK: `pip install agentmail` / `npm i agentmail`\n2. Add a custom domain per client or a shared firm domain, then verify DNS.\n3. client.pods.create(client_id=\"tenant-<your-client-id>\") for idempotent tenant mapping.\n4. client.pods.inboxes.create(pod_id, username=\"books\", display_name=\"<Client> Bookkeeping\").\n5. Create a webhook on message.received scoped with pod_ids so events route per client.\n6. Verify Svix signatures on the endpoint and dedupe on svix-id.\n7. Use inboxes.messages.get_attachment for PDFs, and extracted_text for reply bodies.\n8. Create a receive allow list per inbox so only the client's domains can send in.\n9. For tax-sensitive replies, use inboxes.drafts.create and send only after approval.\n\n# Build steps\n1. Create a pod per client, then an inbox in that pod.\n2. Register a message.received webhook scoped to those pods.\n3. On arrival, read extracted_text and pull attachment text for PDFs.\n4. Have the model classify: receipt, bill, statement, question, other.\n5. Write clean records to Postgres and push entries to the ledger.\n6. Reply confirming, or ask for the missing field in thread.\n\n# Acceptance checks\n- Forwarding a PDF invoice to a client inbox creates a ledger entry with correct vendor, amount and date within one minute.\n- A second delivery of the same webhook event creates no duplicate document or ledger entry.\n- A receipt missing an amount triggers a reply in the same thread asking for it, and the client's answer resolves the record.\n- An invoice over the approval threshold produces a draft, not a sent message, until an accountant sends it.\n- Listing threads scoped to pod A never returns any thread belonging to pod B.\n\n# Notes\n- Generated by agentmail.to/build. Verify API details against the docs before shipping.\n","suggestions":[{"label":"Add month-end chaser","prompt":"Expand this into a month-end document chaser that follows up with each client on a schedule until the file is complete"},{"label":"Client question desk","prompt":"Build a separate inbox where clients email tax questions and the agent drafts answers from our firm notes"},{"label":"Scale to 40 clients","prompt":"How do I run this across 40 clients with domains and pods without reputation bleeding between them?"}],"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 an AI agent for accounting with AgentMail?"},{"role":"assistant","content":"Give each client a dedicated inbox in its own pod, parse receipts and bills on arrival, sync to the ledger, hold risky replies as drafts.\n[blueprint] Accounting intake and bookkeeping agent: One inbox per client turns receipt forwarding and document chasing into an automated pipeline with a human sign-off step. (fit strong)\nNodes: clients=Clients (source); inbox=Client inboxes (agentmail); agent=Bookkeeping agent (agent); ledger=QuickBooks or Xero (tool); db=Document store (destination); accountant=Accountant (human)\nEdges: clients->inbox [forwarded docs]; inbox->agent [webhook]; agent->ledger [create entry]; agent->db [file document]; agent->accountant [draft review]; accountant->inbox [approve, send]; inbox->clients [confirm or chase]\nStack: AgentMail (Inbox per client, attachments, drafts, webhooks); Claude or GPT (Classification and field extraction); QuickBooks or Xero API (Ledger of record); Postgres or Supabase (Document index and chase state); Cron worker (Month-end chaser job)\nSteps: 1. Create a pod per client, then an inbox in that pod. 2. Register a message.received webhook scoped to those pods. 3. On arrival, read extracted_text and pull attachment text for PDFs. 4. Have the model classify: receipt, bill, statement, question, other. 5. Write clean records to Postgres and push entries to the ledger. 6. Reply confirming, or ask for the missing field in thread.\nAgentMail setup: Add a custom domain per client or a shared firm domain, then verify DNS. client.pods.create(client_id=\"tenant-<your-client-id>\") for idempotent tenant mapping. client.pods.inboxes.create(pod_id, username=\"books\", display_name=\"<Client> Bookkeeping\"). Create a webhook on message.received scoped with pod_ids so events route per client. Verify Svix signatures on the endpoint and dedupe on svix-id. Use inboxes.messages.get_attachment for PDFs, and extracted_text for reply bodies. Create a receive allow list per inbox so only the client's domains can send in. For tax-sensitive replies, use inboxes.drafts.create and send only after approval.\nTemplates: invoice-processor, approval-inbox"},{"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."}}