I need to develop an application to Track live call numbers when the RingCentral phone app is ringing. How can I do that with C# SDK?
#User story#
We have developed a c#, .net windows-based application for the Pizza shop. They need to integrate their RingCentral app with this new application to track customer call numbers. When ringing the RingCentral phone app, We need to get the customer's phone number and check whether that number is already registered with our DB. Could please help in order to get this done? I am looking for a sample code.
Also, your sample is for Send SMS, Not to Get caller number. It would be great if you can share a sample code that I can use to get the call number when ringing the phone.
Code is almost the same. You just replace the event filter. And parse the response for the number.
I m not clear with this? How/Where can I do this?
And parse the response for the number.
I see you are already doing the right thing in your code.
Then what should be the issue that it is not subscribing when receiving a call?
Hi Tyler,
I checked your sample. But I received the below error. Could you please advise how can I get this off?
Also, I have given all the permissions.
Here is my code snippet
it means you authorize your app using extension 1, and try to subscribe to events for extensions 2. But extension 1 and extension 2 don't belong to the same company.
I tried with the below event URL. Could you please let me know, what are the correct values for the accountId & extensionId parameters? I just use my sandbox user name and extension. If those are wrong where can I find the correct details?
"/restapi/v1.0/account/{accountId}/extension/{extensionId}/telephony/sessions"
Also, I used the same credentials, clientId & secret for the RestClient constructor & Authorize.
Make an API call to /restapi/v1.0/account/~/extension
to get all the extensions, where you can find the extension Ids. If you only need the ID for the current extension, use "~" as ID.
I execute this API and found the accountID. But still not found a way to get the extentionId?
var extInfo = await rc.Restapi().Account("~").Extension("~").Get(); var accId = extInfo.account.id; var extention = extInfo.extensionNumber;
Also, there is no error receiving when I execute the below code, but it does not subscribe when I answer a call even with the 301 extension?
var extInfo = await rc.Restapi().Account("~").Extension("~").Get(); var accId = extInfo.account.id; var pubNubExtension = new PubNubExtension(); await rc.InstallExtension(pubNubExtension); var eventFilters = new[]{ $"/restapi/v1.0/account/{accId}/extension/~/telephony/sessions" }; var messages = new List<string>(); var messageStoreMessageCount = 0; var subscription = await pubNubExtension.Subscribe(eventFilters, message => { messages.Add(message); dynamic jObject = JObject.Parse(message); var eventString = (string)jObject.@event; if (new Regex("/account/\\d+/extension/\\d+/message-store").Match(eventString).Success) { messageStoreMessageCount += 1; var messageEvent = JsonConvert.DeserializeObject<MessageEvent>(message);
var uuid = (messageEvent.uuid); var body = (messageEvent.body); } }); var subscriptionInfo = subscription.SubscriptionInfo; //await SendSms(rc); feature does not enable for Send SMS await Task.Delay(20000); subscriptionInfo = await subscription.Refresh(); await subscription.Revoke();
extensionid = extInfo.id
I got it. And no error when I execute the code. But it's never subscribing when a call is received. Could you please check the above code snippet and advice me why this is not working as expected?
I am on vacation this week. Please create a ticket https://developers.ringcentral.com/support/create-case if the issue persists.
Do not just copy the code. You need to print the message.
- var subscription = await pubNubExtension.Subscribe(eventFilters, message => { Console.WriteLine(message)
- }
And do not Refresh or Revoke
It is the unit test. You don't need those logic because you are not writting an unit test.
And subscription happens once and only once. When there is incoming call, your code will NOT subscribe (because it already did that). Instead, the code in the callback function will be executed. That's why I let you print the message. Otherwise even the messages come you don't know.
I will try to write a sample project after my vacation. Thanks.
I tried with the below code and got the error.
// https://developers.ringcentral.com/my-account.html#/applications // Find your credentials at the above url, set them as environment variables, or enter them below
RestClient rc = new RestClient( Environment.GetEnvironmentVariable("clientId"), Environment.GetEnvironmentVariable("clientSecret"), false );
await rc.Authorize( Environment.GetEnvironmentVariable("username"), Environment.GetEnvironmentVariable("extension"), Environment.GetEnvironmentVariable("password") );
var r = await rc.Restapi().ClientInfo().SipProvision().Post(); // PROCESS RESPONSE
-----------------------------------------------------
{ "errorCode": "SPR-112", "message": "Client edition is not compatible with current Brand", "errors": [ { "errorCode": "SPR-112", "message": "Client edition is not compatible with current Brand" } ] }
Why did you invoke await rc.Restapi().ClientInfo().SipProvision().Post()?
It's for low level SIP and it's probably not what you need.
To get customer phone number, when they call you, you need to create a subscription: https://github.com/ringcentral/RingCentral.Net/blob/master/RingCentral.Tests/SubscriptionTest.cs
And here is the event: https://developers.ringcentral.com/api-reference/Extension-Telephony-Sessions-Event
A new Community is coming to RingCentral!
Posts are currently read-only as we transition into our new platform.We thank you for your patience
during this downtime.
Try Workflow Builder
Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!Try RingCentral Workflow Builder