Short answer
Installcommune-mail and openai-agents. Wrap your Commune calls in @function_tool decorated functions. Pass those functions to Agent(tools=[...]) and the agent decides when to call them.
Step 1: Install and configure
.env:
Step 2: Define email tools
Wrap each Commune operation in a@function_tool function. The SDK uses the docstring and type annotations to describe the tool to the model.
Step 3: Create the agent
Inject the inbox email address into the system prompt so the agent knows its own identity.Step 4: Run the agent
read_inbox first, then get_thread on any message that needs context, then send_email to reply. It chains those calls on its own — you don’t orchestrate the order.
Step 5: Handle inbound replies
Register a webhook in your Commune dashboard so replies trigger your agent automatically.Related
OpenAI Agents SDK and Email
Deeper walkthrough with a full outbound SDR example using the OpenAI Agents SDK.
Inboxes
Create and manage agent inboxes with per-inbox reputation and reply routing.
Webhooks
Configure inbound email delivery, retry behavior, and signature verification.

