Conversations via Webhooks
The simplest way to run a conversation with Phonic is via webhooks — start a conversation with a single function call, and let Phonic orchestrate telephony for you.
This guide walks through your first webhook conversation, then covers two more advanced features. The example code is available here and here.
1. Install the SDK
See TypeScript SDK or Python SDK for more on the client.
2. Initialize the client
dotenv (npm install dotenv / pip install python-dotenv) to load the API key from .env.local.3. Create an agent
Let’s create an agent and assign it a random phone number.
You should see now my-first-agent on the Agents page.
4. Make an outbound call
Let’s make the agent call you. Specify your phone number, the agent name, and a welcome message:
Now, pick up the phone and chat with your agent!
5. Make an inbound call
Grab the agent’s phone number on the Agents page, and give it a call!
Agent configuration endpoint
Typically, when you create an agent with Phonic you specify default values for its behavior, such as its welcome message and system prompt. With the agent configuration endpoint, you have the option at the start of every conversation to update your agent with conversation-specific information.
This is primarily useful for inbound calls; for example, your endpoint can look up the inbound caller in your CRM and populate your welcome message with the caller information.
At the start of every conversation, Phonic sends a POST request to your endpoint, and your endpoint returns configuration overrides for that conversation. See the Agent configuration endpoint reference for the full request and response payload shapes.
Implementing your configuration endpoint is easy:
Post-call analysis endpoint
Upon the completion of each conversation, you can report conversation information, such as the full transcript, system prompt, and start/end timestamps. Implementing this is also easy: