AutoGen + AgentMail
Official AgentMail integration for AutoGen / AG2. Give your agents real email inboxes — send, receive, reply, forward, and organize messages via the AgentMail API.
Install
pip install autogen-agentmail
Quick Start
1. Set your API key
export AGENTMAIL_API_KEY=your_key_here
2. Create an inbox for your agent
from autogen_agentmail import create_inbox
inbox = create_inbox(name="My Agent")
print(inbox["email"]) # e.g. agent-abc123@agentmail.to
3. Send an email
from autogen_agentmail import send_email
send_email(
to="bob@example.com",
subject="Hello from my agent",
body="This is an automated message.",
from_inbox_id=inbox["id"],
)
4. Wait for a reply
from autogen_agentmail import wait_for_message
msg = wait_for_message(inbox_id=inbox["id"], timeout=60)
print(msg["body"])
5. Register all tools with an AutoGen agent
import autogen
from autogen_agentmail import register_agentmail_tools
agent = autogen.ConversableAgent(
name="EmailBot",
llm_config={"config_list": [{"model": "gpt-4o"}]},
)
register_agentmail_tools(agent)
# Agent can now create_inbox, send_email, list_messages, etc.
Available Tools
| Tool | Description |
|---|---|
create_inbox |
Create a new email inbox |
send_email |
Send an email from an inbox |
list_messages |
List messages in an inbox |
get_message |
Get a single message by ID |
reply_to_email |
Reply to a message |
forward_email |
Forward a message to another recipient |
wait_for_message |
Long-poll for new messages |
search_messages |
Search messages by keyword |
create_label |
Create a label/tag |
apply_label |
Apply a label to a message |
delete_inbox |
Delete an inbox and its messages |
Example
See example.py for a full demo of two agents communicating via email with inboxes, send, wait, and cleanup.
Configuration
| Variable | Description | Default |
|---|---|---|
AGENTMAIL_API_KEY |
Your AgentMail API key | — |
api_key param |
Per-call override | env var |
base_url param |
Custom API base URL | https://api.agentmail.to |
License
MIT
Release files for autogen-agentmail 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| autogen_agentmail-0.1.0.tar.gz | 7.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| autogen_agentmail-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.7 kB
Release files / autogen_agentmail-0.1.0.tar.gz
| Download URL | autogen_agentmail-0.1.0.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bad3a4cb08bb878b835cda95a67d44f08fbbab5a06292ac496dc35c8c79c43f6
|
|
BLAKE2b-256 checksum How to use checksums |
19ca682aefa1acd3695c984afb696ff373c8b7cec6111357a46678dc942081da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / autogen_agentmail-0.1.0-py3-none-any.whl
| Download URL | autogen_agentmail-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
27d03edf0b1de4d13ef8e9cb683ea4cd2842531f1f0ad260ad211c316bf51916
|
|
BLAKE2b-256 checksum How to use checksums |
c08887021db9401c9d86471f9387b4c64c11577d930baf9fcf9792a0ae7ccb80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|