AnswerLoopsAnswerLoops Docs
Self-Hosting

Email Channel Setup

Route inbound support emails through the AnswerLoops AI pipeline.

How it works

Email doesn't poll an inbox. AnswerLoops accepts inbound mail through a webhook endpoint: the AI pipeline triages, embeds, and answers each message, then replies directly to the sender via Resend with proper RFC 5322 threading (Message-ID / In-Reply-To / References), so a customer's next reply lands in the same conversation instead of opening a new ticket.

There are two ways to connect:

  • Platform-hosted (recommended) — one click, zero setup. AnswerLoops generates a dedicated inbox address on our infrastructure. Share that address, or forward an existing mailbox to it, and signature verification, spam/loop filtering, and delivery-status tracking are all handled for you.
  • Bring your own provider (advanced) — point your own SendGrid, Mailgun, Postmark, or Cloudflare account at our webhook with a shared secret. Use this only if you need a custom sending domain the platform-hosted address doesn't give you.

Quickstart: platform-hosted (zero setup)

  1. Go to Settings → Email.
  2. Click Connect email. No API key, no DNS record, no webhook config — AnswerLoops immediately generates an address like [email protected].
  3. Share that address with customers, or forward your existing support mailbox to it.
  4. Done. Inbound mail is triaged, answered, and replied to automatically; replies thread correctly on the customer's next reply.

The generated address is set once and is immutable for the life of the integration — reconnecting never changes it.

Advanced: bring your own provider

Use this path only if you need a custom sending domain or already run your own inbound email infrastructure.

1. Prerequisites

  • RESEND_API_KEY and RESEND_FROM must be set (used for outbound replies)
  • An account with a supported email routing provider

2. Configure in AnswerLoops Settings

Under Settings → Email → Advanced: bring your own email provider, enter:

  • Reply-from address (optional) — the From: address for AI replies. Defaults to RESEND_FROM env var if blank.
  • Allowed sender addresses/domains (optional) — comma-separated list of emails or domains to accept (e.g. example.com, [email protected]). Leave blank to accept all inbound email.
  • Escalation email (optional) — referenced in replies when AI confidence is below threshold.
  • Confidence threshold — 0–1, default 0.8.

Click Connect. The webhook secret is shown once — copy it before closing.

3. Configure your email provider

Point your provider's inbound webhook at:

POST https://yourapp.com/api/email/ingest

Set the custom secret header:

X-Email-Webhook-Secret: <your webhook secret>

Provider-specific guides

SendGrid Inbound Parse

  1. Settings → Inbound Parse → Add Host & URL
  2. Enter your domain and https://yourapp.com/api/email/ingest
  3. Set the X-Email-Webhook-Secret header via your SendGrid HTTP POST settings

Mailgun Routes

  1. Sending → Routes → Create Route
  2. Match filter: match_recipient("[email protected]")
  3. Action: forward("https://yourapp.com/api/email/ingest")
  4. Add X-Email-Webhook-Secret in the route headers

Postmark Inbound

  1. Message Streams → Inbound → Settings
  2. Inbound webhook URL: https://yourapp.com/api/email/ingest
  3. Set the X-Email-Webhook-Secret header in Postmark webhook settings

Cloudflare Email Routing

  1. Email → Email Routing → Rules
  2. Forward to a Worker that POSTs to your webhook URL with the secret header

Verify

Send an email to your address. A ticket should appear in /tickets within a few seconds with source badge "Email from [email protected]". Reply to the AI's answer from your own inbox — it should append to the same ticket rather than opening a new one.

Reliability

A few things worth knowing about how the pipeline handles the messy realities of email:

  • Idempotent by construction. Every inbound email is keyed on its RFC Message-ID, so a provider webhook retry is a no-op, never a duplicate ticket.
  • Mail-loop guarded. Auto-Submitted, Precedence, X-Auto-Response-Suppress, List-Id, and no-reply sender patterns are all detected and rejected before a reply is ever generated. A per-sender reply throttle backstops anything that slips through.
  • Spam-tolerant, fail-open. Provider spam signals are honored when present, but their absence never blocks a legitimate email.
  • HTML fallback. HTML-only emails are converted to plain text rather than silently dropped.
  • Delivery-status visibility. Bounces, spam complaints, and delivery failures on outbound replies are tracked against the ticket and surfaced as a badge on the ticket detail page.
  • Rate-limited per org. A compromised or misbehaving upstream account can't burn one org's AI spend or flood the ticket queue for everyone else.

Environment variables

VariableWhat it is
RESEND_API_KEYRequired for outbound replies
RESEND_FROMDefault reply-from address (e.g. [email protected])
RESEND_WEBHOOK_SECRETSvix signing secret for Resend's inbound webhook (whsec_...) — required for the platform-hosted path
EMAIL_INBOUND_DOMAINDomain used when generating platform-hosted inbound addresses (defaults to inbox.answerloops.app)

The BYO-provider webhook secret is generated automatically and stored in the database per org — no env var needed for that path.

Notes

  • Quoted reply chains are stripped — only the new message content is ingested.
  • Subject is prepended to the body so triage has full context.
  • Messages under 10 characters are ignored.
  • Replies set Message-ID, In-Reply-To, and References for correct email-client threading.

On this page