question

pat-thomas2036 avatar image
pat-thomas2036 asked John Wang Deactivated commented

What is the overall data flow for the Subscription process

I am trying to build a Windows service that can collect call-log data from the RingCentral system, as real-time as possible. I am working in .NET Visual Basic. I have been able to POST requests to the RingCentral URL and get responses. I have also created a PubNub account and can Publish and Subscribe just fine. I understand that at RingCentral, I am supposed to POST a Subscription request and get my DeliveryMode Address and SubscriptionKey. I can see how they can be integrated with the PubNub URL. In one of the PubNub examples, I was able to Publish a string and subsequently Subscribe to the Channel and retrieve the string. What I am trying to understand is how do I access the new RingCentral notifications? Do I have to keep checking the PubNub URL for new data? Is PubNub the data host and that is why I have to query PubNub and not RingCentral directly? I don't have a data stream to test against, so when I Subscribe to PubNub I get nothing significant back. I might be on the right track and just lacking live data. Within our product, we use Marshalling so I know right away when there is new data. This process here, seems like I have to continuously query PubNub checking for new data. Is that correct?

getting started
1 |3000

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

ralph-r1798 avatar image
ralph-r1798 answered ralph-r1798 commented
When you setup your subscription to PubNub you should be passing in three delegates that get called in certain instances, one of those delegates, subscribeCallback, is the method on which you will get any messages back from RingCentral. PubNub is event driven so there shouldn't be any need to query once the PubNub subscription is setup.
2 comments
1 |3000

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

ralph-r1798 avatar image ralph-r1798 commented ·
That is correct. 

Note that if the PubNub channel is encrypted that the message will need to be decrypted using the information returned as part of the RingCentral call that sets up the PubNub channel, the encryptionKey being the key piece of information if I remember correctly.
1 Like 1 ·
pat-thomas2036 avatar image pat-thomas2036 commented ·
So, the CallBack delegate will be called when there is new data at PubNub and the delegate will receive the data each and every time there is a new record arriving at PubNub? I think this is what you are explaining. Am I correct? Thanks for the comment. 

0 Likes 0 ·
benjamin-dean avatar image
benjamin-dean answered pat-thomas2036 commented
Hey Pat, did Ralph's answers get you back on track, or do you require further assistance on this question?
6 comments
1 |3000

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

pat-thomas2036 avatar image pat-thomas2036 commented ·
I am still not getting any notifications. I am wondering if I have the correct filters defined in the Subscription. I have been able to add filters: 
""/restapi/v1.0/account/xxxxxxxxx/extension/yyyyyyyyy/message-store"" and 
""/restapi/v1.0/account/xxxxxxxxx/extension/yyyyyyyyy/presence"" and create the Subscription, but I haven't gotten any notifications when I make some test calls. 

I tried to add filters: 
""/restapi/v1.0/account/xxxxxxxxx/extension/yyyyyyyyy/call-log"" and ""/restapi/v1.0/account/~/extension/~/call-log"",  but I get error '(400) Bad Request'.

When I create the PubNub subscription, I do get an acknowledgement from PubNub... 
ConnectCallback '[1,"Connected","163921857395194_ac52930a"]'
and 
I can request a PubNub Time:
UserCallback '[14647859530123039]'
I can request a PubNub HereNow: 
UserCallback '[{"status":200,"message":"OK","service":"Presence","uuids":[],"occupancy":0},"163921857395194_ac52930a"]'

So, it seems I am connected successfully to PubNub. 

Thanks!

0 Likes 0 ·
benjamin-dean avatar image benjamin-dean commented ·
I would start by testing just the basic Presence events being received by your server.

Create a subscription, add this filter: '/restapi/v1.0/account/~/extension/~/presence', and register the subscription, then use the phone number you authorized with to make a phone call (or receive a phone call) from your cellular number (or some outside number).

If you see the event data...then there is a problem with the eventFilters you are using...if not, there is a problem with the subscription.
0 Likes 0 ·
pat-thomas2036 avatar image pat-thomas2036 commented ·
I started my Windows application. I subscribed to RC and PubNub. I got confirmation of the Subscription with RingCentral with a Channel and SessionID. I received a Connect Callback from PubNub after subscribing. I called the DID for my RC Extension and made a 51 second call. I didn't get a comment posted to my logs of the Callback. I checked the Call-Log and it lists my test calls including the one I just made. I used only one event filter ""/restapi/v1.0/account/~/extension/~/presence"".

In the PubNub demo, playing TicTacToe, it was tested using two browsers and the receiver of the callbacks. I am trying to test using a desktop applicaton and a ListBox within it. When I instantiate the Subscription and request the HereNow or Time with callbacks, I get an entry in my ListBox. Could it be an issue with implementation? That it can't callback to a desktop application? 

Here is a Get on My Subscription, after the test call: 
13:27:07 {13:27:07   "uri" : " https://platform.devtest.ringcentral.com/restapi/v1.0/subscription/eb403381-4eaa-40d5-b179-a0c76c4dd...;,
13:27:07   "id" : "eb403381-4eaa-40d5-b179-a0c76c4dd464",
13:27:07   "creationTime" : "2016-06-01T18:16:01.347Z",
13:27:07   "status" : "Active",
13:27:07   "eventFilters" : [ "/restapi/v1.0/account/bbbbbbbb/extension/cccccccc/presence" ],
13:27:07   "expirationTime" : "2016-06-01T18:31:01.350Z",
13:27:07   "expiresIn" : 233,
13:27:07   "deliveryMode" : {
13:27:07     "transportType" : "PubNub",
13:27:07     "encryption" : true,
13:27:07     "address" : "aaaaaaaaa",
13:27:07     "subscriberKey" : "sub-c-ssssssss",
13:27:07     "encryptionAlgorithm" : "AES",
13:27:07     "encryptionKey" : "xxxxxx"
13:27:07   }

Thanks

0 Likes 0 ·
benjamin-dean avatar image benjamin-dean commented ·
What is the name of your application you created in Developer Portal please?
0 Likes 0 ·
benjamin-dean avatar image benjamin-dean commented ·
This should support standalone apps, so I don't believe that would be the problem.

You should be seeing the following values in the response from POST to create the subscription. This data is from PubNub which gives your application code the data it needs to subscribe to PubNub:
  • address  PubNub channel name to subscribe to;

  • subscriberKey  PubNub subscriber credentials required to subscribe to the channel.

This is outlined in this URL of our documentation:  http://developers.ringcentral.com:8088/api-docs/latest/index.html#!#SubscriptionFlow.html

The important section inside that is:

The client uses this information to properly configure the PubNub client library and subscribe to the channel.

PubNub provides SDKs for many popular operating systems and frameworks: iOS, Android, Ruby, JavaScript, Java, Objective C, .Net etc. You can find full list of SDKs on the pagehttp://www.pubnub.com/developers/. PubNub HTTP REST API can be also used as well. For example, to subscribe for push notifications with channel (address) and credentials (subscriberKey) provided by RingCentral API as it described above, you can use the following HTTP request:

GET http://pubsub.pubnub.com/subscribe/{subscriberKey}/{address}/{callback}/{timetoken}

You can find full PubNub REST API description on this page http://www.pubnub.com/http-rest-push-api/.

Your application in Developer Portal must have been assigned the ReadPresence API permission as well as ReadCallLog API Permission (if it isn't already).

0 Likes 0 ·
Show more comments
John Wang avatar image
John Wang Deactivated answered John Wang Deactivated commented
Have you tried the official RingCentral C# SDK which handles subscription for you? If you can use it directly, you will be using well tested code. If you cannot use it for some reason, you can also use the code for reference. Here are links to the C# SDK:


The latest release includes some subscription changes and is 1.0.0-alpha2.

This is a Portable Class Library (PCL) that supports .NET 4.0+ on Windows and Mono for Mac as well as Xamarin.Android and Xamarin.iOS. It uses the PubNub PCL library.
3 comments
1 |3000

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

pat-thomas2036 avatar image pat-thomas2036 commented ·
Today, I have modified my app to reference the github CSharp app and tried to use the features built into it, but have not found all of the pieces necessary to make it work. The docs on the github site aren't matching to the methods I see in the drivers. As an example: a sample code snipet: 

var subscription = sdk.CreateSubscription();

I cannot find the CreateSubscription function in the SDK. When I trace it back in the source project I see it is either marked internal or private. So, I am not following how to use this tested sample CSharp app as a model for my VB .NET app. 

I have been also chatting with the PubNub Support team and they are trying to help but are limited by not being able to make test calls while testing the app. PubNub has elevated my support level.

My whole project is about putting together an interface for a Ring Central customer, so I hope I can get some more direct and timely support to get this whole process working. Just to be clear, this is a VB .NET desktop application.


0 Likes 0 ·
pat-thomas2036 avatar image pat-thomas2036 commented ·
I worked with a PubNub Technician this afternoon. He showed me how to pull up the Console app at www.pubnub.com/console and enter in my SubKey and Channel information and Subscribe to the Channel.

When I made test calls on the Dev account, I did not get any notifications. Currently my Subscription is filtering on ""/restapi/v1.0/account/~/extension/~/presence""... I made a test call with a voicemail and one as missed.

Should either of these trigger a Presence event? If not, which event type should I be testing with? 
Thanks
0 Likes 0 ·
John Wang avatar image John Wang ♦♦ commented ·
Version 1.0.0 of the C# .NET SDK has been released to Nuget and on GitHub now. CreateSubscription() is a public function on line 44 of the RingCentral.SDK per below:

public SubscriptionService CreateSubscription()

https://github.com/ringcentral/ringcentral-csharp/blob/a0bda936689e8bc5594c3791611b06c67660b3f4/Ring...

You should be able to reference the C# SDK and import it into your VB.NET project. Is there a reason this will not work for you?

Other than that, you can look at and port the code in the C# SDK.
0 Likes 0 ·
John Wang avatar image
John Wang Deactivated answered
Here is working VB.NET code for subscription (and SMS) using the C# SDK 1.0.0:

1 |3000

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

pat-thomas2036 avatar image
pat-thomas2036 answered John Wang Deactivated commented
Thanks for the VB.NET example. I am able to create a subscription using this code.

How do I gain access to the Subscription details using this method? I checked the sdk and subscription objects and don't see any reference to the detail I need.

I am supposed to use the Address and SubscriberKey from the DeliveryMode object for creating a Subscription to PubNub.

Thanks!

2 comments
1 |3000

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

John Wang avatar image John Wang ♦♦ commented ·
You should be good to go using the above VB.NET code only.

When using the C# .NET SDK, the SDK will take care of all PubNub communications and interactions for you so you are not supposed to interact directly with PubNub or use the Address or Subscriber Key properties. PubNub interaction is handled by the RingCentral.Subscription.SubscriptionService class which you can see here:

https://github.com/ringcentral/ringcentral-csharp/blob/master/RingCentral/Subscription/SubscriptionS...
0 Likes 0 ·
John Wang avatar image John Wang ♦♦ commented ·
Also, please star the C# SDK on GitHub if you find it useful.

Hope it's all working now!
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