Skip to content

Email, phone and messaging

LangChain email agent: give a LangChain agent its own inbox and phone number

Five steps in TypeScript: create the inbox and the number, wrap each as a LangChain tool, put sends behind approval and wake the agent on every reply. LangChain’s own email tooling is described from its docs as read on 23 November 2026.

A LangChain email agent is a LangChain agent with tools to send and read email, and to give it an address of its own, wrap an inbox’s calls as LangChain tools. With Obsession, obsession.inboxes.create() returns that inbox and obsession.numbers.create({ country: "US" }) a number, and each reply reaches your server as email.received or sms.received, where agent.invoke() resumes the conversation. LangChain’s own Gmail toolkit is the shorter path when the agent works in a person’s Gmail.

ComparedWays to give a LangChain agent email, comparedGo straight to the comparison
On this page
  1. What a LangChain email agent needs
  2. LangChain’s own email tooling
  3. Give a LangChain agent its own inbox and number
  4. When the reply takes days
  5. Ways to give a LangChain agent email, comparedCompared
  6. When LangChain’s Gmail toolkit is enough
  7. Guardrails for a LangChain email agent
  8. Questions about LangChain email agents

Developers building a LangChain email agent need more than a model. The agent needs tools that send, a way to wake it when a reply lands, and memory that picks the conversation back up. With an inbox and a phone number of its own, it writes from an address and number that belong to it, and every reply reaches your code as an event. The code uses LangChain’s TypeScript library and Obsession’s TypeScript SDK, as documented on 23 November 2026.

What a LangChain email agent needs

A LangChain agent is a model that calls tools in a loop until a task is done. LangChain’s agent docs build one with createAgent, a model and a list of tools. Its tools docs define each tool with the tool function, a name, a description and a schema written in zod, a TypeScript library for describing inputs. An email agent adds four parts:

  • A send tool that writes from an address the agent owns.
  • A wake-up that runs the agent when an email or text arrives, often days later.
  • Memory per conversation, so a reply resumes the thread it belongs to. LangChain keeps it with a checkpointer and a thread_id.
  • Approval before sending, so a person checks each email first. LangChain’s human-in-the-loop middleware pauses chosen tool calls until someone approves, edits or rejects them.

LangChain’s own email tooling

LangChain’s Gmail toolkit reads messages, drafts and sends through the Gmail API. It installs with the langchain-google-community package and gives an agent five tools: GmailCreateDraft, GmailSendMessage, GmailSearch, GmailGetMessage and GmailGetThread. It signs in with a credentials.json file from a Google Cloud project, and its example asks for the full mailbox scope, with a read-only scope as the alternative. LangChain.js ships a GmailSendMessage class in its community package too.

For the whole pattern, LangChain’s agents-from-scratch repository builds an email assistant in four parts. A triage step works with an agent that writes replies, then come evaluation, human review of tool calls such as sending an email, and memory that learns from feedback. Its notebooks run on mock email tools, with a Gmail integration to connect a real account.

LangChain’s tools index also lists email toolkits from inbox providers built for agents. MCP, the Model Context Protocol, is how AI applications call outside tools, and LangChain’s MCP adapter loads any MCP server’s tools into createAgent. MCP servers for email compares the servers it can load. These tools suit an agent that works in a person’s Gmail. An agent with an address of its own needs an inbox that belongs to the agent.

Give a LangChain agent its own inbox and number

Obsession is the toolkit for AI agents: inboxes, phone numbers, browsers and sandboxes on one API and one bill. Each step ends with what a pass looks like.

  1. Install the packages. Run npm install obsession langchain zod @langchain/langgraph, set OBSESSION_API_KEY, and create the client with new Obsession({ apiKey: process.env.OBSESSION_API_KEY }). Pass: the client starts with no error.
  2. Create the inbox and the number. const inbox = await obsession.inboxes.create() returns an inbox that sends and receives, at inbox.address. const number = await obsession.numbers.create({ country: "US" }) returns a number that texts and takes calls, at number.e164. Pass: an address and a number come back.
  3. Wrap each call as a tool. const sendEmail = tool(({ to, subject, text }) => inbox.send({ to, subject, text }), { name: "send_email", description: "Send an email from the agent’s own address.", schema: z.object({ to: z.string(), subject: z.string(), text: z.string() }) }). A send_text tool wraps number.sms({ to, text }) the same way. Pass: sendEmail.invoke() with your own address delivers an email to your mailbox.
  4. Build the agent with approval. const agent = createAgent({ model: "anthropic:claude-sonnet-5", tools: [sendEmail, sendText], middleware: [humanInTheLoopMiddleware({ interruptOn: { send_email: true, send_text: true } })], checkpointer: new MemorySaver() }). The middleware holds every send for a person, and the checkpointer keeps each conversation. Pass: a request to email someone stops at an approval before anything leaves.
  5. Wake it on every reply. obsession.events.subscribe({ url: process.env.HOOK_URL, events: ["email.received", "sms.received"] }) posts each new email and text to your server. For an email, the handler calls agent.invoke({ messages: [{ role: "user", content: JSON.stringify(event.data) }] }, { configurable: { thread_id: event.data.thread } }), so the reply resumes its own conversation. Pass: a reply you send to inbox.address reaches the handler, and the agent drafts an answer for approval.

For texts, key the thread_id on the sender’s number instead. The Free plan’s number receives up to 50 texts and 30 call minutes a month, and sending texts needs a paid plan. US carriers also require business texting to be registered, as 10DLC registration explains. On Obsession that costs $25 once for each campaign, then $17 a month while the campaign is active.

To keep the inbox and the number under one name, create them together with obsession.personas.create({ inbox: true, phone: "US" }). A persona is free while it waits. Its handler can also run on Obsession’s runtime instead of your server, about 50 ms after each email lands.

When the reply takes days

Email agents wait. A supplier answers on Wednesday a question sent on Monday, and a lead texts back a week later. The agent holds nothing open in between. The inbox keeps receiving, every email and text lands in your event log, and the reply reaches your handler as an event. If your server is down, events retry for 27 hours, and any event can be replayed.

LangChain’s checkpointer then restores the conversation from its thread_id, so the agent answers with everything it said before. MemorySaver keeps that history only while the process runs, and LangChain’s docs point to its Postgres and MongoDB savers for production. Long running AI agents covers longer waits and the patterns behind them.

Ways to give a LangChain agent email, compared

We make Obsession, so every other option is described from its provider’s own pages as of 23 November 2026.

OptionWhat it does wellPriceWhere it stopsBest for
LangChain Gmail toolkitFive ready tools: search, read, thread, draft and sendFree; Gmail API quota of 250 units per user per secondA Google account it signs in to; full mailbox scope in the exampleAgents that work in a person’s Gmail
LangChain agents-from-scratchTriage, replies, evaluation, approvals and memory, in notebooksFree, MITMock tools until you connect GmailLearning the whole email agent pattern
MCP servers through MCPAdapterAny email MCP server’s tools, loaded into createAgentFree adapter; each server priced by its makerAs wide as the server you pickReusing a server you already run
Your own tools on an email APIFull control of every callPriced by the provider you chooseYou build receiving, threads and the wake-upOne provider you already use
ObsessionOursEmail, Phone and Personas through the SDKAn inbox and a number in two callsEvery reply as an event, in one logFree, then $20, $99 or $499 a month; usage per pieceStops before payment unless given your cardAgents with their own address and number
Ways to give a LangChain agent email, from each provider’s own pages, as listed on 23 November 2026. Prices in US dollars

When LangChain’s Gmail toolkit is enough

If the agent works in one person’s Gmail, such as drafting replies for a founder to send, the Gmail toolkit needs nothing beyond a Google Cloud project. An inbox of its own fits when the address belongs to the agent. That covers a support or sales agent, one agent per customer or user, and an agent that signs up to supplier portals and reads the codes they send.

It also fits an agent that needs a phone number or a browser that stays signed in, on the same key. An inbox is $0.50 a month and a US number $2 a month, for 1 agent or a fleet of 10,000. The same inbox works from Claude Code too, as email for Claude Code shows, and how to build an AI agent from scratch covers the loop underneath.

Guardrails for a LangChain email agent

  • Approve before it sends. Keep send_email and send_text in interruptOn until the agent has earned trust on real replies.
  • Treat every email as untrusted. An email can carry instructions written for the model, so pass its text in as data and keep it apart from your system prompt.
  • Identify the agent. Every Obsession agent says it’s an AI when it talks to a person, and texts people who gave the business their number.

Questions about LangChain email agents

Yes. Create an inbox with obsession.inboxes.create(), wrap inbox.send as a LangChain tool, and subscribe your server to email.received so each reply wakes the agent. The Free plan includes 3 inboxes with no credit card.

Email for AI agents

Create the inbox through an email API, define a send tool with LangChain’s tool function and a zod schema, and pass it to createAgent. Then send each incoming email to agent.invoke with the email’s thread as the thread_id, so the agent resumes the right conversation.

Yes. The Gmail toolkit in the langchain-google-community package gives an agent five tools to search, read, draft and send in a Gmail account. It signs in with a credentials.json file from a Google Cloud project, and LangChain.js has Gmail tool classes in its community package.

Through a webhook, an address on your server that receives each new email as an event. The handler passes the email to agent.invoke, and a checkpointer restores the conversation from its thread_id. If your server is down, Obsession retries each event for 27 hours.

Yes. Wrap number.sms as a tool next to the email tool. A US number is $2 a month and each text $0.015, and US business texting needs a carrier registration, which Obsession files for $25 once per campaign, then $17 a month.

Phone numbers for AI agents

Yes. LangChain’s Python and TypeScript libraries share the same ideas of agents, tools, middleware and checkpointers, and Obsession’s API can be called from Python or plain HTTP as well as its TypeScript SDK.

API and MCP
ShareLinkedInX

Sources

In the order the article cites them. Every link was checked on 23 Nov 2026.

  1. AgentsLangChain docs (TypeScript)
  2. ToolsLangChain docs (TypeScript)
  3. Human-in-the-loopLangChain docs (TypeScript)
  4. Gmail toolkit integrationLangChain docs (Python)
  5. GmailSendMessageLangChain reference (JavaScript)
  6. agents-from-scratchGitHub (LangChain)
  7. Tools and toolkitsLangChain docs (Python)
  8. Model Context Protocol (MCP)LangChain docs (TypeScript)

What should your first AI agent do?