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

TwilioDevEd/client-quickstart-csharp

Repository files navigation

⚠️

This is a deprecated project.

Please go to the Twilio Voice JavaScript SDK quickstart for C#

⚠️

Twilio Client Quickstart for C# (ASP.NET MVC)

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

Config Value Description
Account SID Your primary Twilio account identifier - find this in the console here.
Auth Token Used to authenticate - just like the above, you'll find this here.
TwiML App SID 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.
Twilio Phone # A Twilio phone number in E.164 format - you can get one here

Setting Up The Application

  1. After downloading or cloning this application, create a new file in ClientQuickstart (at the same level as ClientQuickstart\Web.config) called Local.config.

  2. Next, open up ClientQuickstart.sln in Visual Studio. Edit Local.config with the four values we obtained above:

    <appSettings>
      <add key="TwilioAccountSid" value="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" />
      <add key="TwilioAuthToken" value="your_auth_token" />
      <add key="TwilioTwimlAppSid" value="APXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" />
      <add key="TwilioCallerId" value="+1XXXYYYZZZZ" />
    </appSettings>
  3. Hit F5 or the Play button, and you should land on the home page of our basic voice application. The URL in your browser should be localhost:XXXX, where XXXX is the port number of your app. Take note of this port number.

  4. Download and install ngrok

Learn 6 awesome reasons why to use ngrok.

  1. Run ngrok, replacing the two occurrences of XXXX in the following command with the port number of your app:

    ngrok http -host-header="localhost:XXXX" XXXX
  2. When ngrok starts up, it will assign a unique URL to your tunnel. It might be something like https://asdf456.ngrok.io. Take note of this.

  3. Configure your TwiML app's Voice "REQUEST URL" to be your ngrok URL plus /voice. For example:

    screenshot of twiml app

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

You should now be ready to rock! Make some phone calls. Open it on another device and call yourself. Note that Twilio Client requires WebRTC enabled browsers, so Edge and Internet Explorer will not work for testing. We'd recommend Google Chrome or Mozilla Firefox instead.

screenshot of phone app

License

MIT