API to send voice call via VoIP to multiple recipients
Back to Articles
Tutorial VoIP SIP API Reference Development Howto

API to send voice call via VoIP to multiple recipients

May 2, 2018 4 min
Aivis Olsteins

Aivis Olsteins

This post continues to discuss API to send voice calls via VoIP and play prerecorded or Text to Speech (TTS) messages. In previous article we discussed sending calls to one recipient. Now, let's say we need to serve single voice message located at this address: http://server.domain.com/voices/hello.wav to multiple users. You can send multiple requests to the API with changing to addresses, but there is a simplest way to o it. It is both faster, and can be reused later if you need to change message to be sent. Here is how we will send the API request:

POST /voice/call/play

{
  "recipients":
    [
      {
    "to": "sip:123456@192.168.1.1:5060"
},
  {
    "to": "sip:alice@192.168.1.1:5060"
},
  {
    "to": "sip:bob@192.168.1.1:5060"
},
  {
    "to": "sip:charlie@192.168.1.1:5060"
},
  {
    "to": "sip:999777@192.168.1.1:5060"
},
  "from": "me",
  "playlist":
    [
      {
        "play": "http://server.domain.com/voices/hello.wav"
      }
    ]
}

 

As you can see, the request is similar as in case with one recipient, with the difference that to fields are listed in the recipients field. The API will then reply to us with the response:

{
"code": 0,
"status": 200,
"data": "accepted",
"request_id": "62395c48-5ebf-48f4-8cce-fa6e22d76577"
}

What happens behind the scene, is that system now took our request, and put all recipients in the queue. Depending on the size of the request and available resources, it might take some time while all users are called. Therefore the status report might not be available immediately. Also, it can be very large if the number of recipients is big. Let's call the status API and see what we get:

GET /voice/call/status/62395c48-5ebf-48f4-8cce-fa6e22d76577

And the system replies with something like this:

{
"code": 0,
"status": 200,
"data": "accepted",
"request_id": "5182ebda-4a5f-4a0d-9725-5eaa06cddea4",
"report":
{
"id": "55d9c8c5-e86f-40e7-a902-a07e176f5511",
"location": "/reports",
"status": "ready",
}
}

Instead of call information we now got a reference to report which will be generated after calls are completed. This is due to fact that these reports might take longer time to be created, and can be very large in terms of size, again because it is possible to call many users at the same time. The status field shows if report is ready. When it it ready, we send new API call to get the report itself:

GET /report/55d9c8c5-e86f-40e7-a902-a07e176f5511

The system will now send us full call report with all details of the calls made:

{
"code": 0,
"status": 200,
"data": "accepted",
"request_id": "55d9c8c5-e86f-40e7-a902-a07e176f5511",
"records":
[
{
"type": "voice",
"id": "838a8fb3-3146-4c57-8964-05d95ac768e6",
"result": "completed",
"request_time": "2018-05-02 12:15:32",
"to": "sip:123456@192.168.1.1:5060",
"from": "me",
"setup_time": "2018-05-02 12:15:32",
"connect_time": "2018-05-02 12:15:45",
"disconnect_time": "2018-05-02 12:16:02",
"disconnect_cause_code": "200",
"disconnect_cause_text": "OK",
"duration": 17,
"answered": true
},
{
"type": "voice",
"id": "7d365d1d-0c29-4438-b66d-26fa9ebebfef",
"result": "completed",
"request_time": "2018-05-02 12:15:32",
"to": "sip:alice192.168.1.1:5060",
"from": "me",
"setup_time": "2018-05-02 12:15:32",
"connect_time": "2018-05-02 12:15:50",
"disconnect_time": "2018-05-02 12:16:05",
"disconnect_cause_code": "200",
"disconnect_cause_text": "OK",
"duration": 15,
"answered": true
},
........
{
"type": "voice",
"id": "b9e8ea96-8dea-4878-bc2f-3f2014026532",
"result": "completed",
"request_time": "2018-05-02 12:15:32",
"to": "sip:999777@192.168.1.1:5060",
"from": "me",
"setup_time": "2018-05-02 12:15:32",
"disconnect_time": "2018-05-02 12:16:42",
"disconnect_cause_code": "486",
"disconnect_cause_text": "User Busy",
"duration": 0,
"answered": false
}
]
}

The API now returns a report with full details of each call as in the case of single call. Note that each record contains an ID which relates to the individual call. And indeed, you can also query each call individually:

GET /voice/call/status/b9e8ea96-8dea-4878-bc2f-3f2014026532

and get the same result:

{
"code": 0,
"status": 200,
"data": "accepted",
"request_id": "b9e8ea96-8dea-4878-bc2f-3f2014026532",
"record":
{
"type": "voice",
"result": "completed",
"request_time": "2018-05-02 12:15:32",
"to": "sip:999777@192.168.1.1:5060",
"from": "me",
"setup_time": "2018-05-02 12:15:32",
"disconnect_time": "2018-05-02 12:16:42",
"disconnect_cause_code": "486",
"disconnect_cause_text": "User Busy",
"duration": 0,
"answered": false
}
}

Now when we know how to send calls to multiple recipients, we can proceed to next part where we will discuss advanced routing and SIP parameter settings via API.

 

Share this article

Aivis Olsteins

Aivis Olsteins

An experienced telecommunications professional with expertise in network architecture, cloud communications, and emerging technologies. Passionate about helping businesses leverage modern telecom solutions to drive growth and innovation.

Related Articles

The Commitment Economy: Why Voice AI Bookings Must Be Integrated, Not Just Conversational

The Commitment Economy: Why Voice AI Bookings Must Be Integrated, Not Just Conversational

AI can promise a booking, but what about the broken promise? Learn why systemic integration, Accuracy Rate, and System Sync define the real test of Voice AI reliability

Read Article
Beyond the Dial Tone: 3 Metrics That Define Outbound AI Success

Beyond the Dial Tone: 3 Metrics That Define Outbound AI Success

Outbound AI requires a new scorecard. Learn the 3 metrics (Connection Rate, Engagement Quality, and Conversion Impact) that measure pipeline movement, not just call volume

Read Article
The New AI Scorecard: How to Measure Campaign Effectiveness Beyond "Call Volume"

The New AI Scorecard: How to Measure Campaign Effectiveness Beyond "Call Volume"

Stop guessing with 'Call Volume'. Discover the 3-Layer Framework for measuring Voice AI success: Goal Completion Rate (GCR), Sentiment Drift, and Knowledge Retrieval. Turn phone calls into structured marketing data

Read Article
What Happens to Metrics When "Hold Time" Hits Zero?

What Happens to Metrics When "Hold Time" Hits Zero?

Does Voice AI just save money? No. Discover the "CSAT Paradox" and how zero hold time improves revenue, lead capture, and team morale simultaneously.

Read Article

SUBSCRIBE TO OUR NEWSLETTER

Stay up to date with the latest news and updates from our telecom experts