This app shows how to build a an SMS relay to and from your phone using a Twilio number. Since the other party only sees your Twilio number, this effectively allows you to mask your phone number for privacy purposes.
After the above requirements have been met:
- Clone this repository and
cd
into it
git clone [email protected]:twilio-samples/sms-anonymous-csharp
cd sms-anonymous-csharp
- Add necessary nuget packages.
dotnet add package Twilio
dotnet add package Twilio.AspNet.Core
dotnet add package Twilio.TwiML.Messaging
- Add your Phone Number
In the file SmsController.cs
look for the variable myNumber
and replace the placeholder with the number you wish to forward the SMS messages to.
- Build to install the dependencies
dotnet build
- Run the application
dotnet run
- Use ngrok or other tunneling service to expose your application to the internet
You will need to use ngrok or another tunneling service to allow Twilio to reach your running application. Use the following command, replacing the port number that's shown here with the port that your application is running on.
ngrock http http://localhost:5213
- Set your ngrok endpoint as a Webhook in the Twilio console. Remember to append /sms to the ngrok URL.
- The CodeExchange repository can be found here.
No warranty expressed or implied. Software is as is.