nexmo-community / receive-sms-aspnet-core-signalr

Demo app showing how to receive an SMS with ASP.NET Core MVC and SignalR

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to Receive an SMS Message with ASP.NET Core MVC and SignalR

Nexmo is now known as Vonage

This project demonstrates how to go about receiving SMS messages from the Vonage Messaging API using ASP.NET Core MVC and SignalR. With this project you'll be able to launch the supplied app, configure your Vonage API Webhooks, and receive SMS messages in real time directly into your browser.

Welcome to Vonage

If you're new to Vonage, you can sign up for a Vonage API account and get some free credit to get you started.

Prerequesites

Testing

We're going to going to test this with Ngrok to test this demo. Ngrok allows us to build a publicly accessible tunnel to our app, which is very useful when we need to expose publicly accessible http endpoints to our apps. If you are going to be testing this with IIS Express like I am, you will want to check out our explainer on the subject as there are special considerations. What this boils down to is that we need to add a --host-header option when we are starting up ngrok.

IIS Express Config

Start Ngrok

Next we'll start up ngrok. We'll point incoming requests to the port from our app url, and we will have the host and port replace the incoming host header. This can all be done by running the following command (replace the port number with your port).

ngrok http --region=us --host-header="localhost:51835" 51835

This command will result in your terminal being taken over by ngrok, it will show you a url that all requests will be forwarded from, this will be of the form http://randomhash.ngrok.io my random hash came up d98024d97b04 so for the remainder of this explainer just replace that value with whatever value came up for yours.

ngrok

After starting up my app in IIS Express, I can navigate to my ngrok url to ensure that it's publicily accessible.

Configure Webhooks

The route to the SMS controller in the case of the above is: http://d98024d97b04.ngrok.io/webhooks/inbound-sms adjust the hash for whatever your hash is. The last thing needed before testing is to tell the Vonage SMS API where to send the messages (the URL just mentioned).

To do this, navigate to https://dashboard.nexmo.com/settings. Under Default SMS Settings, set the Inbound Messages field to the that url, and change the HTTP Method to POST-JSON. Click Save Changes and we're ready to test. Navigate to your home page and go ahead and send your Vonage API Virtual number a test message. If you're not certain what your Vonage Virtual Number is, you can find it in your dashboard under numbers.

Getting Help

We love to hear from you so if you have questions, comments or find a bug in the project, let us know! You can either:

Further Reading

About

Demo app showing how to receive an SMS with ASP.NET Core MVC and SignalR


Languages

Language:C# 44.2%Language:HTML 36.4%Language:CSS 12.5%Language:JavaScript 6.8%