/browser-calls

Primary LanguageRubyMIT LicenseMIT

Twilio

Browser Calls - Rails

Build Status

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!

Read the full tutorial here!

Quickstart

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 at https://www.twilio.com/console/phone-numbers/dev-tools/twiml-apps and use its Sid as the TWIML_APPLICATION_SID environment variable wherever you run this app.

Creating a TwiML App

See the end of the "Local development" section for details on the exact URL to use in your TwiML app.

Local development

This project is built using the Ruby on Rails web framework. It runs on Ruby 2.3.1.

  1. First clone this repository and cd into it:

    git clone git@github.com:TwilioDevEd/browser-calls-rails.git
    cd browser-calls-rails
    
  2. Install the dependencies

    $ bundle
  3. Copy the sample configuration file and edit it to match your configuration

    $ cp .env.example .env

    You can find your TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN in your Twilio Account Settings. You will also need a TWILIO_NUMBER, which you may find here.

    Run source .env to export the environment variables

  4. Create database and run migrations

    Make sure you have installed PostgreSQL. If on a Mac, I recommend Postgres.app.

    $ bundle exec rake db:setup
  5. Make sure the tests succeed

    $ bundle exec rspec
  6. Run the server

    $ bundle exec rails s
  7. Expose your application to the wider internet using ngrok. This step is important because the application won't work as expected if you run it through localhost.

    $ ngrok http 3000

    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
    

    You can read this blog post for more details on how to use ngrok.

Meta

  • No warranty expressed or implied. Software is as is. Diggity.
  • MIT License
  • Lovingly crafted by Twilio Developer Education.