new InteractionApi()
Interaction API contains methods and event to track interaction lifecycle and get/set some interaction data. Also some utility methods are provided.
The interaction (call, chat, email) has a limited lifetime. When it is finished (disposition is set) the interaction data (CAVs, disposition list, search results, Name/RelatedTo lists etc.) cleaned up. It means the most of get/set methods won't work after you receive 'Call/Chat/EmailFinished' event (and inside this event callback as well). It might be true for other events. For example, you implement callback for CallEnded event and start long async action in it. When action is completed, call is already finished, so get/set methods won't work.
Methods
click2dial(params) → {void}
Communicate to Five9 adapter that user pressed phone number and wants to initiate click to dial. call will be started automatically if default campaign is configured by administrator or campaign name is provided in click2dialData parameter.
const interactionApi = window.Five9.CrmSdk.interactionApi();
interactionApi.click2dial({
click2DialData: {
clickToDialNumber: "9250000111",
crmObject: {id: "789", label: "Account", name: "Umbrella", isWho: false, isWhat: true}
}
});
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
void
executeRestApi(params) → {Promise}
Executes REST request using CORS
interactionApi.executeRestApi({path: '/appsvcs/rs/svc/orgs/1/dispositions', method: 'GET', payload: null}).then(function (result) {
// resolve handler
}, function (result) {
// reject handler
});
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
Parameters
|
Returns:
- Type:
-
Promise
Promise objects represents {status: <e.g. 200, 404, ...>, response:
executeRestApiV2(params) → {Promise}
Executes REST request using Five9 Rest Api from adapter
interactionApi.executeRestApi({path: '/appsvcs/rs/svc/orgs/1/dispositions', method: 'GET', payload: null}).then(function (result) {
// resolve handler
}, function (result) {
// reject handler
});
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
Parameters
|
Returns:
- Type:
-
Promise
Promise objects represents {status: <e.g. 200, 404, ...>, response:
getCav(params) → {Promise}
Retrieves list of call attached variables
interactionApi.subscribe({
callStarted: params => {
interactionApi.getCav({interactionId: params.callData.interactionId})
.then(cavList => {
console.debug('Interaction API got cavList: ' + JSON.stringify(cavList));
});
}
});
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
params |
object
|
Parameters
|
Returns:
- Type:
-
Promise
Promise object represents Cav[] In case of error Promise is rejected and InteractionApiErrorStatus is returned.
getCrm(params) → {Promise}
Retrieves list of VCC contact record fields
interactionApi.subscribe({
callStarted: params => {
interactionApi.getCrm({interactionId: params.callData.interactionId})
.then(crmList => {
console.debug('Interaction API got crmList: ' + JSON.stringify(crmList));
});
}
});
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
Parameters
|
Returns:
- Type:
-
Promise
Promise object represents ContactField[] In case of error Promise is rejected and InteractionApiErrorStatus is returned.
getDispositions(params) → {Promise}
Retrieves list of dispositions for specified interaction
interactionApi.subscribe({
callStarted: params => {
interactionApi.getDispositions({interactionType: 'Call', interactionId: params.callData.interactionId})
.then(dispositionList => {
console.debug('Interaction API got dispositionList: ' + JSON.stringify(dispositionList));
});
}
});
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise object represents Disposition[] In case of error Promise is rejected and InteractionApiErrorStatus is returned.
getMetadata() → {Promise}
Retrieves of agent and tenant ids
Returns:
- Type:
-
Promise
that's always resolved and return object represents {agentId: Number, tenantId: Number}
getNameObjects(params) → {Promise}
Retrieves list of visited 'Name' CRM objects for specified interaction
interactionApi.subscribe({
objectSelected: params => {
interactionApi.getNameObjects({
interactionType: params.interactionType,
interactionId: params.interactionData.interactionId
}).then(objects => {
console.debug('Interaction API got name objects: ' + JSON.stringify(objects));
});
}
});
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise object represents CrmObject[] In case of error Promise is rejected and InteractionApiErrorStatus is returned.
getRelatedToObjects(params) → {Promise}
Retrieves list of visited 'Related To' CRM objects for specified interaction
interactionApi.subscribe({
objectSelected: params => {
interactionApi.getRelatedToObjects({
interactionType: params.interactionType,
interactionId: params.interactionData.interactionId
}).then(objects => {
console.debug('Interaction API got related to objects: ' + JSON.stringify(objects));
});
}
});
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise object represents CrmObject[] In case of error Promise is rejected and InteractionApiErrorStatus is returned.
getSearchResults(params) → {Promise}
Retrieves list of CRM objects found by search
interactionApi.subscribe({
callEnded: params => {
interactionApi.getSearchResults({
interactionType: params.interactionType,
interactionId: params.interactionData.interactionId
}).then(searchResults => {
console.debug('Interaction API got searchResults: ' + JSON.stringify(searchResults));
});
}
});
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
Parameters
|
Returns:
- Type:
-
Promise
Promise object represents CrmObject[] In case of error Promise is rejected and InteractionApiErrorStatus is returned.
getSelectedNameObject(params) → {Promise}
Retrieves selected 'Name' CRM object for specified interaction
interactionApi.subscribe({
callEnded: params => {
interactionApi.getSelectedNameObject({
interactionType: params.interactionType,
interactionId: params.interactionData.interactionId
}).then(nameObject => {
console.debug('Interaction API got selected name object: ' + JSON.stringify(nameObject));
});
}
});
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise object represents CrmObject or nothing if 'None' is selected. In case of error Promise is rejected and InteractionApiErrorStatus is returned.
getSelectedRelatedToObject(params) → {Promise}
Retrieves selected 'Related To' CRM object for specified interaction
interactionApi.subscribe({
callEnded: params => {
interactionApi.getSelectedRelatedToObject({
interactionType: params.interactionType,
interactionId: params.interactionData.interactionId
}).then(relatedToObject => {
console.debug('Interaction API got selected related to object: ' + JSON.stringify(relatedToObject));
});
}
});
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise object represents CrmObject or nothing if 'None' is selected. In case of error Promise is rejected and InteractionApiErrorStatus is returned.
isMasterPage() → {Promise}
Determines if this page contains ADT instance which holds websocket connection
Returns:
- Type:
-
Promise
Promise object represents boolean value
mute() → {Promise}
Mute softphone.
Returns:
- Type:
-
Promise
Promise is resolved if mute is successful. In case of error Promise is rejected and InteractionApiErrorStatus is returned.
objectVisited(params) → {void}
Communicate details of object visited by user in CRM system to Five9 Agent Desktop toolkit. Five9 adapter will display this object in the list of objects available for saving call logs.
const interactionApi = window.Five9.CrmSdk.interactionApi();
interactionApi.objectVisited({
crmObject: {id: "456", label: "Case", name: "Broken microwave", isWho: false, isWhat: true}
});
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
void
openInteraction(params) → {Promise}
Open screen for passed interaction.
interactionApi.openInteraction({
interactionType: params.interactionType,
interactionId: params.interactionId
}).then(() => {
console.debug('Interaction API interaction opened');
});
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise is resolved if interaction opened. If it was not able to switch to interaction UI Promise is rejected.
selectNameObject(params) → {Promise}
Sets selected 'Name' CRM object for specified interaction
interactionApi.subscribe({
callEnded: params => {
interactionApi.selectNameObject({
interactionType: params.interactionType,
interactionId: params.interactionData.interactionId,
objectId: '123'
}).then(() => {
console.debug('Interaction API set selected name object');
});
}
});
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise is resolved if object is selected. In case of error Promise is rejected and InteractionApiErrorStatus is returned.
selectRelatedToObject(params) → {Promise}
Sets selected 'Related To' CRM object for specified interaction
interactionApi.subscribe({
callEnded: params => {
interactionApi.selectRelatedToObject({
interactionType: params.interactionType,
interactionId: params.interactionData.interactionId,
objectId: '123'
}).then(() => {
console.debug('Interaction API set selected related to object');
});
}
});
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise is resolved if object is selected. In case of error Promise is rejected and InteractionApiErrorStatus is returned.
sendDtmf() → {Promise}
Send DTMF to softphone.
Parameters:
Name | Type | Description |
---|---|---|
params.char |
string
|
A string containing DTMF digits. |
Returns:
- Type:
-
Promise
Promise is resolved if DTMF send is successful. In case of error Promise is rejected and InteractionApiErrorStatus is returned.
setCav(params) → {Promise}
Sets value of call attached variables
interactionApi.setCav({
interactionId: "45E471D607A94072A553A1406CC0BF03",
cavList: [
{id: "641", value: "test value"},
{id:"219", value: "test@example.com"}
]
});
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
Parameters
|
Returns:
- Type:
-
Promise
Promise is resolved if Five9 REST API call succeeded. In case of error Promise is rejected and InteractionApiErrorStatus is returned.
setDisposition(params) → {Promise}
Sets disposition for current call
interactionApi.setDisposition({
interactionType: 'Call',
interactionId: "92544E7EFD1B4858A93C54092CB51886",
dispositionId: "3558"
});
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise is resolved if Five9 REST API call succeeded. In case of error Promise is rejected and InteractionApiErrorStatus is returned.
subscribe(apiEvents) → {void}
Subscribes to Interaction Api events.
const interactionApi = window.Five9.CrmSdk.interactionApi();
interactionApi.subscribe({
callStarted: function (params) {
},
callFinished: function (params) {
},
callAccepted: function (params) {
},
callRejected: function (params) {
},
callEnded: function (params) {
},
emailOffered: function (params) {
},
emailAccepted: function (params) {
},
emailRejected: function (params) {
},
emailTransferred: function (params) {
},
emailFinished: function (params) {
},
chatOffered: function (params) {
},
chatAccepted: function (params) {
},
chatRejected: function (params) {
},
chatTransferred: function (params) {
},
chatEnded: function (params) {
},
chatFinished: function (params) {
},
objectSelected: function (params) {
}
});
Parameters:
Name | Type | Description |
---|---|---|
apiEvents |
InteractionApiEvents
|
Callbacks corresponding to the events will be called on object passed as parameter |
Returns:
- Type:
-
void
subscribeWsEvent(wsEventId) → {void}
Subscribes to web socket events.
interactionApi.subscribeWsEvent({
"29": function (params, context) {
},
"15": function (params, context) {
},
...
});
alternative subscription:
interactionApi.subscribeWsEvent("29", function (params) {
});
Parameters:
Name | Type | Description |
---|---|---|
wsEventId |
string
|
object
|
Callbacks corresponding to the web socket events will be called on object passed as parameter |
Returns:
- Type:
-
void
unMute() → {Promise}
Unmute softphone.
Returns:
- Type:
-
Promise
Promise is resolved if unmute is successful. In case of error Promise is rejected and InteractionApiErrorStatus is returned.
unsubscribeWsEvent(wsEventId) → {void}
Unsubscribes from web socket events.
interactionApi.unsubscribeWsEvent({
"29": <function used for subscription>,
"15": <function used for subscription>,
...
});
alternative unsubscription:
interactionApi.unsubscribeWsEvent("29", <function used for subscription>);
Parameters:
Name | Type | Description |
---|---|---|
wsEventId |
string
|
object
|
Callback references used for subscription to web socket events will be unsubscribed from those events |
Returns:
- Type:
-
void