Keep call quality high with these neat tricks!
Catapult, one of Bandwidth’s communications API, is a straightforward REST API to send/receive text-messages/multimedia-messaging and phone calls. Use-cases are all over the place! On-demand services (get a car, order some food, hire a dog walker), call tracking (does the billboard or newspaper ad perform better), to customer service (keep track of customer interactions) have all benefited from using similar APIs. In fact, regardless of your application, you should probably start thinking about how your customers interact with you.
We have maintained that we offer superior quality by offering more direct control over call flow. Here are a few best practices to ensure you’re getting the most out of Bandwidth.
Scenario One: Two Outbound Calls
To create two outbound calls from Bandwidth and connect them together: Create the bridge first, and pass the bridgeId when creating the calls.
Step 1: Create a new bridge and save the bridgeID
POST /v1/users/{userId}/bridges
{
“bridgeAudio”: “true”
}HTTP/1.1 201 Created
Location: /v1/users/{userId}/bridges/{bridgeId}
Step 2: Create the first call using the bridgeID
POST /v1/users/{userId}/calls
{
“from”: “{fromNumber}”,
“to”: “{toNumber}”,
“bridgeId” : “{bridgeId}”
}HTTP/1.1 201 Created
Location: /v1/users/{userId}/calls/{callId}
Step 3: Create the second call using the same bridgeID
POST /v1/users/{userId}/calls
{
“from”: “{fromNumber}”,
“to”: “{toNumber}”,
“bridgeId” : “{bridgeId}”
}HTTP/1.1 201 Created
Location: /v1/users/{userId}/calls/{callId}
Step 4: Wait, calls will be bridged automatically as soon as both answer
Scenario 2: Incoming call is forwarded to another phone number
To best forward a call: Answer the call, create a bridge with the inbound callId then create the outbound call with the bridgeId.
Step 1: Save the callId from the incomingCall event
POST http://[External server URL]
{
“eventType”:”incomingcall”,
“from”:”+13233326955",
“to”:”+13865245000",
“callId”:”{callId}”,
“callUri”: “https://api.catapult.inetwork.com/v1/users/{userId}/calls/{callId}",
“callState”:”active”,
“applicationId”:”{appId}”,
“time”:”2012–11–14T16:21:59.616Z”
}
Step 2: Create a bridge with the saved callId
POST /v1/users/{userId}/bridges
{
“bridgeAudio”: “true”,
“callIds”: [“{callId1}”]
}HTTP/1.1 201 Created
Location: /v1/users/{userId}/bridges/{bridgeId}
Step 3: Create the outbound call with the bridgeId
POST /v1/users/{userId}/calls
{
“from”: “{fromNumber}”,
“to”: “{toNumber}”,
“bridgeId” : “{bridgeId}”
}HTTP/1.1 201 Created
Location: /v1/users/{userId}/calls/{callId}
Step 4: Wait, calls will be bridged automatically as soon as both answer
Scenario 3: Forward to multiple phones, connect the first one to answer
In the ‘simulring’ use case, everything is essentially the same as scenario 2, except the field: ‘registerBridgeId’ is used when creating the outbound calls.
Step 1: Save the callId from the incomingCall event
POST http://[External server URL]
{
“eventType”:”incomingcall”,
“from”:”+13233326955",
“to”:”+13865245000",
“callId”:”{callId1}”,
“callUri”: “https://api.catapult.inetwork.com/v1/users/{userId}/calls/{callId}",
“callState”:”active”,
“applicationId”:”{appId}”,
“time”:”2012–11–14T16:21:59.616Z”
}
Step 2: Create a bridge with the saved callId
POST /v1/users/{userId}/bridges
{
“bridgeAudio”: “true”,
“callIds”: [“{callId1}”]
}HTTP/1.1 201 Created
Location: /v1/users/{userId}/bridges/{bridgeId}
Step 3: Create any number of outgoing call using the bridgeID to fill the registerBridgeId parameter
POST /v1/users/{userId}/calls
{
“from”: “{fromNumber}”,
“to”: “{toNumber}”,
“registerBridgeId” : “{bridgeId}”
}HTTP/1.1 201 CreatedLocation: /v1/users/{userId}/calls/{callId}
Step 4: Wait for the first answer event from all the created calls
POST http://[External server URL]{
“eventType”:”answer”,
“from”:”+15753222083",
“to”:”+13865245000",
“callId”:”{callId2}”,
“callUri”: “https://api.catapult.inetwork.com/v1/users/{user-id}/calls/{call-id}",
“callState”:”active”,
“time”:”2012–11–14T16:28:31.536Z”
}
Step 5: Update the bridge with the new callId
POST /v1/users/{userId}/bridges/{bridgeId}
{
“callIds”: [“{callId1}”,”{callId2}”]
}HTTP/1.1 201 Created
Location: /v1/users/{userId}/calls/{bridgeId}
Step 6: Calls are bridged
And that’s it!
Following these tips will ensure you get the best possible call quality.