We are currently in the process of updating this sample template. If you are encountering any issues with the sample, please open an issue at github.com/twilio-labs/code-exchange/issues and we'll try to help you.
Learn how to use Twilio Client to make browser-to-phone and browser-to-browser calls with ease. The unsatisfied customers of the Birchwood Bicycle Polo Co. need your help.
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.
-
First clone this repository and
cd
into its directory:git clone https://github.com/TwilioDevEd/browser-calls-csharp.git cd browser-calls-csharp
-
Create a copy of
BrowserCalls.Web/Web.config.sample
and rename it toBrowserCalls.Web/Web.config
. -
Open
BrowserCalls.Web/Web.config
and update the following keys:<appSettings> <!-- omitted for clarity --> <add key="TwilioAccountSid" value="TWILIO_ACCOUNT_SID" /> <add key="TwilioAuthToken" value="TWILIO_AUTH_TOKEN" /> <add key="TwiMLApplicationSid" value="TWIML_APPLICATION_SID" /> <add key="TwilioPhoneNumber" value="TWILIO_PHONE_NUMBER" /> </appSettings>
-
Build the solution.
-
Run
Update-Database
at Package Manager Console to execute the migrations. -
Run the application.
-
Check it out at http://localhost:9932
To actually forward incoming calls, your development server will need to be publicly accessible. We recommend using ngrok to solve this problem.
-
To start your ngrok tunnel, run this from a command line (after downloading ngrok):
ngrok http -host-header="localhost:9932" 9932
Or, you can install Ngrok Extensions for Visual Studio.
-
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:
http://<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.
-
Finally, open up the dashboard for the app http://localhost:9932/Dashboard -- from here you can answer incoming calls and make outbound calls for open support tickets.
- No warranty expressed or implied. Software is as is. Diggity.
- MIT License
- Lovingly crafted by Twilio Developer Education.