API References
This section contains what all calls related actions can be performed using JavaScript SDK.
Start a Call
This method start or initiate a new video/voice call. Video/Audio can be turned on/off later at user's level.
channelizeCall.Call.startCall(data, options, function (err, call) {
});
Function Params
data can be a user id or an array of user ids or a javascript object having below properties.
Data Properties
Name | Type | Required | Description |
---|---|---|---|
id | string | no | The unique ID of the call. |
type | string | no | The type of call. Allowed values are voice and video and default value is voice . |
title | string | no | The name of the call. |
conversationId | string | no | The conversationId associated with the call. Admin messages will be sent to this associated conversation. |
members | array | yes | Specifies an array of user IDs to add to the call. E.g. ["20697", "18859"] |
createdAt | date object | no | The timestamp when the call was created. |
customType | string | no | Specifies the custom type of call which is used for grouping of calls. |
metaData | object | no | Some extra data of special calls. |
config | object | no | Specifies the config settings of the call. Config properties are described in a separate section below the data properties. |
Config properties
require_invite
Determines whether an invite should be mandatory for a user to join a call. By default, this will be true. You can set this false if you want anyone in your community to join a call.admin_messages
Determines whether admin messages should be sent to the associated conversation on certain call actions. By default, this will be true. Examples of admin messages are:Missed Call
,Call Rejected
,Call Completed - 40s
,Call Not Answered
etc. The text for these admin messages is customizable from the front end.
options represent WebRTC options and should be an object that can have below properties.
Options Properties
Name | Type | Required | Description |
---|---|---|---|
muteAudio | boolean | no | Specify if you want to start the call with audio muted. You can unmute the audio later. |
muteVideo | boolean | no | Specify if you want to start the call with video muted. You can unmute the video later. |
cameraId | string | no | Specify the camera device ID retrieved from the getDevices method. |
microphoneId | string | no | Specify the microphone device ID retrieved from the getDevices method. |
Callback Params
err
Indicates if there is an error. It will be null if there is no error.call
Indicates call's object.
Join/Accept Call
Once you have received an incoming call from a user or in any group, accept or join it using this method.
channelizeCall.Call.getCall(callId, function (err, call) {
if (err) return console.error(err);
call.join(options, function (err, res) {
});
});
Function Params
options represents WebRTC options and should be an object that can have below properties.
Options Properties
Name | Type | Required | Description |
---|---|---|---|
muteAudio | boolean | no | Specify if you want to join the call with audio muted. You can unmute the audio later. |
muteVideo | boolean | no | Specify if you want to join the call with video muted. You can unmute the video later. |
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Reject/Decline Call
You can also choose to reject the incoming call once it is received using this method.
channelizeCall.Call.getCall(callId, function (err, call) {
if (err) return console.error(err);
call.reject(function (err, res) {
});
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
End Call
This method triggers the action to end a call.
channelizeCall.Call.getCall(callId, function (err, call) {
if (err) return console.error(err);
call.end(data, function (err, res) {
});
});
Function Params
data is a JavaScript object having below properties.
Data Properties
Name | Type | Required | Description |
---|---|---|---|
duration | number | no | Specifies the duration to set for all the members while ending the call. If you do not pass duration, the duration for each member will be calculated using the joined timestamp. This parameter will be useful in the one-to-one call when the duration is the same for both the members and calculated from the time when both have joined the call. |
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Add/Invite Members Call
This method invites new members to the call in a group video or voice call. On the invite, the member will get notified and he can choose to join or reject the call.
channelizeCall.Call.getCall(callId, function (err, call) {
if (err) return console.error(err);
call.invite(memberIds, function (err, res) {
});
});
Function Params
This table lists all possible parameters this function supports.
Name | Type | Description |
---|---|---|
memberIds | array | Specifies an array of user IDs to invite to the call. E.g. ["20236", "20697", "19116"] |
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Send Invite Received Event
Once you have received the invite to join a group call you need to send an invite received status, so that ringing
status can be shown at the caller's end. The ringing
status will differentiate at the caller's end whether you received the call invite or you are unreachable.
channelizeCall.Call.getCall(callId, function (err, call) {
if (err) return console.error(err);
var busy = false;
call.sendInviteReceivedEvent(busy, function (err, res) {
});
});
Function Params
This table lists all possible parameters this function supports.
Name | Type | Description |
---|---|---|
busy | boolean | Specifies if the invited member is busy on another call or not. |
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Leave Call
Leaves a call.
channelizeCall.Call.getCall(callId, function (err, call) {
if (err) return console.error(err);
call.leave(function (err, res) {
});
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Remove Members
This method allows you to remove members from the call that is no longer required.
channelizeCall.Call.getCall(callId, function (err, call) {
if (err) return console.error(err);
call.remove(memberIds, function (err, res) {
});
});
Function Params
This table lists all possible parameters this function supports.
Name | Type | Description |
---|---|---|
memberIds | array | Specifies an array of user IDs to remove from the call. E.g. ["20236", "20697", "19116"] |
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
List Calls
This method allows you to retrieve the list of calls of a user.
let callListQuery = channelizeCall.Call.createcallListQuery();
// string - Specifies a comma-separated string of the unique calls IDs to retrieve. (Default: null)
callListQuery.ids = '0558701b-3c7b-45a1-80c3-8af7f0e98l659';
// string - Specifies a comma-separated string of one or more Caller IDs to filter the call logs. A caller is a user who initiates the call. (Default: null)
callListQuery.callerIds = '20697';
// string - Specifies the type of call. Allowed values are video and voice. (Default: null)
callListQuery.type = 'video';
// string - Specifies the result of the call. Allowed values are ongoing and completed. (Default: null)
callListQuery.result = 'completed';
// string - Specifies the conversation ID this call belongs to. It is required when call functionality is used in association with Channelize.io Chat. (Default: null)
callListQuery.conversationId = 'd0f71323-84e8-42bc-87a6-764ce874628a';
// string - Specifies the state of a login user in a call. Allowed values are invited, joined, missed, not_answered and completed. (Default: null)
callListQuery.state = 'missed';
// string - Specifies a comma-separated string of one or more custom types to filter the calls. Custom Types stores additional information for the call. (Default: null)
callListQuery.customTypes = 'custom-type';
// number - Specifies the minimum value of the call duration to restrict the search scope. (Default: null)
callListQuery.minDuration = 10;
// number - Specifies the maximum value of the call duration to restrict the search scope. (Default: null)
callListQuery.maxDuration = 80;
// string - Specifies the sorting criteria for the returned results. Allowed values are createdAt ASC && createdAt DESC. (Default: createdAt DESC)
callListQuery.sort = 'createdAt DESC';
// number - Specifies the number of results to return. (Default: 25)
callListQuery.limit = 25;
// number - Specifies the number of results you want to skip from the beginning. (Useful in Pagination) (Default: 0)
callListQuery.skip = 0;
callListQuery.list(function (err, calls) {
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.calls
Indicates the response which will be an array of call's object.
Get Calls Count
This method allows you to retrieve the count of calls of a user.
let callListQuery = channelizeCall.Call.createcallListQuery();
// string - Specifies a comma-separated string of the unique calls IDs to retrieve. (Default: null)
callListQuery.ids = '0558701b-3c7b-45a1-80c3-8af7f0e98l659';
// string - Specifies a comma-separated string of one or more Caller IDs to filter the call logs. A caller is a user who initiates the call. (Default: null)
callListQuery.callerIds = '20697';
// string - Specifies the type of call. Allowed values are video and voice. (Default: null)
callListQuery.type = 'video';
// string - Specifies the result of the call. Allowed values are ongoing and completed. (Default: null)
callListQuery.result = 'completed';
// string - Specifies the conversation ID this call belongs to. It is required when call functionality is used in association with Channelize.io Chat. (Default: null)
callListQuery.conversationId = 'd0f71323-84e8-42bc-87a6-764ce874628a';
// string - Specifies the state of a login user in a call. Allowed values are invited, joined, missed, not_answered and completed. (Default: null)
callListQuery.state = 'missed';
// string - Specifies a comma-separated string of one or more custom types to filter the calls. Custom Types stores additional information for the call. (Default: null)
callListQuery.customTypes = 'custom-type';
// number - Specifies the minimum value of the call duration to restrict the search scope. (Default: null)
callListQuery.minDuration = 10;
// number - Specifies the maximum value of the call duration to restrict the search scope. (Default: null)
callListQuery.maxDuration = 80;
callListQuery.count(function (err, res) {
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates response object having count as property.{ "count": 15 }
Get a Call
Retrieves information about a call.
channelizeCall.Call.getCall(callId, function (err, call) {
});
Function Params
This table lists all possible parameters this function supports.
Name | Type | Description |
---|---|---|
callId | string | The unique ID of the call to retrieve. |
Callback Params
err
Indicates if there is an error. It will be null if there is no error.call
Indicates call's object.
Call Model Object
A call's object can be retrieved either using get call method or start call method.
{
"id": "2b296450-8b83-4963-896d-4f7cec379104",
"type": "video",
"callerId": "20697",
"conversationId": null,
"createdAt": "2020-06-09T15:55:12.354Z",
"endedAt": "2020-06-09T15:56:06.275Z",
"result": "completed",
"title": null,
"customType": null,
"metaData": {},
"members": [
{
"userId": "20697",
"state": "completed",
"rtcUserId": 2595171365,
"id": "3e56a23d-bdd1-4215-979f-3cb6398278a1",
"user": {
"isOnline": true,
"displayName": "alen joe",
"profileImageUrl": "http://mobiledemodevelopment.s3.amazonaws.com/public/user/33/19/02/b5ceb45b2d6c74e4fc89673a5675c09c.jpg",
"profileUrl": "http://devaddons1.socialengineaddons.com/mobiledemodevelopment/profile/test1",
"metaData": {
"secondaryField": "Engineer"
},
"id": "20697"
}
},
{
"userId": "18859",
"state": "completed",
"rtcUserId": 967772343,
"id": "0e5c2c9f-2a06-4e64-8f97-e19ccddb51e2",
"user": {
"isOnline": false,
"displayName": "sydney millers",
"profileImageUrl": "http://mobiledemodevelopment.s3.amazonaws.com/public/user/17/0a/02/fbef1bb47eb85fb2979b135ed04e0eb3.png",
"profileUrl": "http://devaddons1.socialengineaddons.com/mobiledemodevelopment/profile/Alfredo",
"metaData": {
"secondaryField": "Software Engineer"
},
"id": "18859"
}
}
],
"state": "completed",
"duration": 53,
"timestamps": {
"joinedAt": "2020-06-09T15:55:12.353Z",
"completedAt": "2020-06-09T15:56:06.275Z"
},
"caller": {
"isOnline": true,
"displayName": "alen joe",
"profileImageUrl": "http://mobiledemodevelopment.s3.amazonaws.com/public/user/33/19/02/b5ceb45b2d6c74e4fc89673a5675c09c.jpg",
"profileUrl": "http://devaddons1.socialengineaddons.com/mobiledemodevelopment/profile/test1",
"metaData": {
"secondaryField": "Engineer"
},
"id": "20697"
},
"config": {
"require_invite": true,
"admin_messages": true
}
}
You can call various functions through this call model object directly. These functions are mentioned below:
Delete Call
Deletes a call. You can only delete a call once it has been completed.
channelizeCall.Call.getCall(callId, function (err, call) {
if (err) return console.error(err);
call.delete(function (err, res) {
});
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Refresh Call
Refresh the call model with latest data from the servers.
channelizeCall.Call.getCall(callId, function (err, call) {
if (err) return console.error(err);
call.refresh(function (err, res) {
});
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Get Members
Return members list of a call.
channelizeCall.Call.getCall(callId, function (err, call) {
if (err) return console.error(err);
const members = call.getMembers(state);
});
Function Params
state
Indicates the state of a member. The function will return the members of the provided state only. If you do not provide a state, the function will return all the members.
Play Local Media Stream
Once the call has been started, use the function to play the local media stream. The audio/video stream of the login user will be played on the given element once this function is called.
channelizeCall.Call.startCall(data, options, function (err, call) {
if (err) return console.error(err);
call.playLocalStream(elementId, options, cb);
});
Function Params
This table lists all possible parameters this function supports.
Name | Type | Description |
---|---|---|
elementId | string | Indicates the HTML element id where you want to play the video of the login user |
options | object | Indicates some options for playing the stream. Not a required argument. |
cb | function | Callback function that will be triggered once media starts playing on the given element. Not a required argument. |
Options
options can have a fit
property which represents video display mode and can have below values.
cover
Uniformly scale the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents. Refer to the cover option of object-fit in CSScontain
Uniformly scale the video until one of its dimension fits the boundary (zoomed to fit). Areas that are not filled due to the disparity in the aspect ratio will be filled with black. Refer to the contain option of object-fit in CSS.
The default value for the fit property is cover
.
Play Remote Media Stream
Once the call has been started, use the function to play the remote media streams. The audio/video stream of the provided user will be played on the given element once this function is called.
channelizeCall.Call.startCall(data, options, function (err, call) {
if (err) return console.error(err);
call.playRemoteStream(userId, elementId, options, cb);
});
Function Params
This table lists all possible parameters this function supports.
Name | Type | Description |
---|---|---|
userId | string | Indicates the user id for which you want to set the remote media stream. |
elementId | string | Indicates the HTML element id where you want to play the video of the login user |
options | object | Indicates some options for playing the stream. Not a required argument. |
cb | function | Callback function that will be triggered once media starts playing on the given element. Not a required argument. |
Options
options can have fit
property which represents video display mode and can have below values.
cover
Uniformly scale the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents. Refer to the cover option of object-fit in CSScontain
Uniformly scale the video until one of its dimension fits the boundary (zoomed to fit). Areas that are not filled due to the disparity in the aspect ratio will be filled with black. Refer to the contain option of object-fit in CSS.
The default value for fit property is cover
.
Get RTC Stream
This method returns the RTC stream of the given user. The RTC stream can be used for local and remote streams manipulations.
call.getRTCStream(userId);
Function Params
userId
Indicates the user for which you want to get the RTC stream. If you do not pass userId, the function will return the RTC stream of the login user.
Check Audio Enabled
This method allows you to check if the audio for a user is enabled or not. Returns true if the audio is enabled and otherwise returns false.
call.isAudioOn(userId);
Function Params
userId
Indicates the user for which you want to check the audio. If you do not pass userId, the function will check the audio of the login user.
Check Video Enabled
This method allows you to check if the video for a user is enabled or not. Returns true if the video is enabled and otherwise returns false.
call.isVideoOn(userId);
Function Params
userId
Indicates the user for which you want to check the video. If you do not pass userId, the function will check the video of the login user.
Mute Audio
This method allows you to mute audio for a user.
call.muteAudio(userId);
Function Params
userId
Indicates the user for which you want to mute the audio. If you do not pass userId, the function will mute the audio of the login user.
Mute Video
This method lets you mute video for a user.
call.muteVideo(userId);
Function Params
userId
Indicates the user for which you want to mute the video. If you do not pass userId, the function will mute the video of the login user.
Unmute Audio
This method lets you unmute audio for a user.
call.unmuteAudio(userId);
Function Params
userId
Indicates the user for which you want to unmute the audio. If you do not pass userId, the function will unmute the audio of the login user.
Unmute Video
This method lets you unmute video for a user.
call.unmuteVideo(userId);
Function Params
userId
Indicates the user for which you want to unmute the video. If you do not pass userId, the function will unmute the video of the login user.