Phonic
Build, test, and operate voice agents on the Phonic platform using the phonic SDK (npm and PyPI) or REST API. Use when the project or request involves Phonic - creating Phonic agents, placing or receiving calls through Phonic, browser speech-to-speech via Phonic, Phonic tools, webhooks, or conversation analysis, or attaching MCP servers to a Phonic agent. Do NOT use for non-Phonic voice platforms or SDKs, generic text-to-speech or transcription tasks, or building standalone MCP servers.From its SKILL.md
npx -y skills add Phonic-Co/skills --skill phonicAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
12.2 KB, as published. Nobody here has run it
Building voice agents on Phonic
SDKs: npm install phonic / pip install phonic. Entry points: new PhonicClient({ apiKey }) (Node), Phonic(api_key=...) / AsyncPhonic(...) (Python). REST base: https://api.phonic.ai/v1 with Authorization: Bearer $PHONIC_API_KEY. Always use the .ai domain for API and docs URLs — phonic.co addresses still resolve for backward compatibility, but all new code should use phonic.ai.
Fetch live docs rather than from memory: use the index at llms.txt. For the REST API, see openapi.json. For the WebSocket protocol, see asyncapi.json. If an endpoint does not appear in these docs, it doesn't exist, do not invent one.
Choosing a conversation surface
- Outbound phone call:
client.conversations.outboundCall({ to_phone_number, config }) - Inbound phone number: create/update the agent with
phone_number: "assign-automatically" - Voice in a browser or mobile app: direct STS WebSocket
wss://api.phonic.ai/v1/sts/ws?session_token=... - Bridge your own telephony/audio server-side:
client.conversations.connect() - Watch a live conversation (read-only):
wss://api.phonic.ai/v1/conversations/{id}/live/ws
Mistakes to avoid when picking:
- Don't open the browser STS socket to place a phone call — phone calls are one API call (
outboundCall); the STS socket streams a user's microphone. - Don't relay browser audio through your own server on the way to Phonic — it works, but adds a network hop of latency to every utterance; browsers connect directly using a session token. The session-token flow exists because an API key can't live in a browser; your own server holds the key, so server-side code uses
conversations.connect()directly and never needs session tokens. - Don't confuse the two WebSockets:
sts/wsis the live voice conversation;conversations/{id}/live/wsis a read-only monitoring feed (conversation-updated/conversation-endedevents only) — it cannot send audio or speak.
Config message
Every conversation begins with a config message:
- Minimal
configmessage:{ "type": "config", "agent": "my-cool-agent", "input_format": "pcm_44100", "output_format": "pcm_44100" }(pick the audio formats that match your use case). - For prototyping, it is possible to send the config without a named agent by carrying
system_prompt,welcome_message,voice_id,tools, and more inline (see the config schema in asyncapi.json). However, for long-term projects we recommend creating an agent to be able to track version changes, reuse the agent config across different conversation mediums, and avoid frequent redeployments. - Unknown fields and out-of-bounds values are rejected with
{"error": {"message": "Invalid parameters"}}plus aparam_errorsobject naming each offending field — read it, and treat a config rejection as fatal (a reconnect loop must not resend the same config). Field bounds are documented on the docs pages, but the servedasyncapi.jsonartifact currently omits constraint keywords (minimum/maximum/const) — a field looking unconstrained in the artifact doesn't mean it is.
Browser voice
This is the recommended pattern for building Phonic into a browser:
- Server side, exchange the API key for a session token with the SDK —
client.auth.createSessionToken({ ttl_seconds: 300 })(POST /v1/auth/session_token). The API key stays on the server — in Next.js, never put it in aNEXT_PUBLIC_*env var (those are compiled into client code). - The browser connects directly to
wss://api.phonic.ai/v1/sts/ws?session_token=<token>(token in the query string — browsers can't set WebSocket headers). Don't add a relay server in between; the direct connection is the supported, lowest-latency pattern. - Send the config message (see Config message above).
- Send and receive audio as base64 16-bit PCM
audio_chunkmessages. We recommend to use chunks of ~20ms (chunks longer than ≤40ms are rejected with error); note mic access requires a secure context — HTTPS or localhost. - The client can also send messages during the call:
add_system_message,update_tools_subset,set_external_id,mute/unmute,generate_reply(force a turn), andsay— schemas in asyncapi.json. These enable patterns like pushing app state into the conversation or a button that makes the agent speak. Note thatupdate_system_promptis deprecated; useadd_system_messageinstead. - Turn lifecycle comes from explicit events:
assistant_started_speaking/assistant_finished_speakinganduser_started_speaking/user_finished_speaking. When building a transcript UI, start a new assistant entry onassistant_started_speaking, not on the first audio chunk — trailingaudio_chunks (often with empty text) can arrive afterassistant_finished_speaking, and keying entries on chunks creates ghost transcript items. Interrupts are signaled byuser_started_speaking; flush queued playback there. - Long sessions need a reconnect loop (there's no browser SDK to do it for you): on a drop, retry with backoff and mint a fresh session token per attempt; classify failures first — network blips are retryable, auth failures (revoked key, expired grant) must stop retrying and surface to the user.
Reference implementations: phonic-web-demo (Next.js browser voice) and phonic-examples (quick start, webhooks, websocket conversations, websocket tools — TS and Python).
SDK surface
- Agents:
client.agents.create/get/list/update/upsert/delete.upsertis create-or-update by name (idempotent). Agents are identified by name. - Outbound calls:
client.conversations.outboundCall(...)— greeting goes inconfig.welcome_message. - Server audio bridge:
client.conversations.connect()(context manager in Python:with client.conversations.connect() as socket: for message in socket: ...). - Tools:
client.tools.create(...), then attach by name in agent configtools: [...].
Tools
Tool types (webhook, websocket, context, built-in transfers, MCP), reserved parameter names, and each type's request/response contract are documented in the tools docs — fetch the page for your tool type before implementing.
- Tool outputs must include every identifier a later tool call needs as a parameter (e.g. return the
job_idyourupdate_jobtool expects) — the agent can only pass along values it has been given. - Tools can be defined inline in the STS config (no pre-created tool):
tools: [{ "type": "custom_websocket", "execution_mode": "sync", "tool_schema": { "type": "function", "function": { ..., "strict": true } } }]— thestrict: trueinside the function schema is required. - If you bridge audio server-side, never do blocking I/O in the audio send/receive loop — periodic multi-second stalls in agent audio are almost always blocking code in the bridge.
Transfers
- Transfer to a human is a built-in tool (
built_in_transfer_to_phone_number, target number in the tool config) attached to the agent — don't hand-roll Twilio call control. - Targets are preconfigured per transfer tool; the agent chooses among configured transfer tools and cannot dial an arbitrary number returned by another tool mid-call.
- Reading outcomes from conversation data: the transfer tool's output body has
connected: true|false—truemeans the callee leg answered (human or voicemail);falsemeans the transfer failed and the agent tells the caller. - Voicemail detection: set
detect_voicemail: trueon the transfer tool (tools API). The agent then listens to the answered leg and a system tool call records the judgment —tool_transfer_hit_voicemailortool_transfer_successful(= judged human). Without voicemail detection,tool_transfer_successfulfires immediately on connect and means only "connected". Detection requires the bridged transfer mode (use_agent_phone_number: true, the default) — a SIP REFER handoff leaves the call and can't listen. - The
conversation.transferredwebhook carriestransferred_to,call_info, and the conversation items up to the transfer — the pre-transfer transcript arrives with the event.
Webhooks and post-call steps
Webhooks can indicate conversation progress: conversation.ended, conversation.analysis, conversation.transferred. A typical post-call pipeline looks like:
conversation.endedfires when the call ends — log the outcome and kick off your downstream steps from here.conversation.analysisfollows with performance metrics: itsconversationpayload carrieslatencies_msandinterruptions_count(also available viaGET /v1/conversations/{id}/analysis). It does not contain extraction results.- Extractions turn the transcript into typed fields you define. Create an extraction schema, then run it per conversation with
POST /v1/conversations/{id}/extractionsand read results with the matching GET — typically from yourconversation.endedhandler. Extractions read the transcript, so they fail if transcripts are deleted; run them promptly if you have a retention policy. - Eval prompts grade calls against plain-language criteria. Create them at the project level (
name+ a criterion like "the assistant made the required disclosure"), evaluate a conversation via the conversation-evals endpoint, and read results per conversation or listed across the project — useful for compliance checks and QA queues.
Prompting voice agents
Voice prompts differ from chat prompts (speech formatting, silence handling, naturalness) — use the prompting guide.
Operations
- Projects organize agents/tools/numbers within a workspace; use one project per tenant/product line rather than a new workspace. API keys are workspace-level.
- Rate limits: see the rate limits page; high-volume outbound campaigns need client-side concurrency caps.
- Observability: per-call outcomes via the webhook events above; live read-only monitoring via the live WebSocket; audit logs.
Best practices for shipping to prod
These patterns may not be necessary to get a working demo, but are good practices for handling customer traffic, especially as you scale:
- Webhook receivers — Phonic delivers webhooks via svix, which retries, so the same event can arrive more than once (and concurrently). Build for that:
- Verify the svix signature before touching the body.
- Return 2xx immediately; do slow work (DB writes, API calls) in the background.
- Store each event id durably (DB unique constraint, not process memory) and skip events you've already processed.
- For side effects that must happen exactly once (paging someone, charging a card): durably mark the work "started" before doing it and "done" after, and on startup retry anything started-but-never-finished. The before-mark stops a redelivery from repeating the side effect; the startup retry stops a crash from silently dropping it.
- Server-side reconnects The SDK's
conversations.connect()reconnects automatically on abnormal disconnects and resumes the same conversation — opt in withreconnectConversationOnAbnormalDisconnect: true(client or per-connect option). - Campaign/batch dialers: claim each number (durable in-progress state) before dialing and design the claim so a second runner instance can't grab it too — per-run completion state alone doesn't prevent two processes from double-dialing.