Stateful Email Workflows for LangGraph Agents

Combine LangGraph's graph-based orchestration with MultiMail's email infrastructure to build multi-step email workflows with built-in human approval checkpoints.


LangGraph is a framework for building stateful, multi-step agent workflows as directed graphs. Built by the LangChain team, it excels at complex agent patterns that require cycles, branching, persistence, and human-in-the-loop checkpoints. MultiMail provides the email infrastructure layer that LangGraph agents need to send, receive, and manage messages within these workflows.

LangGraph's checkpoint system pairs naturally with MultiMail's oversight modes. You can model email approval as a graph node that pauses execution until a human approves the draft in MultiMail's pending queue, then resumes the workflow automatically. This makes gated_send a first-class workflow primitive rather than an afterthought.

Connect LangGraph to MultiMail by defining tool nodes that call the MultiMail REST API or by integrating the @multimail/mcp-server. Both approaches let your graph nodes send, read, and reply to emails while respecting oversight boundaries.

Built for LangGraph developers

Human-in-the-Loop as Graph Nodes

LangGraph's checkpoint system and MultiMail's gated_send mode align perfectly. Model email approval as an explicit node in your state graph, pausing execution until the human approves the draft.

Stateful Email Conversations

LangGraph persists state across graph executions. Combined with MultiMail's thread tracking via get_thread, your agent maintains full context across multi-turn email conversations spanning days or weeks.

Branching Email Logic

Use conditional edges to route emails based on content, sender, or intent. LangGraph's branching lets you build sophisticated triage workflows that classify inbound mail and route responses through different processing paths.

Cyclic Workflows for Follow-ups

LangGraph supports cycles, enabling agents that check for replies, send follow-ups, and loop until a conversation reaches resolution — all with MultiMail handling delivery and thread management.

Oversight Modes Match Workflow Stages

Start new email workflows in gated_send mode for safety, then programmatically escalate to monitored or autonomous as the workflow proves reliable. MultiMail's five oversight levels map to different trust stages in your graph.


Try it with your agent

No code, no dashboard. Paste this to your AI agent — it connects MultiMail, creates an inbox, and builds the flow for you.

1. Read https://multimail.dev/llms.txt first. Connect the MultiMail MCP server exactly as documented there, create a free MultiMail inbox for this LangGraph agent, configure a verified sending domain, and set the inbox oversight mode to gated_send. 2. Wire the connected MCP tools into LangGraph using LangGraph's real tool mechanism: load the MultiMail MCP tools with the LangChain MCP adapter, then pass those tools to langgraph.prebuilt.create_react_agent, or place them behind a ToolNode inside your StateGraph if you are building the graph manually. 3. Give the agent only the MultiMail tools it needs for this workflow: check the inbox, compose or draft replies, and send or schedule email. In the agent instructions, require it to draft first, preserve thread context, and never send unrelated or promotional email. 4. Send a test email through the LangGraph agent to your own address. Have the agent check the inbox, draft a reply, and attempt to send the reply using MultiMail so you can verify the full receive, draft, and send loop. 5. Keep the inbox in gated_send for the test and for initial development. Treat every send attempt as pending until you review and approve it, and do not move to monitored or autonomous until the workflow is behaving correctly.

Step by step

1

Create a MultiMail Account and API Key

Sign up at multimail.dev, create a mailbox, and generate an API key from your dashboard. Your key will start with mm_live_.

2

Install Dependencies

Install LangGraph, LangChain core, and requests for calling the MultiMail API.

3

Define Your State and Nodes

Create a TypedDict for your email workflow state and implement node functions that call MultiMail endpoints for inbox checking, email drafting, and sending.

4

Build and Compile the Graph

Wire nodes together with edges and conditional routing. Add a checkpointer for state persistence across workflow executions.

5

Run and Monitor

Execute the graph and review pending emails in the MultiMail dashboard. Approve or reject drafts, and the graph will proceed based on approval status.


Common questions

How does LangGraph's human-in-the-loop work with MultiMail's oversight?
LangGraph's checkpoint system can pause graph execution at any node. When your graph hits a send_email node in gated_send mode, MultiMail queues the email for human approval. You can add an approval-polling node that checks the pending queue and resumes the graph once approved. This combines LangGraph's workflow control with MultiMail's email-specific oversight.
Can I persist LangGraph state across email conversations that span days?
Yes. LangGraph supports persistent checkpointers like SQLite or PostgreSQL. Your graph state — including inbox history, drafted emails, and conversation context — persists across executions. This is ideal for email workflows where responses may take hours or days to arrive.
What's the difference between using LangGraph vs plain LangChain with MultiMail?
LangChain is best for simple tool-calling agents that react to a single prompt. LangGraph adds stateful, multi-step workflows with branching and cycles. Use LangGraph when your email workflow has multiple stages (triage, draft, approve, send, follow up) or needs to maintain state across long-running conversations.
Can I use LangGraph's prebuilt ReAct agent with MultiMail?
Yes. LangGraph's create_react_agent function builds a graph with tool-calling capabilities. You can pass MultiMail tools (either custom functions or MCP-discovered tools) and the agent will reason about when to check email, draft replies, and send messages within the ReAct loop.
How do I handle email attachments in a LangGraph workflow?
Add an attachment-processing node to your graph that encodes files as base64 and includes them in the MultiMail API request body. LangGraph's state can carry attachment data between nodes, so one node can download files and a later node can attach them to outgoing emails.

Explore more

The only agent email with a verifiable sender

Email infrastructure built for AI agents. Verifiable identity, graduated oversight, and a hosted MCP server. Formally verified in Lean 4.