Recieve SMS using C#

  • 1
  • Question
  • Updated 2 weeks ago
How can I receive SMS using C#

So I can send SMS using the api. But can't seem to find a way to receive them. Is it even possible? At this point I think I need something like ngrok? But Im not sure where to start.

Thanks In Advance
Photo of Rick Smith

Rick Smith

  • 412 Points 250 badge 2x thumb

Posted 3 weeks ago

  • 1
Photo of Tyler Long

Tyler Long, Official Rep

  • 8,492 Points 5k badge 2x thumb
If you want to receive sms in real time, check this: https://github.com/ringcentral/ringcentral-csharp-client/blob/master/RingCentral.Test/SubscripotionT... It is powered by PubNub, so you don't need ngrok.

Alternatively, you can check WebHook which does require a public address: https://github.com/ringcentral/ringcentral-csharp-client/blob/master/RingCentral.Test/WebHookTest.cs

Or if you don't need real time sms notification, you can retrieve sms via HTTP GET /restapi/v1.0/account/~/extension/~/message-store

Photo of Rick Smith

Rick Smith

  • 412 Points 250 badge 2x thumb
Tyler

Thanks again! I will try these.
Photo of Rick Smith

Rick Smith

  • 412 Points 250 badge 2x thumb
Tyler

Hmm I just plugged it in and tried the PubNub variant, It has an error can't quite figure out.

 await subscription.Register(); //Throws Object Reference not set to instance of object...



Photo of Tyler Long

Tyler Long, Official Rep

  • 8,432 Points 5k badge 2x thumb
I have written a sample project and it runs pretty smooth without the "Object Reference not set to instance of object" error. https://github.com/tylerlong/RingCentralPasswordFlow/tree/PubNub

Could you please have a try? Pay attention it is the PubNub branch instead of master branch.

The code is pretty simple: https://github.com/tylerlong/RingCentralPasswordFlow/blob/PubNub/RingCentralPasswordFlow/Program.cs#...
Photo of Rick Smith

Rick Smith

  • 412 Points 250 badge 2x thumb
Tyler,

Thanks, It will compile, its not doing anything however. Not sure what Im doing wrong here? I think I have the ring central server URL wrong, what are you using, can't seem to find this information...

Using this: Must be wrong??
 Environment.GetEnvironmentVariable("/restapi/v1.0/account/~/extension/~/message-store")
            );

(Edited)
Photo of Tyler Long

Tyler Long, Official Rep

  • 8,432 Points 5k badge 2x thumb
I use Environment.GetEnvironmentVariable in my code because I don't want to hard code my credentials there.  You don't have to copy my example as long as you have ways to protect your credentials.

Environment.GetEnvironmentVariable("/restapi/v1.0/account/~/extension/~/message-store");  is wrong.  "/restapi/v1.0/account/~/extension/~/message-store" is the event filter string itself.

Let me explain the env vars:

RINGCENTRAL_CLIENT_ID: client ID of your RingCentral App
RINGCENTRAL_CLIENT_SECRET: client secret of your RingCentral App
RINGCENTRAL_SERVER_URL: https://platform.devtest.ringcentral.com for sandbox and https://platform.ringcentral.com for production.
RINGCENTRAL_USERNAME: username, this is normally in the form of a phone number
RINGCENTRAL_EXTENSION: such as 101, if your username is a direct number, you can set this to an empty string
RINGCENTRAL_PASSWORD: password


Photo of Rick Smith

Rick Smith

  • 412 Points 250 badge 2x thumb
Thanks I do, I was just going fast, dumb of me I know ;{ Anyway Its now  throwing NullReferenceException

"FlurlHttpException was null"



Photo of Tyler Long

Tyler Long, Official Rep

  • 8,432 Points 5k badge 2x thumb
Do you mind posting a simple project to reproduce the issue to GitHub? Like the one I posted above?   Remember hide your credentials in environment variables.