What is the overall data flow for the Subscription process

  • 2
  • Question
  • Updated 2 years ago
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? 
Photo of Pat Thomas

Pat Thomas

  • 150 Points 100 badge 2x thumb
  • almost there...

Posted 2 years ago

  • 2
Photo of Ralph R

Ralph R

  • 142 Points 100 badge 2x thumb
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.
Photo of Pat Thomas

Pat Thomas

  • 150 Points 100 badge 2x thumb
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. 
Photo of Ralph R

Ralph R

  • 142 Points 100 badge 2x thumb
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.
Photo of Benjamin Dean

Benjamin Dean, Alum

  • 8,622 Points 5k badge 2x thumb
Hey Pat, did Ralph's answers get you back on track, or do you require further assistance on this question?
Photo of Benjamin Dean

Benjamin Dean, Alum

  • 8,622 Points 5k badge 2x thumb
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.
Photo of Pat Thomas

Pat Thomas

  • 150 Points 100 badge 2x thumb
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
Photo of Benjamin Dean

Benjamin Dean, Alum

  • 8,622 Points 5k badge 2x thumb
What is the name of your application you created in Developer Portal please?
Photo of Benjamin Dean

Benjamin Dean, Alum

  • 8,622 Points 5k badge 2x thumb
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).
Photo of Pat Thomas

Pat Thomas

  • 150 Points 100 badge 2x thumb
My app name is Create Test Call.

In my project I am using the PubNub-Messaging.dll, ver: 3.7.5.0 for .Net 4.5,  that I got from PubNub. So, instead of subscribing via the url, I am subscribing using their interface.

I instantiate the PubNub dll, using the Subscriber Key (from RingCentral Subscription.DeliveryMode.SubscriberKey) and then call PubNub.Subscribe using the Channel (from RingCentral.Subscription.DeliveryMode.Address and the three callback methods for Subscriber, Connect, and Error. I do get a response from the ConnectCallback that it connected. 

I used the PubNub library in the Demo and it worked before. 

I do have the Read permissions mentioned above. 

When I tried the link to the SubscriptionFlow above, it failed to open the page. This site can’t be reached  developers.ringcentral.com refused to connect.
I do recall reading that section. 

I will go ahead and rewrite accessing the PubNub using the https method instead of the PubNub .net drivers and give it a try. 

Thanks
Photo of John Wang

John Wang, Official Rep

  • 5,278 Points 5k badge 2x thumb
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.
(Edited)
Photo of Pat Thomas

Pat Thomas

  • 150 Points 100 badge 2x thumb
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.
Photo of Pat Thomas

Pat Thomas

  • 150 Points 100 badge 2x thumb
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
Photo of John Wang

John Wang, Official Rep

  • 5,278 Points 5k badge 2x thumb
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.
(Edited)
Photo of John Wang

John Wang, Official Rep

  • 5,278 Points 5k badge 2x thumb
Here is working VB.NET code for subscription (and SMS) using the C# SDK 1.0.0:

(Edited)
Photo of Pat Thomas

Pat Thomas

  • 150 Points 100 badge 2x thumb
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!
Photo of John Wang

John Wang, Official Rep

  • 4,798 Points 4k badge 2x thumb
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...
(Edited)
Photo of John Wang

John Wang, Official Rep

  • 4,798 Points 4k badge 2x thumb
Also, please star the C# SDK on GitHub if you find it useful.

Hope it's all working now!