Skip to main content

PatterTool

PatterTool exposes a live Patter instance as a single make_phone_call tool that any text-based agent framework can register and dispatch. The agent picks up the phone, Patter runs a short conversation against the caller, and the tool returns a JSON envelope with the call ID, status, transcript, cost, and metrics. This complements the bring-your-own-agent pattern (serve({ onMessage: 'https://...' })) with the inverse pattern — phone-as-tool — exposing any Patter-built voice agent as an MCP-compatible tool that other agent frameworks can call as if it were a local function.

Quickstart

Schema exporters

PatterTool ships three schema exporters with identical wire shape (parameter JSON-schema + result envelope), so a customer can switch frameworks without re-mapping fields.
When a framework expects a JSON-string handler (Hermes, MCP), use tool.hermesHandler() — it executes the call and returns either a JSON-string result or {"error": "..."}.

Tool arguments (JSON-schema)

Identical across all three exporters:

Result envelope

Concurrency & timeouts

  • start() is idempotent — call it from your bootstrap, or let execute() boot it lazily.
  • Concurrent execute() calls are serialised through a dial mutex so the per-call_id Future never races.
  • max_duration_sec is enforced via setTimeout; on timeout the tool hangs up the call and returns status: "timeout".

Production deployment

PatterTool boots phone.serve() once. Make sure the Patter instance was constructed with a stable webhook hostname in webhookUrl — never a tunnel — because Twilio/Telnyx need a long-lived HTTPS URL. For local development, use tunnel: true on the Patter constructor and let it spawn a cloudflared. For production deploys (Fly.io / Cloud Run / Fargate behind ALB), set webhookUrl to your public hostname and disable the tunnel.

Examples

Runnable integration examples live in their own repo (see the Patter examples organization):
  • hermes_phone_tool.py — drop-in tools/patter.py for Hermes Agent.
  • openai_assistant_phone_tool.ts — minimal OpenAI Assistants run dispatching the tool.
  • Pattern A vs Pattern B decision matrix in the example repo’s README.

What’s next

Tools

In-call tool calling (function calling within a Patter agent).

Agents

Configure the in-call agent that PatterTool wraps.