Official AgentMail integration for LangChain
Project description
LangChain + AgentMail
Official AgentMail integration for LangChain. Give your AI agents the ability to create email inboxes, send and receive emails, and automate email-based workflows like OTP verification.
Install
pip install langchain-agentmail
Quick Start
from langchain_agentmail import AgentMailToolkit
# Uses AGENTMAIL_API_KEY env var by default
toolkit = AgentMailToolkit()
tools = toolkit.get_tools()
Create an Inbox
result = tools[0].invoke({"name": "test-inbox"}) # CreateInbox
print(result) # {"inbox_id": "...", "email": "..."}
Send and Read Emails
# Send an email
tools[1].invoke({"to": "user@example.com", "subject": "Hello", "body": "Hi there!", "from": "inbox_abc123"})
# Wait for a reply (blocks up to 60s)
msg = tools[6].invoke({"inbox_id": "inbox_abc123", "timeout": 60})
Use with a LangGraph Agent
from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI
from langchain_agentmail import AgentMailToolkit
toolkit = AgentMailToolkit()
agent = create_react_agent(ChatOpenAI(model="gpt-4o-mini"), toolkit.get_tools())
result = agent.invoke({"messages": [{"role": "user", "content": "Create an inbox and wait for a verification email"}]})
See example.py for a full OTP-automation agent.
Environment Variables
| Variable | Description |
|---|---|
AGENTMAIL_API_KEY |
Your AgentMail API key (required) |
Tools
| Tool | Description |
|---|---|
CreateInbox |
Create a new email inbox |
SendEmail |
Send an email |
ListMessages |
List messages in an inbox |
GetMessage |
Get a single message by ID |
ReplyToEmail |
Reply to a message |
ForwardEmail |
Forward a message |
WaitForMessage |
Block until a new message arrives |
SearchMessages |
Search messages by query |
CreateLabel |
Create an organizational label |
ApplyLabel |
Apply a label to a message |
DeleteInbox |
Delete an inbox permanently |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_agentmail-0.1.0.tar.gz.
File metadata
- Download URL: langchain_agentmail-0.1.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3dff2b9b8d71c5ce26f2f46ee3f114aeb1c76a2ff1eb1a62f6155601fc578ee
|
|
| MD5 |
53d12310bf8229d689e41e430bc6fee7
|
|
| BLAKE2b-256 |
3ee6f8bf2850caf3a0b63e86502600389668b83ee360a45d4e6a496890e5652b
|
File details
Details for the file langchain_agentmail-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_agentmail-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
117c58fd45b945fe2c9da81a6edb1db3d5afd3a7965d17910a55d8f1a2bb8c0e
|
|
| MD5 |
1f577baa7721805bbfdf4e07b8bc25f8
|
|
| BLAKE2b-256 |
89e17e54c0ba12b15419a884b0b32c58a963d08bb9c60df1bac351d82734dfb3
|