Watch the webinar: Calls with .NET and Twilio.
- Create a free Twilio account, or log into your existing Twilio account. If you register here, you'll receive $10 in Twilio credit when you upgrade to a paid account!
- Create a Twilio API key (more info on creating API Keys here)
- Create a TwiML Application and take not of the Application SID (leave configuration empty)
- Buy a Twilio phone number using the Twilio CLI or Twilio Console
- Download or clone the source code
- Open a terminal and navigate to the CallPhoneNumber project
cd MakePhoneCalls/CallPhoneNumber
- Configure the Twilio Account SID, API Key SID, API Key Secret, Phone Number, and Application SID using the .NET Secrets Manager:
dotnet user-secrets set Twilio:AccountSid [YOUR_ACCOUNT_SID]
dotnet user-secrets set Twilio:ApiKeySid [YOUR_API_KEY_SID]
dotnet user-secrets set Twilio:ApiKeySecret [YOUR_API_KEY_SECRET]
dotnet user-secrets set Twilio:PhoneNumber [YOUR_TWILIO_PHONE_NUMBER]
dotnet user-secrets set Twilio:ApplicationSid [YOUR_TWIML_APPLICATION_SID]
This configuration will be applied and are shared across all projects that need them.
8. Install and authenticate the ngrok
CLI
Run the console application and provide your Twilio Phone Number to the from:
prompt, and your private phone number to the to:
prompt.
If you want to change the TwiML instructions to use the WebhookService:
- Start the WebhookService application
- Create an ngrok tunnel using
ngrok http [YOUR_WEBHOOK_SERVICE_LOCALHOST_URL]
- Grab the ngrok forwarding URL and replace
http://demo.twilio.com/docs/voice.xml
with the forwarding URL. - Run the console project
Run all the projects in the solution and browse to https://localhost:7000.
- Twilio blog .NET tag
- Twilio SDK for C# and .NET
- Twilio helper library for ASP.NET
- Twilio Docs
- Integrate ngrok into ASP.NET Core startup and automatically update your webhook URLs
- Better Twilio Authentication with API Keys
- How to use Twilio SMS and Voice with a .NET 6 Minimal API
- How to make Phone Calls from Blazor WebAssembly with Twilio Voice