-
Notifications
You must be signed in to change notification settings - Fork 2
Integration with Calls API
To use our SDK, you'll first need to read the following tutorials as a prerequisite to this one:
Also, before integrating with Calls API, you can read the Calls product documentation to get a better overview of this product.
To be able to use the Calls API, you'll first have to do some additional setup:
- Create your own backend application which can listen on
Calls webhooks
- Have at least one
Calls application
created with receive and event URL set to point to the aforementioned backend application - Have your backend application call the Call API depending on the
Calls events
and your own business logic
With the Calls API, you have the ultimate freedom to implement your own business logic when handling calls and can use Web and In-App Calls to implement complex use cases much easier.
Some more intricate use cases include:
- Transferring call participants to conferences with multiple participants mid-call
- Managing participants in a call or conference by your own backend application
- Establish calls with participants from different endpoints simultaneously (WEBRTC, SIP, PHONE)
- Have full control over incoming calls through your backend application
- Play text-to-speech or audio files during calls to participants
Before starting to use the Calls API with Web and In-App Calls, you'll need to create your own backend application and host it in your environment or in the cloud.
Your backend application will be represented on our platform as a Calls application, which is a logical entity containing the required webhooks exposed by your application. The event and receive webhooks will receive events via HTTP from Infobip's platform, which you can use to properly control your voice and video scenarios. The application will also include the list of real-time events to which your application is subscribed.
The following image provides a clear overview of your application integrated into the whole ecosystem.
To use your backend application as mentioned earlier, you will need to create the Calls application logical entity through our Calls API.
This Calls application will be identified by the applicationId
unique identifier on our platform,
which you'll use when sending Calls API requests and setting up calls to define which application is interacting with the system.
To create your Calls application on Infobip's platform, you can read our Calls API documentation for the
/calls/1/applications/
endpoint.
When working with the Calls API it is up to you to develop your voice and video scenarios with the help of your backend application. Your use cases can be as simple or as complex as you need them to be.
Keep in mind that any Calls API method you call through our SDK will trigger an event on your application's event webhook, and vice versa, any HTTP request you send to the Calls API platform from your application will trigger an event on your web application (through our SDK).
To make a call towards your backend application,
the application using our Javascript SDK should call the callApplication
method with the correct applicationId
.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
When this code is triggered, your backend application will receive the CALL_RECEIVED
event on its event webhook
(if you subscribed to this event whilst creating the Calls application).
With this information, your application can process it, and act accordingly through the Calls API.
You can also use the Calls API to initiate a call to a certain user by using the
/calls/1/calls
endpoint.
When receiving such a call on your web application as an incoming call, you can use the SDKs accept
method to answer the call.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.on('incoming-application-call', (incomingApplicationCallEvent) => {
incomingApplicationCallEvent.incomingCall().accept();
});
Shortly after answering the call, you'll receive a CALL_ESTABLISHED
event on your event webhook (if you subscribed to this event).
At this moment, the call has been established with your application.
Whenever you want to hang up the call, as earlier, you can do it both from the SDK and through the Calls API.
From the Calls API side, this is done by sending an HTTP POST request to our platform to the
/calls/1/calls/:id/hangup
endpoint.
This will of course trigger a HANGUP
on the SDK side, to inform you that the call has been hung up.
From the SDK side, you can use the hangup
method to perform the hang up action.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
applicationCall.on(ApplicationCallApiEvents.ESTABLISHED, _ => {
applicationCall.hangup();
});
This will trigger the CALL_FINISHED
event, which your event webhook will receive (if you have subscribed to this event when creating the application).
To check out which methods you can use through our SDK to control application calls,
you can take a look at the ApplicationCall
class.
To find a list of all the Calls API methods you can use, you can reference our Calls API documentation.
- InfobipRTC
- Call
- IncomingCall
- OutgoingCall
- CallOptions
- CallOptionsBuilder
- RecordingOptions
- RecordingOptionsBuilder
- VideoOptions
- VideoOptionsBuilder
- CameraOrientation
- CallPhoneNumberOptions
- CallPhoneNumberOptionsBuilder
- DeclineOptions
- DeclineOptionsBuilder
- CallStatus
- HangupStatus
- User
- IncomingCallEvent
- Conference
- ConferenceOptions
- ConferenceOptionsBuilder
- ConferenceUser
- NetworkQuality
-
ApplicationCall
-
IncomingApplicationCall
-
ApplicationCallApiEvents
-
IncomingApplicationCallEvent
-
Participant
-
State
-
Media
-
Audio
-
Endpoint
-
EndpointType
-
WebrtcEndpoint
-
PhoneEndpoint
-
SipEndpoint
-
AudioOptions
-
AudioOptionsBuilder
-
AudioFilter
-
AudioFilterFactory
-
VideoFilter
-
VideoFilterFactory