Warning - this application has not been updated for .NET Core 2.1 yet - it will run on .NET Core 1.0.4.
This sample project demonstrates how to use Twilio APIs in a C# web application. Once the app is up and running, check out the home page to see which demos you can run. You'll find examples for Chat, Video, Sync, and more.
Let's get started!
- Install .NET Core.
To run the application, you'll need to gather your Twilio account credentials and configure them
in a file named appsettings.json
in the src/sdkstarter
directory. To create this file from an example template, do the following in your Terminal.
Windows
cd src\sdkstarter
copy .\appsettings.example.json .\appsettings.json
OS X or Linux
cp appsettings.example.json appsettings.json
Every sample in the demo requires some basic credentials from your Twilio account. Configure these first.
Config Value | Description |
---|---|
TWILIO_ACCOUNT_SID |
Your primary Twilio account identifier - find this in the console here. |
TWILIO_API_KEY |
Used to authenticate - generate one here. |
TWILIO_API_SECRET |
Used to authenticate - just like the above, you'll get one here. |
When you generate an API key pair at the URLs above, your API Secret will only be shown once -
make sure to save this information in a secure location, or possibly your ~/.bash_profile
.
Depending on which demos you'd like to run, you may need to configure a few more values in your
appsettings.json
file.
Twilio Sync works out of the box, using default settings per account. Once you have your API keys configured and your Java application built and running, open a browser!
In addition to the above, you'll need to generate a Chat Service in the Twilio Console. Put the result in your appsettings.json
file.
Config Value | Where to get one. |
---|---|
TWILIO_CHAT_SERVICE_SID |
Chat |
You will need to create a Notify Service and add at least one credential on the Mobile Push Credential screen (such as Apple Push Notification Service or Firebase Cloud Messaging for Android) to send notifications using Notify.
Config Value | Where to get one. |
---|---|
TWILIO_NOTIFICATION_SERVICE_SID |
Generate one in the Notify Console and put this in your appsettings.json file. |
A Push Credential | Generate one with Apple or Google and configure it as a Notify credential. |
Once you've done that, run the application and open a browser!
Open sdkstarter.sln
and press F5 or click the Run button
cd src/sdkstarter
dotnet restore
dotnet run
Your application should now be running at http://localhost:3000/. (If you are running from Visual Studio, a random port number may be selected as opposed to 3000.)
Check your config values, and follow the links to the demo applications!
If you are going to connect to this SDK Starter Kit with a mobile app (and you should try it out!), your phone won't be able to access localhost directly. You'll need to create a publicly accessible URL using a tool like ngrok to send HTTP/HTTPS traffic to a server running on your localhost. Use HTTPS to make web connections that retrieve a Twilio access token.
ngrok http 3000
dotnet test sdkstarter.Test/sdkstarter.Test.csproj
MIT