Skip to content

TwilioDevEd/airtng-csharp-dotnet-core

Repository files navigation

Twilio

AirTNG App: Part 1 - Workflow Automation with Twilio - ASP.NET Core MVC

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.

About

Learn how to automate your workflow using Twilio's REST API and Twilio SMS. This example app is a vacation rental site, where the host can confirm a reservation via SMS.

Read the full tutorial here!

Implementations in other languages:

Python Java Node PHP Ruby
Done Done Done Done TBD

Set up

Requirements

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

Local development

After the above requirements have been met:

  1. Clone this repository and cd into it
git clone [email protected]:TwilioDevEd/airtng-csharp-dotnet-core.git
cd airtng-csharp-dotnet-core
  1. Build to install the dependencies
dotnet build
  1. Set your environment variables
cp AirTNG.Web/twilio.json.example AirTNG.Web/twilio.json

See Twilio Account Settings to locate the necessary environment variables.

  1. Install EF Core CLI if it's not already installed.
dotnet tool install --global dotnet-ef --version 3.0.0
  1. Create the local DB. This also should be executed in AirTNG.Web directory.
dotnet ef database update
  1. Run the application
dotnet run --project AirTNG.Web
  1. Navigate to http://localhost:5000

  2. To let our Twilio phone number use the callback endpoint we exposed, our development server will need to be publicly accessible. You could expose the application to the wider Internet using ngrok. Here, there is an interesting article about why we recommend you to use ngrok.

ngrok http 5000

Keep in mind that our endpoint is:

https://<your-ngrok-subdomain>.ngrok.io/Sms/Handle
  1. Register your webhook with your Twilio Number at https://www.twilio.com/console/phone-numbers/. Your webhook url should include the ngrok host from the previous step and should look similar to https://<your-ngrok-subdomain>.ngrok.io/Sms/Handle.

    Configure Messaging

That's it!

Docker

If you have Docker already installed on your machine, you can use our docker-compose.yml to setup your project.

  1. Make sure you have the project cloned.
  2. Setup the twilio.json file as outlined in the Local Development steps.
  3. Run docker-compose up.
  4. Follow the steps in Local Development on how to expose your port to Twilio using a tool like ngrok and configure the remaining parts of your application.

Tests

You can run the tests locally by typing:

dotnet test

Resources

  • The CodeExchange repository can be found here.

Contributing

This template is open source and welcomes contributions. All contributions are subject to our Code of Conduct.

Visit the project on GitHub

License

MIT

Disclaimer

No warranty expressed or implied. Software is as is.

About

No description or website provided.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published