[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M781FJZVS1ZJ49G4Z57FMXMP":3,"skill-same:01M781FJZVS1ZJ49G4Z57FMXMP":50},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":32,"ownerHtmlUrl":33,"ownerBlogUrl":6,"ownerDescription":34,"updatedAt":35,"install":36,"resources":49},"01M781FJZVS1ZJ49G4Z57FMXMP","agent-email-patterns",null,"Architecture patterns and best practices for giving AI agents email capabilities. Use when designing how agents send, receive, and manage email conversations, building two-way communication loops, implementing human-in-the-loop approval with drafts, choosing between WebSockets and webhooks, setting up multi-agent email topologies, handling OTP and verification flows, or securing agent email against prompt injection.","Lord1Egypt\u002Fawesome-skill-forge","Lord1Egypt","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F99746359?v=4","01M7592YDNT0XK9WJ0T2MQVPDN","Mohamed Mounir Ali AL Keshita","01M75GRFNHC8VZNWEB8DKDE433",3,"MIT","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fskills_sh\u002Fs\u002Fskills-sh_agentmail-to_agentmail-skills_agent-email-patterns\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: agent-email-patterns\ndescription: Architecture patterns and best practices for giving AI agents email capabilities. Use when designing how agents send, receive, and manage email conversations, building two-way communication loops, implementing human-in-the-loop approval with drafts, choosing between WebSockets and webhooks, setting up multi-agent email topologies, handling OTP and verification flows, or securing agent email against prompt injection.\nlicense: MIT\nmetadata:\n  author: agentmail-to\n  version: \"1.0\"\n---\n\n# Agent Email Patterns\n\nOpinionated patterns for building AI agents that communicate over email. This skill covers architecture decisions, not SDK specifics. For AgentMail SDK usage, use the `agentmail` skill.\n\n## Pattern 1: one inbox per agent\n\nEvery agent gets its own email address. Never share inboxes between agents.\n\n```python\nfrom agentmail import AgentMail\nfrom agentmail.inboxes.types import CreateInboxRequest\n\nclient = AgentMail()\n\nsupport_inbox = client.inboxes.create(\n    request=CreateInboxRequest(\n        username=\"support-agent\",\n        display_name=\"Acme Support\",\n        client_id=\"support-v1\",  # idempotent\n    ),\n)\n# support-agent@agentmail.to is now live\n```\n\nWhy:\n- **Identity**: recipients see a clear sender\n- **Isolation**: agents cannot access each other's email\n- **Auditability**: every message is traceable to one agent\n- **Security**: compromising one agent does not expose others\n\nAnti-pattern: one shared inbox with multiple agents reading from it. This creates race conditions and makes debugging impossible.\n\n## Pattern 2: two-way conversation loops\n\nThe core agent email pattern: agent sends, human replies, agent reads the reply and responds.\n\n```\nAgent sends initial email\n  -> Human replies\n    -> Agent reads reply (use extracted_text to strip quoted history)\n      -> Agent decides next action and responds\n        -> Loop continues until resolved\n```\n\nImplementation:\n\n```python\n# 1. Agent sends the opening message\nclient.inboxes.messages.send(\n    inbox_id,\n    to=\"user@example.com\",\n    subject=\"Your support ticket #1234\",\n    text=\"We received your request. Can you clarify the issue?\",\n)\n\n# 2. Later: agent reads the reply.\n# messages.list() returns MessageItem objects (metadata only — NO body).\n# Fetch the full Message with .get() to access .text \u002F .extracted_text.\nresponse = client.inboxes.messages.list(inbox_id, limit=5)\nfor item in response.messages:\n    msg = client.inboxes.messages.get(\n        inbox_id=item.inbox_id,\n        message_id=item.message_id,\n    )\n    # extracted_text strips quoted history and signatures\n    new_content = msg.extracted_text or msg.text\n    # Feed new_content to your LLM for next response\n```\n\nKey rules:\n- Always use `extracted_text` \u002F `extracted_html` for inbound replies to avoid processing the entire quoted chain\n- Track conversation state in your database, not in the email body\n- To keep messages grouped in the same thread, call `client.inboxes.messages.reply(inbox_id, message_id, ...)` with the parent `message_id` — AgentMail routes the reply into the existing thread automatically. There is no `thread_id` parameter on the reply call.\n\n## Pattern 3: human-in-the-loop drafts\n\nFor high-stakes emails, let the agent draft and a human approve before sending.\n\n```python\n# Agent drafts\ndraft = client.inboxes.drafts.create(\n    inbox_id,\n    to=\"important-client@example.com\",\n    subject=\"Contract proposal\",\n    text=agent_generated_text,\n)\n# Human reviews in console or via API, then:\nclient.inboxes.drafts.send(inbox_id, draft.draft_id)\n```\n\nUse drafts when:\n- Email has legal or financial implications\n- Recipient is a VIP or external stakeholder\n- Agent is new and untrusted for this workflow\n\nSend directly when:\n- Routine notification (receipts, confirmations)\n- Agent has proven reliability\n- Speed matters (OTP forwarding, automated alerts)\n\n## Pattern 4: event-driven architecture\n\nNever poll for new emails. Use WebSockets or webhooks.\n\n**WebSockets** (best for agents, no public URL needed):\n\n```python\nfrom agentmail import AgentMail, Subscribe, MessageReceivedEvent\n\nclient = AgentMail()\nwith client.websockets.connect() as socket:\n    socket.send_subscribe(Subscribe(inbox_ids=[inbox_id]))\n    for event in socket:\n        if isinstance(event, MessageReceivedEvent):\n            process_email(event.message)\n```\n\n**Webhooks** (for servers with public endpoints):\n\n```python\nwebhook = client.webhooks.create(\n    url=\"https:\u002F\u002Fyour-server.com\u002Fagent\u002Femail\",\n    event_types=[\"message.received\"],\n)\n```\n\nDecision guide:\n\n| Factor | WebSockets | Webhooks |\n|---|---|---|\n| Public URL needed | No | Yes |\n| Best for | Agents, bots, local dev | Servers, serverless |\n| Latency | Lowest (persistent) | HTTP round-trip |\n| Reconnection | You handle it | AgentMail retries |\n\n## Pattern 5: multi-agent topologies\n\nFor systems with multiple agents, assign clear roles:\n\n```\nsupport@agentmail.to     -> customer support\nsales@agentmail.to       -> sales inquiries\nbilling@agentmail.to     -> invoices and payments\nrouter@agentmail.to      -> intake, routes to correct agent\n```\n\nAgents can email each other for internal coordination:\n\n```python\n# Support agent escalates to sales\nclient.inboxes.messages.send(\n    support_inbox_id,\n    to=sales_inbox.email,\n    subject=\"Lead handoff: Acme Corp\",\n    text=\"Customer wants enterprise pricing. Full thread below.\",\n)\n```\n\nUse allow lists (`references\u002Fsecurity.md`) to restrict which external senders can reach each agent. For hub-and-spoke, peer-to-peer, and hierarchical escalation patterns, see `references\u002Fmulti-agent-topologies.md`.\n\n## Pattern 6: OTP and verification flows\n\nAgents that sign up for services need to receive and extract verification codes.\n\n```python\nimport re\n\ninbox = client.inboxes.create()\n# Use inbox.email to sign up for a service\n\n# Listen for OTP via WebSocket\nwith client.websockets.connect() as socket:\n    socket.send_subscribe(Subscribe(inbox_ids=[inbox.inbox_id]))\n    for event in socket:\n        if isinstance(event, MessageReceivedEvent):\n            text = event.message.text or \"\"\n            match = re.search(r\"\\b(\\d{4,8})\\b\", text)\n            if match:\n                otp = match.group(1)\n                break\n```\n\nBest practices:\n- Create a fresh inbox per sign-up flow for isolation\n- Set a timeout (do not wait indefinitely for OTP)\n- Delete the inbox after the flow completes if it is single-use\n\n## Pattern 7: labels for workflow state\n\nUse labels to track message processing state within an inbox:\n\n```python\n# When agent processes a message\nclient.inboxes.messages.update(\n    inbox_id, message_id,\n    add_labels=[\"processed\", \"needs-followup\"],\n    remove_labels=[\"unread\"],\n)\n\n# Query by label\nunprocessed = client.inboxes.messages.list(inbox_id, labels=[\"unread\"])\n```\n\nCommon label schemes:\n- `unread` \u002F `processed` \u002F `archived`\n- `needs-reply` \u002F `replied` \u002F `escalated`\n- `billing` \u002F `support` \u002F `sales` (category routing)\n\n## Security essentials\n\nSee `references\u002Fsecurity.md` for full coverage. Critical rules:\n\n1. **Sanitize inbound email before passing to LLM** -- prompt injection via email is a real attack vector. Never pass raw email content directly as a system prompt.\n2. **Use allow lists** on production agent inboxes to restrict senders.\n3. **Verify webhook signatures** to prevent spoofed events.\n4. **Never put API keys or secrets in email bodies or subjects.**\n5. **Separate agent credentials from human credentials** -- each agent gets its own API key.\n\n## Reference files\n\n- `references\u002Fmulti-agent-topologies.md` -- hub-and-spoke, peer-to-peer, and hierarchical agent email architectures\n- `references\u002Fsecurity.md` -- prompt injection defense, sender validation, credential isolation\n","# Agent Email Patterns\n\nOpinionated patterns for building AI agents that communicate over email. This skill covers architecture decisions, not SDK specifics. For AgentMail SDK usage, use the `agentmail` skill.\n\n## Pattern 1: one inbox per agent\n\nEvery agent gets its own email address. Never share inboxes between agents.\n\n```python\nfrom agentmail import AgentMail\nfrom agentmail.inboxes.types import CreateInboxRequest\n\nclient = AgentMail()\n\nsupport_inbox = client.inboxes.create(\n    request=CreateInboxRequest(\n        username=\"support-agent\",\n        display_name=\"Acme Support\",\n        client_id=\"support-v1\",  # idempotent\n    ),\n)\n# support-agent@agentmail.to is now live\n```\n\nWhy:\n- **Identity**: recipients see a clear sender\n- **Isolation**: agents cannot access each other's email\n- **Auditability**: every message is traceable to one agent\n- **Security**: compromising one agent does not expose others\n\nAnti-pattern: one shared inbox with multiple agents reading from it. This creates race conditions and makes debugging impossible.\n\n## Pattern 2: two-way conversation loops\n\nThe core agent email pattern: agent sends, human replies, agent reads the reply and responds.\n\n```\nAgent sends initial email\n  -> Human replies\n    -> Agent reads reply (use extracted_text to strip quoted history)\n      -> Agent decides next action and responds\n        -> Loop continues until resolved\n```\n\nImplementation:\n\n```python\n# 1. Agent sends the opening message\nclient.inboxes.messages.send(\n    inbox_id,\n    to=\"user@example.com\",\n    subject=\"Your support ticket #1234\",\n    text=\"We received your request. Can you clarify the issue?\",\n)\n\n# 2. Later: agent reads the reply.\n# messages.list() returns MessageItem objects (metadata only — NO body).\n# Fetch the full Message with .get() to access .text \u002F .extracted_text.\nresponse = client.inboxes.messages.list(inbox_id, limit=5)\nfor item in response.messages:\n    msg = client.inboxes.messages.get(\n        inbox_id=item.inbox_id,\n        message_id=item.message_id,\n    )\n    # extracted_text strips quoted history and signatures\n    new_content = msg.extracted_text or msg.text\n    # Feed new_content to your LLM for next response\n```\n\nKey rules:\n- Always use `extracted_text` \u002F `extracted_html` for inbound replies to avoid processing the entire quoted chain\n- Track conversation state in your database, not in the email body\n- To keep messages grouped in the same thread, call `client.inboxes.messages.reply(inbox_id, message_id, ...)` with the parent `message_id` — AgentMail routes the reply into the existing thread automatically. There is no `thread_id` parameter on the reply call.\n\n## Pattern 3: human-in-the-loop drafts\n\nFor high-stakes emails, let the agent draft and a human approve before sending.\n\n```python\n# Agent drafts\ndraft = client.inboxes.drafts.create(\n    inbox_id,\n    to=\"important-client@example.com\",\n    subject=\"Contract proposal\",\n    text=agent_generated_text,\n)\n# Human reviews in console or via API, then:\nclient.inboxes.drafts.send(inbox_id, draft.draft_id)\n```\n\nUse drafts when:\n- Email has legal or financial implications\n- Recipient is a VIP or external stakeholder\n- Agent is new and untrusted for this workflow\n\nSend directly when:\n- Routine notification (receipts, confirmations)\n- Agent has proven reliability\n- Speed matters (OTP forwarding, automated alerts)\n\n## Pattern 4: event-driven architecture\n\nNever poll for new emails. Use WebSockets or webhooks.\n\n**WebSockets** (best for agents, no public URL needed):\n\n```python\nfrom agentmail import AgentMail, Subscribe, MessageReceivedEvent\n\nclient = AgentMail()\nwith client.websockets.connect() as socket:\n    socket.send_subscribe(Subscribe(inbox_ids=[inbox_id]))\n    for event in socket:\n        if isinstance(event, MessageReceivedEvent):\n            process_email(event.message)\n```\n\n**Webhooks** (for servers with public endpoints):\n\n```python\nwebhook = client.webhooks.create(\n    url=\"https:\u002F\u002Fyour-server.com\u002Fagent\u002Femail\",\n    event_types=[\"message.received\"],\n)\n```\n\nDecision guide:\n\n| Factor | WebSockets | Webhooks |\n|---|---|---|\n| Public URL needed | No | Yes |\n| Best for | Agents, bots, local dev | Servers, serverless |\n| Latency | Lowest (persistent) | HTTP round-trip |\n| Reconnection | You handle it | AgentMail retries |\n\n## Pattern 5: multi-agent topologies\n\nFor systems with multiple agents, assign clear roles:\n\n```\nsupport@agentmail.to     -> customer support\nsales@agentmail.to       -> sales inquiries\nbilling@agentmail.to     -> invoices and payments\nrouter@agentmail.to      -> intake, routes to correct agent\n```\n\nAgents can email each other for internal coordination:\n\n```python\n# Support agent escalates to sales\nclient.inboxes.messages.send(\n    support_inbox_id,\n    to=sales_inbox.email,\n    subject=\"Lead handoff: Acme Corp\",\n    text=\"Customer wants enterprise pricing. Full thread below.\",\n)\n```\n\nUse allow lists (`references\u002Fsecurity.md`) to restrict which external senders can reach each agent. For hub-and-spoke, peer-to-peer, and hierarchical escalation patterns, see `references\u002Fmulti-agent-topologies.md`.\n\n## Pattern 6: OTP and verification flows\n\nAgents that sign up for services need to receive and extract verification codes.\n\n```python\nimport re\n\ninbox = client.inboxes.create()\n# Use inbox.email to sign up for a service\n\n# Listen for OTP via WebSocket\nwith client.websockets.connect() as socket:\n    socket.send_subscribe(Subscribe(inbox_ids=[inbox.inbox_id]))\n    for event in socket:\n        if isinstance(event, MessageReceivedEvent):\n            text = event.message.text or \"\"\n            match = re.search(r\"\\b(\\d{4,8})\\b\", text)\n            if match:\n                otp = match.group(1)\n                break\n```\n\nBest practices:\n- Create a fresh inbox per sign-up flow for isolation\n- Set a timeout (do not wait indefinitely for OTP)\n- Delete the inbox after the flow completes if it is single-use\n\n## Pattern 7: labels for workflow state\n\nUse labels to track message processing state within an inbox:\n\n```python\n# When agent processes a message\nclient.inboxes.messages.update(\n    inbox_id, message_id,\n    add_labels=[\"processed\", \"needs-followup\"],\n    remove_labels=[\"unread\"],\n)\n\n# Query by label\nunprocessed = client.inboxes.messages.list(inbox_id, labels=[\"unread\"])\n```\n\nCommon label schemes:\n- `unread` \u002F `processed` \u002F `archived`\n- `needs-reply` \u002F `replied` \u002F `escalated`\n- `billing` \u002F `support` \u002F `sales` (category routing)\n\n## Security essentials\n\nSee `references\u002Fsecurity.md` for full coverage. Critical rules:\n\n1. **Sanitize inbound email before passing to LLM** -- prompt injection via email is a real attack vector. Never pass raw email content directly as a system prompt.\n2. **Use allow lists** on production agent inboxes to restrict senders.\n3. **Verify webhook signatures** to prevent spoofed events.\n4. **Never put API keys or secrets in email bodies or subjects.**\n5. **Separate agent credentials from human credentials** -- each agent gets its own API key.\n\n## Reference files\n\n- `references\u002Fmulti-agent-topologies.md` -- hub-and-spoke, peer-to-peer, and hierarchical agent email architectures\n- `references\u002Fsecurity.md` -- prompt injection defense, sender validation, credential isolation\n",{"name":5,"license":15,"metadata":24,"description":7},{"author":25,"version":26},"agentmail-to","1.0","master","4aa004da461d820f4ea5499e58eb8d196cf99016","community\u002Fskills_sh\u002Fs\u002Fskills-sh_agentmail-to_agentmail-skills_agent-email-patterns",0,"https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge","https:\u002F\u002Fskill-explorer-rho.vercel.app","https:\u002F\u002Fgithub.com\u002FLord1Egypt","Unbreakable. Unstoppable. Unmatched⚡.\r\n Speaker of machine tongues 🤖  | World-builder of decentralized dreams 🌐 | Defender of the digital realm🛡️.","2026-06-10 08:21:01",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add Lord1Egypt\u002Fawesome-skill-forge --skill agent-email-patterns",{"tool":42,"command":43},"bunx","bunx skills add Lord1Egypt\u002Fawesome-skill-forge --skill agent-email-patterns",{"tool":45,"command":46},"pnpm","pnpm dlx skills add Lord1Egypt\u002Fawesome-skill-forge --skill agent-email-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fskills_sh\u002Fs\u002Fskills-sh_agentmail-to_agentmail-skills_agent-email-patterns\u002FSKILL.md",true,[],[51,58,65,72,79,86],{"skillNo":52,"name":53,"nameZh":6,"description":54,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":19},"01M785WKJB99G3STR1NF9NRTJW","youtube-content","YouTube transcripts to summaries, threads, blogs.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fyoutube-content\u002FSKILL.md",[],[],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M785WEFHB0G2S9YA6EPR3H0E","xurl","X\u002FTwitter via xurl CLI: post, search, DM, media, v2 API.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fxurl\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M785W98EDN4EFJXJPMQEHCRC","touchdesigner-mcp","Control a running TouchDesigner instance via twozero MCP — create operators, set parameters, wire connections, execute Python, build real-time visuals. 36 native tools.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftouchdesigner-mcp\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":19},"01M785W5S9FP3QBH2V191E025P","test-driven-development","TDD: enforce RED-GREEN-REFACTOR, tests before code.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftest-driven-development\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M785W2AS08NSSH9YATCV6FJB","teams-meeting-pipeline","Operate the Teams meeting summary pipeline via Hermes CLI — summarize meetings, inspect pipeline status, replay jobs, manage Microsoft Graph subscriptions.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fteams-meeting-pipeline\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M785VXKW4T34BTP1SCHW1R7F","systematic-debugging","4-phase root cause debugging: understand bugs before fixing.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fsystematic-debugging\u002FSKILL.md",[],[]]