Real Email for CAMEL Role-Playing Agents

Bridge CAMEL's multi-agent role-playing with real email delivery — using MultiMail's oversight modes to safely transition from simulation to production.


CAMEL is a communicative agents framework for studying multi-agent behaviors through role-playing. Its agents take on specific roles and collaborate on tasks through structured dialogue. When these role-playing scenarios need to interact with the real world via email, MultiMail provides the safe bridge.

MultiMail's oversight modes are particularly valuable for CAMEL because role-playing agents may simulate business communications that shouldn't immediately become real emails. The gated_send mode lets agents compose emails naturally during role-play while a human decides which ones to actually deliver.

Integration uses CAMEL's tool system. Define MultiMail API functions as tools available to ChatAgent instances, giving role-playing agents email capabilities with built-in safety controls.

Built for CAMEL developers

Safe Simulation-to-Production Bridge

CAMEL agents role-playing business scenarios may draft realistic emails. MultiMail's gated_send mode lets these drafts exist as reviewable items rather than delivered messages, safely bridging simulation and real communication.

Role-Specific Email Permissions

Different CAMEL roles can have different email capabilities. An executive agent might have send access while a research agent only reads. MultiMail's per-mailbox oversight modes enable this fine-grained control.

Society-Level Communication Patterns

CAMEL's society framework models group interactions. MultiMail extends this to external email, letting agent societies coordinate on outbound communications while maintaining human oversight.

Research-Grade Audit Logging

Studying multi-agent email behavior requires detailed logs. MultiMail's audit trail records every email action with context, providing research-grade data on how role-playing agents handle communications.


Get started in minutes

Define MultiMail Tools for CAMEL Agents
python
import requests
from camel.toolkits import FunctionTool

MULTIMAIL_API = "https://api.multimail.dev/v1"
HEADERS = {"Authorization": "Bearer mm_live_your_api_key"}

def send_email(to: str, subject: str, body: str, mailbox_id: str) -> str:
    """Send an email via MultiMail. In gated_send mode, the email is
    queued for human approval before delivery."""
    resp = requests.post(f"{MULTIMAIL_API}/send", headers=HEADERS, json={
        "mailbox_id": mailbox_id,
        "to": to,
        "subject": subject,
        "body": body
    })
    return str(resp.json())

def check_inbox(mailbox_id: str) -> str:
    """Check inbox for recent messages."""
    resp = requests.get(
        f"{MULTIMAIL_API}/mailboxes/{mailbox_id}/inbox",
        headers=HEADERS,
        params={"limit": 10}
    )
    return str(resp.json())

"cm"># Wrap as CAMEL tools
send_email_tool = FunctionTool(send_email)
check_inbox_tool = FunctionTool(check_inbox)

Create tool functions that CAMEL ChatAgents can invoke for email operations.

Role-Playing Email Agents
python
from camel.agents import ChatAgent
from camel.messages import BaseMessage
from camel.types import ModelType

"cm"># Create a role-playing agent with email capabilities
assistant_sys_msg = BaseMessage.make_assistant_message(
    role_name="Executive Assistant",
    content=(
        "You are an executive assistant handling email correspondence. "
        "Use the send_email tool to draft emails and check_inbox to "
        "review incoming messages. All outbound emails go through "
        "gated_send mode — a human approves before delivery."
    )
)

assistant = ChatAgent(
    system_message=assistant_sys_msg,
    model_type=ModelType.GPT_4O,
    tools=[send_email_tool, check_inbox_tool]
)

"cm"># The agent can now role-play with email capabilities
user_msg = BaseMessage.make_user_message(
    role_name="Manager",
    content="Check our inbox and draft a reply to any "
            "pending client inquiries."
)

response = assistant.step(user_msg)
print(response.msg.content)

Create CAMEL role-playing agents that use email tools in their interactions.

Multi-Agent Email Society
python
from camel.societies import RolePlaying
from camel.types import TaskType

"cm"># Create a role-playing session focused on email management
role_play = RolePlaying(
    assistant_role_name="Customer Success Agent",
    user_role_name="Sales Director",
    task_prompt=(
        "Review the support inbox, categorize inquiries by urgency, "
        "and draft professional responses. Use the MultiMail tools "
        "to check inbox and send replies. All emails will be queued "
        "for approval in gated_send mode before delivery."
    ),
    assistant_agent_kwargs={"tools": [send_email_tool, check_inbox_tool]},
    task_type=TaskType.DEFAULT
)

"cm"># Run the role-playing session
for i in range(5):  "cm"># Max 5 conversation turns
    assistant_response, user_response = role_play.step()
    if assistant_response.terminated or user_response.terminated:
        break
    print(f"Turn {i+1}:")
    print(f"  Assistant: {assistant_response.msg.content[:100]}...")
    print(f"  User: {user_response.msg.content[:100]}...")

Set up a CAMEL society where agents collaborate on email-driven tasks.


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

bash
pip install camel-ai requests
3

Create Email Tool Functions

Define Python functions for send_email, check_inbox, and reply_email that call the MultiMail REST API. Wrap each with CAMEL's FunctionTool.

4

Assign Tools to Agents

Create ChatAgent instances with email tools and system messages that explain the oversight mode. Only assign email tools to roles that need them.

5

Approve Pending Emails

Review pending emails in the MultiMail dashboard. In gated_send mode, no email is delivered until a human approves it.


Common questions

Can CAMEL agents send real emails during role-playing?
Yes, but with safety controls. When a CAMEL agent invokes the send_email tool, MultiMail's gated_send mode queues the email for human review. The human decides whether the role-played email should actually be delivered, preventing accidental sends during simulations.
How do I limit which roles can send email?
Only pass email tools to the ChatAgent instances that should have email access. Agents without the send_email tool in their tool list simply cannot invoke it. You can also use separate mailboxes with different oversight modes for different roles.
Can I use CAMEL societies to study agent email behavior?
Yes. CAMEL's role-playing framework combined with MultiMail's audit logging provides a research environment for studying how agents handle email. The audit trail records every email action with full context, while gated_send prevents any unintended real-world side effects.
What oversight mode should I use for CAMEL experiments?
For research and testing, use gated_all so every email action (reads and sends) is logged and gated. For production deployments where the role-playing session handles real customer email, gated_send is appropriate — reads are free but sends need approval.

Explore more

The only agent email with a verifiable sender

Email infrastructure built for AI agents. Verifiable identity, graduated oversight, and a 38-tool MCP server. Formally verified in Lean 4.