FreeSWITCH JS API (v3.2.8)
This library of SIP.js can be used either as a standalone implementation or with EFCX.
Please refer to the table below for compatible EFCX versions
EFCX Version | SIP JS Version |
---|---|
4.5.2 | 3.2.8_b-CIM-15311 |
To send commands, you need to import the following libraries Freeswitch
Commands Sample
Sample
Sample
{
"action": "login",
"parameter":
{
"loginId": "jazeb",
"password": "1234",
"extension": "448899",
"clientCallbackFunction": eventCallback
}
};
Commands for CTI
Story | Description | Commands | Events | |
---|---|---|---|---|
1 | login | The Login command is used to actually Register an agent associated extension and log in to CTI. Login command parameters are
First JS API will register extension to webphone, If Registeration got failed, the following event will be thrown Following errors are possible:
If a Registeration is successful, will send the following event. agentState and dialogState events. Now the agent will be able to make and receive calls on the client application. | Sample Sample
JS
| Successful Events :
Failure Events :
|
2 | makeCall | This command allows a user to make a call. To make a call, a new Dialog object is created that specifies the <Extension_Number> (the destination target). The new Dialog object is posted to the Dialog collection for that user. Here callType parameter value would be audio/video/screenshare | Sample Sample
JS
|
|
3 | makeOBCall | This command allows a user to make a Manual Outbound call. To make a call, a new Dialog object is created that specifies the (the destination target). The new Dialog object is posted to the Dialog collection for that user. Here callType parameter value would be audio | Sample Sample
JS
|
|
4 | answerCall | This command allows a user to answer a call. Here answerCalltype parameter value would be audio/video/screenshare/onlyviewscreenshare | Sample Sample
JS
|
|
5 | releaseCall | This command allows a user to drop a call. | Sample Sample
JS
|
|
6 | holdCall | This command allows a user to hold a call | Sample
JS
|
|
7 | retrieveCall | This command allows a user to Resume a call. | Sample
JS
|
|
8 | logout | This command will logout the agent from the CTI | Sample
JS
|
|
9 | mute | This command will mute the audio of call from agent side. |
JS
|
|
10 | unmute | This command will unmute the audio of call from agent side. |
JS
|
|
11 | SST (blind transfer) | This command allows a user to transfer the call on agent extension blindly without waiting for the other agent to receive the call. |
JS
| Agent A
Agent B
|
12 | SST_Queue(Blind transfer on queue) | This command allows a user to transfer the call on queue blindly. |
JS
| Agent A
Agent B
|
13 | ConsultCall | This command allows a user to initiate a consult call with another agent. Once the call is accepted by the other agent, the user can either transfer this call to the other agent or can drop the consult call. |
JS
| For Agent A:
For agent B:
|
14 | ConsultCall_Queue | This command allows a user to initiate a consult call with another agent using Queue. Once the call is accepted by the other agent, the user can either transfer this call to the other agent or can drop the consult call. |
JS
| For Agent A:
For agent B:
|
15 | Consult Transfer | This command allows a user to merge / Bridge Customer Call with another agent. The Other agent must be in Call with First Agent. |
JS
| For Agent A:
For agent B:
|
16 | SendDtmf | This command allows user to send dtmf during the IVR playing. Here message is the dtmf that we need to send. |
JS
|
|
17 | Click To Call | This command will allow user to make call in cross domain like if the user domain is different then the FS JS API domain then user must send us window.postMessage that contains required parameters.
Here above are dynamic values while SourceType value will remain static |
JS
|
|
18 | ConvertCall | This Command will allow the user to Enable / Disable Stream while in webrtc Call. streamStatus: on / off |
JS
|
|
19 | Silent Monitor | This command allows the supervisor to silently monitor a call. |
JS
|
|
Event for CTI
1 | agentInfo | JS API sends this event when the device logged in successfully with state LOGIN. This event will never be sent again in a session | Sample Sample
JS
Sample
JS
Possible value for state
|
2 | dialogState | Dialog state event represents the current state of the dialog. | Use both dialog's state and participant's state provided in response JSON object to figure out call state.
Sample
JS
The current state of the dialog. Possible values are:
|
3 | newInboundCall | This event occurs when an incoming call is ringing for the agent. This event specifies from address, call variables, and dialog id for the agent. The client needs to activate the control for accepting or rejecting the call. | Sample Sample
JS
|
4 | outboundDialing | This event will trigger when the user starts the outbound Dialing | Sample Sample
JS
|
5 | consultCall | This event informs the client about the current state of consult call for an agent. The current state of the dialog. Possible values are:
| Sample
JS
|
6 | RONA | The customer initiated the call and the call is ringing on the agent's side, the agent does not accept the call and alerting/ringing times out The customer initiated the call and the call is ringing on the agent's side, and the customer ends the call. In above both case the value of the key endCallReason would be Canceled in dialogState event. |
JS
|
7 | xmppEvent | This event will be triggered when network connection status changes i.e it will be triggered when network status is connected or disconnected. |
JS
types: OUT_OF_SERVICE IN_SERVICE |
8 | DTMF | This event will be triggered when we send DTMF during IVR playing. |
JS
type: 1 for success response 0 for failure response |
9 | mediaConversion | This Event will be triggered when any Participant of the webrtc call enable/disable a stream |
JS
status: error/success |
Error Event for CTI
Error Event Types | Description | Events | |
---|---|---|---|
1 | subscriptionFailed | This error occurs when JS API tries to get a subscription of an agent with supplied credentials and those credentials are invalid. | Sample Sample
JS
|
2 | generalError | We define its type as general error and its description will tell what is the root cause of this error. | Sample Sample
JS
In some cases description can also be "description": "Sorry we are unable to process your request" |
3 | invalidState | The object is in the incorrect state for the request, Send the request again. | Sample
JS
|
SR No | Parameter | Details |
---|---|---|
1 | callType | callTypes = { inboundType : "OTHER_IN", outboundType : "OUT", consultType : "CONSULT", consultTransferType : "CONSULT_TRANSFER", } |