Is there a way I can integrate PureCloud dialpad in my custom CRM? The homegrown CRM is based on Asp.NET platform and I would like the dialpad to be available in customer profile page. When the user uses the dial pad, I would like to capture the InteractionId for the call.
you would have to handle the UI for this yourself and then use POST /api/v2/conversations/calls to place the call. That POST will return the conversation id.
The API seem not working every time - postCalls is going to error (timeout), although the call would get started. Any idea why this is happening?
Also, I am using the below SDK. Is there an update OR alternate to this?
https://sdk-cdn.mypurecloud.com/javascript/0.51.1/purecloud-api.js
The api is working, you just need to increase the timeout because your internet connection is slow.
var session = purecloud.platform.PureCloudSession({
// ... your other settings
timeout: 10000
});
cdn versions of the sdk match the bower version, the latest is 0.68.2
Thank you for the quick response.
If I open PureCloud app in a chrome tab and leave it idle (perhaps more than 5 minutes or so), the postCall do not get through until I refresh that page. Is there a solution to this? Does it work differently on PureCloud Desktop client?
what do you mean it does not go through?
I am calling the postCalls API from my Web Application, which is on a chrome tab. The same user has logged into PureCloud in another tab. Upon invoking the API, I can see the call (against the number that I passed to the API) getting initiated, most of the time. But not very consistent, and looks like it do not work after some idle time.
what is the http response from your postCall?
and what is the token duration for your oauth client set to?
I am getting "Error: timeout of 2000ms exceeded at Request.timeoutError ".
And token duration is set to the default (86400)
then try increasing the timeout.
I do not see a parameter that can be used as timeout value (from below list). Am I missing something?
"phoneNumber": "",
"callFromQueueId": "",
"callQueueId": "",
"callUserId": "",
"priority": 0,
"languageId": ""
from above: set it in the session
For postCalls, I am just passing the target phone number. However, the dialer appears in PureCloud app, but no connection established. Is there a need to set the user presence OR create notification channel for this to work?
All you need to do is have a logged in user that is using a phone and then use POST /api/v2/conversations/calls.
This example is using the .NET SDK to place a call, but it's pretty simple: https://github.com/T-Boss/purecloud_platform_api_test_apps/blob/master/csharp/console%20app/SDK%20Test/Program.cs#L155
I am trying to achieve this using JavaScript and here is the code I am trying to make work. Would you be able to tell me what is going wrong? (It do not establish connection when dialed using the script below. If I dial from call history for the same number, it works)
<html>
<head>
<title>PostCall Test</title>
<script src='https://code.jquery.com/jquery-1.10.2.js'></script>
<script src='https://sdk-cdn.mypurecloud.com/javascript/0.51.1/purecloud-api.min.js'></script>
</head>
<body>
<button class="callNow">Call Desk</button>
</body>
<script type="text/javascript">
var pureCloudSession = purecloud.platform.PureCloudSession({
strategy: 'implicit',
clientId: 'cd775fb3-e156-4fdd-af7d-a711cc7ef073',
redirectUrl: 'http://localhost/purecloud_call.html',
timeout: 20000
});
$('.callNow').click(function() {
pureCloudSession.login().then(function () {
var myUserId = '';
var usersapi = new purecloud.platform.UsersApi(pureCloudSession);
usersapi.getMe('presence').then(function(data){
debugger;
var api = new purecloud.platform.ConversationsApi(pureCloudSession);
var body = { 'phoneNumber' : '3172222222' };
api.postCalls(JSON.stringify(body)).then(function(result){
console.log(result);
})
.catch(function(error){
console.log(error);
});
})
.catch(function (error) {
console.log(error);
});
})
.catch(function (error) {
console.log(error);
});
});
</script>
</html>
I don't see that you're logging in to a station anywhere in your code. Are you ensuring the user is logged in to a phone via some other means? You can set the user's station with PUT /api/v2/users/{userId}/station/associatedstation/{stationId}.
Also, you're calling JSON.stringify on the request body. I think that might be causing an issue as the SDK expects an object, not a string. Try removing that first.
There's also a tutorial on placing a call and doing call control operations: https://developer.mypurecloud.com/api/tutorials/calls/#javascript
I downloaded the example from here - https://github.com/MyPureCloud/developercenter-tutorials/tree/master/calls/javascript, but that also did not work. I have PureCloud app opened in another browser tab. Although I see the tiny dialer panel opened, the connection is not getting established.
Do I have to set any permission/role against the ClientID?
At this point, it sounds like you're probably doing things correctly. I'd suggest opening a ticket with PureCloud Support. They can dig in deeper with you to figure out why the edge isn't placing calls correctly. It could be an issue with the edge or some config issue, but Support will be able to track that down.