POST /v2/calls
rings one number now. A campaign keeps a list of people and
dials it for you, with calling hours, pacing and retries. With
always_on: true the campaign stays open,
and your system adds one person at a time as events happen.
Both run the same agents, cost the same per minute and send the same call.*
webhooks. What changes is who schedules the calls. With direct
calls your code does it, and with a campaign we do.
Which one to use
Adding a person to an always-on campaign is one request, the same as placing a
direct call. If you aren’t sure which to use, start with the campaign.
How they compare
A refused direct call and a rejected campaign row both appear in
Refused requests. Once your company is live, its owners also get
an email when one keeps repeating.
Space retries by hours
Across the platform, a second attempt after an unanswered call connects about 24% of the time when it comes within 15 minutes. When it comes one to three hours later, about 33% connect. Setre_attempt_period_secs to 7200 (two hours) with a retry_count of 1
or 2. If your customers pick up more at some
hours of the day, add retry_slots: up to 4 {start, end} ranges, each inside
slots, and retries ring only inside them. First calls are never held back by
retry_slots, and neither is a call placed again after a failure on our side.
Move from direct calls to an always-on campaign
You create the campaign once. After that, eachPOST /v2/calls becomes a
POST /v2/campaigns/{id}/contacts with one contact.
Step 1: Create the campaign once
Create it, start it, and keep its id in your configuration.- cURL
- Python
- Node.js
- Set
end_dateas far ahead as the campaign should stay open. Running out of contacts never ends an always-on campaign. - Calling hours in India must lie inside 09:00 to 21:00 IST.
budget_paiseis optional. On an open campaign it counts everything the campaign has ever spent, so treat it as a ceiling you raise from time to time, or leave it out and rely on the wallet.
Step 2: Add each event as a contact
Where your code placed a call, add a contact instead. Give it your ownid,
such as the cart or order id. Sending the same id again is safe: it counts in
contacts_duplicate and rings nobody, so you can retry a request that timed out
without a second call. A new cart for the same phone number gets a new id and
is called.
- cURL
- Python
- Node.js
200 OK
The contact is called straight away when the calling window is open, and when
it next opens otherwise. If the customer finishes the purchase first,
cancel the contact so nobody is called about
it.
Step 3: Match webhooks to your records
Every call of the campaign sends the usualcall.* events to the campaign’s
webhook_url. Each event has data.call.campaign_id, data.call.contact_id
and your metadata in data.call.metadata. With final_results on, which is
the campaign default, each call also ends with one
call.processed that has the transcript and the
after-call results.
Do this work after you have verified the signature
and answered 200:
- Python
- Node.js
db stands for your own database. A contact can have several calls, one for
each attempt, and each carries the same metadata. Keep the latest, or read the
contact’s state from List contacts: exhausted
means it used every attempt and never connected.
Step 4: Watch it
- Alert on
campaign.pausedwith apause_reason. An open campaign that pauses for money stops calling until you add credit and resume it. - Read Refused requests for rejected rows, or watch
contacts_rejectedin your own code. - Pause the campaign when you need calls to stop for a while. New contacts are still accepted and wait their turn.
When to keep direct calls
KeepPOST /v2/calls where a person is waiting for the phone to ring, for
browser and Realtime sessions, and for test calls. For those, send an
Idempotency-Key, check every answer, and alert on 4xx.
Related
Campaigns
Always-on campaigns, the contact schedule and every campaign setting.
Calls
Direct calls, the call queue on Mirai numbers and variable limits.
Refused requests
Every refused call and rejected contact, with the fix.
Phone numbers and pools
Spread calls over several numbers at a pace each can keep.