We want to implement automatically pause recording (secure pause) feature. So far we use embedded Iframe for softphone and WebSocket JDK to handle events.
Questions:
Is there any interaction in embedded framework we can use to accomplish this?
If not, it seems that we can use PATCH to /api/v2/conversations/calls/{conversationId} to set the recordingState . so we would need conversation id and conversation body to make this request. Should we get conversation data from WebSocket or get it thru API api/v2/conversations to get active conversations for the logged in user before we making PATCH request?
The process seems to be parent page (our CRM page) post message to iframe and and then framework.js listen to that event. But I am having issue accessing the conversation id inside framework.js.
Is there something I am missing or misunderstanding? Thanks
Use the window.PureCloud.subscribe in framework.js to obtain information about the interaction including the conversationId. This will provide all the categorized events to you such as:
where id is the conversationId you are looking for.
Then you use the framework.js method getAuthToken() to obtain the token to use for the API:
window.PureCloud.User.getAuthToken(function(token) {
... do something with 'token'
});
With that information you have the basics to perform the PureCloud API call to perform the pause or resume operation. You are using a web socket connection to framework.js, so you can package the two attributes into a JSON message when an interaction is alerting within framework.js (from the subscribe) and send over your connection to your WSS component. Based on when you want to pause and subsequently resume, you can then send that to your WSS which leverages the stored token and conversationId to do the REST call against the PATCH of https://api.mypurecloud.com/api/v2/conversations/calls with the authentication bearer token with:
call.recordingState="paused";
or
call.recordingState="active";
based on the pause/resume action.
There's an alternative trick you can use where you use the PureCloud API to get the current calls for the user token. That is by doing a GET against https://api.mypurecloud.com/api/v2/conversations/calls first then using the returned conversation ID to pause or resume as above. But, this is only valuable if you have a single call in operation (no consults or second calls) otherwise you'll have to perform deeper analysis to determine which conversationId you are going to pause/resume.
I was missing "window.PureCloud.subscribe" to get the interaction info.
Just to be clear, Can we use 'window.PureCloud.Interaction.updateState' in framework.js to perform the pause action, assuming I get conversationId and pass it thru message to framework.js?
I was able to use API call to perform pause or resume as you describe, I am just wondering if this can be done inside framework.js via window.PureCloud.Interaction.updateState