Skip to main content

Official AgentMail integration for AutoGen/AG2

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autogen_agentmail-0.1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autogen_agentmail-0.1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file autogen_agentmail-0.1.0.tar.gz.

File metadata

  • Download URL: autogen_agentmail-0.1.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for autogen_agentmail-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bad3a4cb08bb878b835cda95a67d44f08fbbab5a06292ac496dc35c8c79c43f6
MD5 aeaaac1ffcd7dfb3d78b8e573814188a
BLAKE2b-256 19ca682aefa1acd3695c984afb696ff373c8b7cec6111357a46678dc942081da

See more details on using hashes here.

File details

Details for the file autogen_agentmail-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for autogen_agentmail-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27d03edf0b1de4d13ef8e9cb683ea4cd2842531f1f0ad260ad211c316bf51916
MD5 df0747a2a6f01ed1bfd371490e3999ca
BLAKE2b-256 c08887021db9401c9d86471f9387b4c64c11577d930baf9fcf9792a0ae7ccb80

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page