n8n Email Integration for AI Agents | OpenMail
Email for n8n Agents
Give every n8n workflow its own inbox. Trigger workflows from inbound email, send replies in thread, and handle full conversations — no SMTP config, no deliverability headaches.
How OpenMail works with n8n
01
Create an inbox with an HTTP Request node
Add an HTTP Request node to your n8n workflow. One call to the OpenMail API provisions a live inbox on your domain and returns the address immediately. This call uses your account key, which stays in the provisioning workflow.
HTTP Request node
Method: POST
URL: https://api.openmail.sh/v1/inboxes
Headers:
Authorization: Bearer {{ $env.OPENMAIL_ACCOUNT_KEY }}
Content-Type: application/json
Body:
{ "mailboxName": "{{ $json.agentName }}" }
Response:
{ "id": "inb_8f3a1b2c", "address": "agent@yourdomain.com" }
02
Mint a key scoped to that inbox
Add a second HTTP Request node to mint a key that reaches only the inbox you just created. It can read and send from that one inbox and nothing else, so a workflow handling untrusted mail can't touch another workflow's inbox. The token comes back once — write it straight to the workflow's credentials.
HTTP Request node
Method: POST
URL: https://api.openmail.sh/v1/inboxes/{{ $json.id }}/api-keys
Headers:
Authorization: Bearer {{ $env.OPENMAIL_ACCOUNT_KEY }}
Content-Type: application/json
Body:
{ "name": "workflow:{{ $json.agentName }}" }
Response:
{ "token": "om_...", "inboxId": "inb_8f3a1b2c" }
# Shown once, never retrievable again.
03
Store credentials in n8n environment variables
Save all three as n8n environment variables — the key is the inbox-scoped one you just minted, not your account key, so this workflow can only reach its own inbox.
n8n environment variables
OPENMAIL_API_KEY=om_... # scoped to this inbox only
OPENMAIL_INBOX_ID=inb_8f3a1b2c
OPENMAIL_ADDRESS=agent@yourdomain.com
04
Send and reply from your workflow
Use an HTTP Request node to send email from your agent's inbox. Pass threadId to reply in the same thread — the reply arrives threaded correctly in the recipient's email client.
HTTP Request node
Method: POST
URL: https://api.openmail.sh/v1/inboxes/{{ $env.OPENMAIL_INBOX_ID }}/send
Headers:
Authorization: Bearer {{ $env.OPENMAIL_API_KEY }}
Content-Type: application/json
Body:
{
"to": "{{ $json.recipient }}",
"subject": "{{ $json.subject }}",
"body": "{{ $json.body }}",
"threadId": "{{ $json.threadId }}"
}
05
Trigger your n8n workflow from inbound email
Register your n8n webhook URL in the OpenMail dashboard. Every inbound email fires a structured JSON POST to your workflow — parsed message body, full thread context, and extracted attachments included. Webhook config is account-level on purpose: an inbox-scoped key can't repoint it, so a compromised workflow can't redirect its own mail.
Webhook payload
{
"event": "message.received",
"inbox_id": "inb_8f3a1b2c",
"thread_id": "thr_9d4e5f6a",
"message": {
"from": "customer@example.com",
"subject": "Re: Your order",
"body_text": "Thanks for following up...",
"attachments": [
{
"filename": "receipt.pdf",
"parsedText": "Order confirmation #1042"
}
]
}
}
What n8n agents use email for
- Customer support: Receive tickets, reply in thread, escalate when needed — no human in the loop for routine enquiries.
- Invoice processing: Receive vendor emails, parse PDF attachments into structured data, and route line items to accounting automatically.
- Sales follow-ups: Send personalised outbound sequences, receive replies in full thread context, and continue the conversation without leaving n8n.
- Account verification: Receive OTP codes and confirmation links autonomously — complete signup and verification flows without human involvement.
- Internal ops: HR and IT request handling via dedicated agent inboxes — employees email in, your workflow handles the rest.
What's included
- Dedicated inbox per agent: Each n8n workflow gets its own address on your domain — no shared inboxes, no filtering logic required.
- Webhook inbound delivery: Every inbound email fires a structured JSON POST into your n8n workflow in under 500ms. No polling, no IMAP.
- Full thread history as structured JSON: Every inbound reply includes complete thread context — your workflow always has the full conversation available.
- Attachment parsing: PDF, CSV, and DOCX files automatically extracted to plain text and included in the webhook payload.
- Managed deliverability: SPF, DKIM, and DMARC configured automatically on provisioning. Primary inbox from day one.
- Works with n8n Cloud and self-hosted: REST API and webhooks, no special setup. Works with any n8n deployment as long as your webhook endpoint is reachable.
Frequently asked questions
How do I connect OpenMail to n8n?
Use an HTTP Request node to call POST /v1/inboxes and create an inbox. Register your n8n webhook URL in the OpenMail dashboard to receive inbound emails as workflow triggers. Full guide at docs.openmail.sh/quickstart/api.
Does OpenMail work with n8n Cloud and self-hosted?
Yes. OpenMail uses REST API calls and webhooks — it works with any n8n deployment as long as your webhook endpoint is publicly reachable.
How does inbound email trigger an n8n workflow?
Register your n8n Webhook node URL in the OpenMail dashboard. Every inbound email fires a structured JSON POST to that URL with the parsed message, thread context, and attachments included.
Can an n8n workflow handle a full email conversation autonomously?
Yes. OpenMail delivers every inbound reply with the full thread history as structured JSON. Your workflow receives complete context and can reply using the threadId to keep the conversation threaded correctly.
Is there a free tier?
Yes. Three inboxes and 3,000 emails per month. No credit card required.