LangChain
Getting started
LangChain is the most widely used framework for building LLM-powered agents. The langchain-agentmail package wraps the AgentMail SDK as standard LangChain tools, plus a document loader and a retriever — so a LangGraph agent can send, reply, draft, label, and search email through a real inbox without any glue code.
The full reference lives on the LangChain docs site: docs.langchain.com/oss/python/integrations/providers/agentmail.
Use cases
- Give agents their own inboxes: Provision a dedicated email address per agent so it can send and receive mail independently.
- Triage and reply: Read recent threads, summarize what’s new, and reply inside the same thread with the right In-Reply-To headers.
- Stage and schedule sends: Use the draft tools to compose iteratively or schedule a delivery time via
send_at. - RAG over email: Load messages as LangChain
Documents and index them into a vector store for semantic search across the inbox.
Prerequisites
- An AgentMail account with an API key from the AgentMail Console.
- Python 3.10+ and a LangChain-compatible model provider (e.g. an
OPENAI_API_KEYorANTHROPIC_API_KEY).
Setup
Install the integration package:
Set your API key:
Quickstart
Build a ReAct agent with the full toolkit in a few lines:
You can also pull a single tool in if you don’t need the whole toolkit:
Available tools
The toolkit exposes one tool per AgentMail operation.
Inbox and thread management
Message operations
Draft management
RAG over an inbox
AgentMailLoader streams messages as LangChain Documents — one per message, plain-text body as page_content, sender / subject / labels / thread / attachment metadata on metadata. Pair it with any vector store for semantic search:
For a quick keyword search without embeddings, use the bundled AgentMailRetriever instead.
Inbound email via webhooks
The webhooks extra ships a FastAPI router with svix-compatible signature verification so a LangGraph agent can react to inbound mail:
Resources
- LangChain integration docs: docs.langchain.com/oss/python/integrations/providers/agentmail
- Source code: github.com/agentmail-to/langchain-agentmail
- PyPI: pypi.org/project/langchain-agentmail/
