Prerequisites
Before receiving calls, you need:- A phone number assigned to your application
- A webhook configured for the
calls.initiatedevent
How It Works
- A caller dials your Chirp phone number
- Chirp creates a call and sends a
calls.initiatedwebhook to your application - Your application responds with a call command (answer, reject, or send to voicemail)
- Chirp executes the command and continues the call flow
Webhook Payload
When an inbound call is received, Chirp sends a POST request to your webhook URL:calls.initiated Webhook Payload
Payload Fields
event - The event type (calls.initiated)
eventId - Unique event identifier for idempotency
timestamp - ISO 8601 timestamp of when the event was generated
data.call.id - Unique call identifier, used to send commands
data.call.direction - Always inbound for received calls
data.call.from - The caller’s phone number or identifier
data.call.to - Your Chirp phone number that received the call
data.call.fromChannel - Channel of the caller (pstn, webrtc, or whatsapp)
data.call.toChannel - Channel of the recipient (pstn, webrtc, or whatsapp)
data.call.livekitRoomName - LiveKit room name (present when channel is webrtc)
data.call.metadata - Custom metadata (if any)
data.app.id - The application that owns the call
Answering a Call
To answer an inbound call, send ananswer command:
Answer a Call
Rejecting a Call
To reject an inbound call, send areject command with an optional reason:
Reject a Call
Sending to Voicemail
To send an inbound call directly to voicemail:Send to Voicemail
Default Behavior
If your application does not respond to thecalls.initiated webhook within 30 seconds, Chirp uses the default behavior configured in your application’s calling settings. This can be:
- Voicemail - The call is sent to voicemail automatically
- Reject - The call is rejected with a busy signal
Example: Webhook Handler
Here is a complete example of a webhook handler that answers calls during business hours and sends them to voicemail otherwise:Inbound Call Handler