Email for AG2 Multi-Agent Conversations

Give AG2 conversable agents email capabilities with MultiMail — centralized oversight ensures every email from any agent in the group is properly authorized.


AG2 is a community fork of AutoGen that provides a multi-agent conversation framework. It maintains API compatibility with AutoGen while adding community-driven features for production use. When AG2 agents in a group chat need to send email, MultiMail provides centralized oversight that catches sends from any agent in the conversation.

In AG2's multi-agent setup, multiple agents may independently decide to trigger email actions. MultiMail's centralized oversight is essential here: regardless of which agent in the group chat calls the send endpoint, the email is gated for human review in gated_send mode.

Integration uses AG2's function registration system. Define email functions and register them with your AssistantAgent instances, just as you would with AutoGen.

Built for AG2 developers

Centralized Oversight for Group Chats

AG2 group chats involve multiple agents that can all trigger actions. MultiMail's centralized oversight ensures every email from any agent passes through the same review queue, preventing unauthorized sends.

AutoGen API Compatibility

AG2 maintains AutoGen API compatibility, so MultiMail integrations written for AutoGen work with AG2 unchanged. Same function registration, same tool calling patterns, same email oversight.

Production-Ready Email Safety

AG2 focuses on production readiness. MultiMail's oversight modes align with this goal — graduated trust from gated_all to autonomous lets you deploy email-capable agents with appropriate safety controls.

Code Execution Monitoring

AG2 agents can generate and execute code that might include email operations. MultiMail's API-level oversight catches email sends from both registered functions and dynamically generated code.


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. Get MultiMail ready: read https://multimail.dev/llms.txt, connect the MultiMail MCP server to the agent environment you use with AG2, create a free inbox for this agent, and set up a verified sending domain so outbound mail is authorized. 2. Wire MultiMail into AG2 using AG2’s tool-calling pattern for ConversableAgent agents: expose the MultiMail MCP tools as callable functions on the agent that will handle email, and register those functions with the agent that executes tool calls. 3. Give the AG2 agent three email abilities through those registered tools: check the MultiMail inbox for new messages, compose draft replies for developer review, and send or schedule approved emails from the verified sender. 4. Send a test email to the new MultiMail inbox, ask the AG2 agent to check mail, summarize the message, draft a reply, and prepare it to send from the verified sender. 5. Run MultiMail in gated_send oversight mode for this AG2 setup so every outgoing email from any agent in the group is held for developer review and explicit approval before it sends.

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 AG2 and the HTTP library for calling the MultiMail API.

3

Define and Register Email Functions

Create email functions that call the MultiMail API. Register them with your AssistantAgent using register_for_llm and with UserProxyAgent using register_for_execution.

4

Configure Your Agent or Group Chat

Set up an AssistantAgent with a system message explaining the oversight mode, or create a group chat with a designated email agent.

5

Approve Pending Emails

Review emails queued by AG2 agents in the MultiMail dashboard. Approve or reject before delivery.


Common questions

Is AG2 compatible with AutoGen MultiMail integrations?
Yes. AG2 maintains API compatibility with AutoGen. Email function registrations, tool calling patterns, and agent configurations written for AutoGen work with AG2 without modification. MultiMail API calls are identical in both frameworks.
How do I prevent multiple agents from sending duplicate emails?
Register email functions only with one designated email agent in the group chat. Other agents discuss and draft content, but only the email agent can actually invoke send_email. MultiMail's gated_send mode provides an additional safety layer where duplicates can be caught during review.
Can AG2 agents execute code that sends emails?
AG2's code execution feature lets agents run generated Python code. If this code calls the MultiMail API, the oversight is still enforced server-side. In gated_send mode, emails from generated code are queued for review just like emails from registered functions.
How does AG2 handle email function errors?
MultiMail returns standard HTTP error codes that your functions convert to strings for the agent. The agent sees the error message and can retry or modify its approach. Common errors include 429 (rate limited) and 400 (invalid parameters). The agent's LLM reasoning helps it adapt to these errors.

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.