question

liu6213 avatar image
liu6213 asked teresa-b13989 commented

Rest API - how to get notified when there's incoming call

I'm creating a browser app to use rest APIs. One critical feature is to show waiting calls. I tried to use subscription to get notified when there's new incoming call. But subscription seems not working for either active-calls or call-logs API. I got invalid event filter error.

So subscription doesn't support call logs?

rest api
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

paco-vu avatar image
paco-vu answered
Hi Liu,

First of all, there is no event filter for call-log event. You said you got invalid event filter error, was that for what you tried with call-logs?

I am not sure what you meant "active-calls" while your question was about to get notified when there's new incoming call (new coming call is not an active-call yet). To get notified when there is an incoming call, you can simply subscribe to the account presence event with this event type "/restapi/v1.0/account/~/presence". Then when there is an incoming call, you should receive this "telephonyStatus":"Ringing" inside the body of the notification payload.

If this is not what you wanted, please clarify more your question and post the event filter your tried and the error message you got.

Kind regards,
Paco
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

anton-nikitin avatar image
anton-nikitin answered
Probably you should use detailed presence with active calls information - see  https://developer.ringcentral.com/api-docs/latest/index.html#!#RefGetDetailedExtensionPresenceEvent. It is not a direct alternative for active-calls but the best we have today. We are working on extending the event payload to contain more details about a call to eliminate a need of calling active-calls API after a call is finished.
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

liu6213 avatar image
liu6213 answered
Thanks everybody for reply. I tried agent presence subscription. But I only got notified when agent changes presence, but when there's incoming call, no notification. Is it because I don't have softphone connected? Problem is I couldn't login to softphone, it's testing environment.
The following is my code:
  var loadAgentInfo = function (allAgents) {
    var agentIds = getAgentIds(allAgents);
    if (agentIds) {
      $scope.rcsdk.platform().get('/account/~/extension/' + agentIds, {}).then(function(agentRes) {
        var agents = agentRes.multipart();

        var subscription = $scope.rcsdk.createSubscription();
        var callLogSubscription = $scope.rcsdk.createSubscription();

        subscription.on(subscription.events.notification, function(msg) {
          $scope.loadAgentsStatus();
        });

        var callLogEvents = [];
        var presenceEvents = [];
        for (var j = 0; j < agents.length; j++) {
          var agentJson = agents[j].json();
          populateAgentInfo(agentJson);
          //presenceEvents.push('/account/~/extension/'+ agentJson.id + '/presence');
          presenceEvents.push('/account/~/extension/'+ agentJson.id + '/presence?detailedTelephonyState=true');
        }
        presenceEvents.push('/account/~/presence');
        subscription.setEventFilters(presenceEvents).register();
        $scope.$apply();
        $scope.loadAgentsStatus();

      }).catch(function(agentErr) {
        Notification.error({message: "Loading agent info failed!", positionY: 'top', positionX: 'center', delay: 10 * 1000});
      });
    }
  }
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

paco-vu avatar image
paco-vu answered liu6213 commented
Hi Liu,

Yes, you need to login your SoftPhone with the extension phone number which you want to monitor an incoming call. You have to switch your SoftPhone to sandbox mode before you can login with sandbox account. In Windows PC, press Ctrl + F2 and in MacOS, press Fn+Command+F2 simultaneously and select sandbox mode.

+ Paco
1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

After I switched to sandbox mode, the subscription is working. Thanks for your help.
0 Likes 0 ·
liu6213 avatar image
liu6213 answered teresa-b13989 commented
One more question, how can I monitor incoming calls to call queue? Currently I can monitor calls for all agents of a call queue. But the problem is if all agents are busy, then one more incoming call to the call queue I won't be able to get notified by monitoring all agents. Any solutions?
1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

were you able to get a solution to this?
0 Likes 0 ·

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys