Add customer support email agent using Commune#2481
Add customer support email agent using Commune#2481shanjairaj7 wants to merge 3 commits intoopenai:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f3d3822543
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| @@ -0,0 +1,621 @@ | |||
| { | |||
There was a problem hiding this comment.
Register new notebook in registry.yaml
This commit adds a new notebook at examples/agents_sdk/email_agent_with_commune.ipynb, but there is no corresponding entry for that path in registry.yaml (repo search shows no match). Per this repo’s contribution rules in AGENTS.md, new content must be registered so it is published; without that metadata, this example will not be included by the site generator and is effectively invisible.
Useful? React with 👍 / 👎.
| "def execute_tool_call(tool_call) -> str:\n", | ||
| " \"\"\"Execute a single OpenAI tool call and return the result as a JSON string.\"\"\"\n", | ||
| " name = tool_call.function.name\n", | ||
| " args = json.loads(tool_call.function.arguments)\n", |
There was a problem hiding this comment.
Guard JSON parsing of tool arguments
execute_tool_call calls json.loads(tool_call.function.arguments) before entering the try block, so malformed tool arguments raise JSONDecodeError and terminate the run instead of being returned as a tool-level error. In practice, one bad tool-call payload can crash the entire support workflow during multi-turn processing.
Useful? React with 👍 / 👎.
|
Addressed the two Codex review items: P0 — registry.yaml (commit P2 — JSON parsing guard (commit |
What this notebook covers
This notebook shows how to build a customer support email agent using the OpenAI Python SDK with GPT-4o function calling and Commune — a programmable email and SMS API built for AI agents.
The notebook lives in
examples/agents_sdk/because it demonstrates a complete, production-oriented agentic workflow: multiple tools, multi-turn reasoning, error handling, and a polling loop suitable for deployment.Use case
A SaaS company points a Commune inbox at their support address. The agent reads new tickets, classifies them (billing / technical / feature-request), drafts empathetic replies, sends them via the Commune API, and SMS-escalates P0 issues to an on-call phone number — all without human intervention.
What readers learn
{"type": "function", ...}formatfinish_reason == "tool_calls", executing eachtool_call, and returning{"role": "tool", ...}messagesWhy it's valuable
Support inbox automation is one of the highest-ROI use cases for function-calling agents but is underrepresented in the cookbook relative to its real-world prevalence. This recipe gives developers a complete, working starting point that handles the email infrastructure (via Commune) so the focus stays on the agent logic.
Technical details
openaiPython SDK directly — no LangChain, no frameworkcommune-mailPython package (pip install commune-mail)gpt-4o(also compatible withgpt-4o-minifor cost-sensitive deployments)commune_client.sms.send()