Skip to main content

How it works

When someone replies to your agent’s email, Commune:
  1. Receives the reply on your inbox address
  2. Resolves it to the correct conversation thread
  3. POSTs the full parsed email to your webhook endpoint
  4. Your agent processes and replies

Step 1: Set a webhook on your inbox

Step 2: Handle the webhook

Every inbound email POSTs to your endpoint:
Always include thread_id when replying. This is what keeps the conversation correctly threaded for both your agent and the recipient’s email client.

Step 3: Verify webhook signatures

Commune signs every webhook with HMAC-SHA256. Verify before processing:

How threading works

Commune resolves replies to threads in this priority order:
  1. Routing token — a unique token embedded in the Reply-To header of your outbound email
  2. RFC 5322 Message-ID — standard email header threading
  3. Subject line matching — fallback for replies that strip headers
You don’t configure this. It’s automatic.

Read conversation history

Before generating a reply, your agent can read the full thread:

Webhooks

Full webhook reference including payload schema and signature verification.

Threads

Thread management API for reading conversation history and resolving message chains.

How to Add Email to a LangChain Agent

Complete tutorial covering multi-agent email patterns with LangChain.
Last modified on March 19, 2026