Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

A sample application which shows you how to make and receive phone calls with a browser and Twilio Client

License

Notifications You must be signed in to change notification settings

TwilioDevEd/browser-calls-csharp

Repository files navigation

Twilio

Browser Calls (ASP.NET MVC)

This repository is now archived and is no longer being maintained. Check out the JavaScript SDK Quickstarts to get started with browser-based calling.

About

Learn how to use Twilio's JavaScript SDK to make browser-to-phone and browser-to-browser calls with ease. The unsatisfied customers of the Birchwood Bicycle Polo Co. need your help!

Set up

Requirements

Create a TwiML App

This project is configured to use a TwiML App, which allows us to easily set the voice URLs for all Twilio phone numbers we purchase in this app.

Create a new TwiML app and save its Sid. You will need it to setup your app settings.

Using the twilio-cli ?

twilio api:core:applications:create --friendly-name browser-calls --voice-url [your-app-url]

If not you can do it at https://www.twilio.com/console/voice/twiml/apps/create See the end of the "Local development" section for details on the exact URL to use in your TwiML app.

Once you have created your TwiML app, configure your Twilio phone number to use it (instructions here). If you don't have a Twilio phone number yet, you can purchase a new number in the Twilio Console.

Twilio Account Settings

This application should give you a ready-made starting point for writing your own application. Before we begin, we need to collect all the config values we need to run the application:

Config Value Description
TwilioAccountSid Your primary Twilio account identifier - find this in the console here.
TwilioTwimlAppSid The TwiML application with a voice URL configured to access your server running this app - create one in the console here. Also, you will need to configure the Voice "REQUEST URL" on the TwiML app once you've got your server up and running.
TwilioCallerId A Twilio phone number in E.164 format - you can get one here
TwilioApiKey / TwilioApiSecret Your REST API Key information needed to create an Access Token - create one here.

Local development

After the above requirements have been met:

  1. Clone this repository and cd into it
git clone [email protected]:TwilioDevEd/browser-calls-csharp.git
cd browser-calls-csharp
  1. Set your configuration variables
cd BrowserCalls.Web
copy Web.config.sample Web.config

See Twilio Account Settings to locate the necessary environment variables.

  1. Build the solution

  2. Run Update-Database at Package Manager Console to execute the migrations.

  3. Run the application

  4. Run ngrok (or use the ngrok Visual Studio extension)

ngrok http -host-header="localhost:9932" 9932

Learn 6 awesome reasons why to use ngrok.

  1. Once you have started ngrok, update your TwiML app's voice URL setting to use your ngrok hostname, so it will look something like this:
https://<your-ngrok-subdomain>.ngrok.io/Call/Connect

If you make changes to your ASP.NET application and restart it, there is no need to restart the ngrok tunnel. Leaving it running will avoid getting a new ngrok subdomain and requiring you to update your TwiML app's voice URL.

Note: You must set your webhook urls to the https ngrok tunnel created.

That's it!

Try it out

  1. To create a support ticket go to the home page. On this page you could fill some fields and create a ticket or you can call to support.

    https://<your-ngrok-subdomain>.ngrok.io
    

    Note: Make sure you use the https version of your ngrok URL as some browsers won't allow access to the microphone unless you are using a secure SSL connection.

  2. To respond to support tickets go to the Dashboard page (you should open two windows or tabs). On this page you could call customers and answers phone calls.

    https://<your-ngrok-subdomain>.ngrok.io/Dashboard
    
    

Resources

  • The CodeExchange repository can be found here.

License

MIT

Disclaimer

No warranty expressed or implied. Software is as is.

About

A sample application which shows you how to make and receive phone calls with a browser and Twilio Client

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published