Git Product home page Git Product logo

twilio-webrtc-ruby's Introduction

Twilio + WebRTC + Web Audio API = Awesome

Setup

git clone <this repo>

gem install sinatra

gem install twilio

export TWILIO_ACCOUNT_SID=YOUR_ACCOUNT_SID
export TWILIO_AUTH_TOKEN=YOUR_AUTH_TOKEN

Get the app on the public Internet

###Option #1

Deploy to the hosting provider or PaaS of choice. Remember to replicate the environment variables to your production environment.

###Option #2

Use a tool like Ngrok to tunnel localhost.

View the Presentation

Go to http://yourdomain/index.html in your browser.

Connect it to Twilio

  1. Sign-up for a free Twilio account
  2. Purchase a new Twilio number or use the one you are given
  3. Set your Messaging Request URL to http://yourdomain/sms and HTTP GET.

Send and Receive SMS

Send a text message to your new Twilio number. You should get a canned response. Have a few people send a text to that phone number as well.

Voice

Create a new TwiML app. Give it a name and set the Voice Request URL to http://yourdomain/random. Save the TwiML app and copy the App SID.

Edit index.rb and paste the App SID into line 34. Save index.rb and restart Sinatra.

Go to slide 12 and open up the JavaScript console. Enter the following commands:

$.ajax('/token').done(function(data) { Twilio.Device.setup(data); });
Twilio.Device.connect(function(conn) { console.log(conn); window.stream = conn.mediaStream.stream; });
Twilio.Device.connect();

When the browser asks for permission to access your microphone, say "Accept". Your browser will then dial a random person who sent you an SMS earlier and you'll be connected. Say "hi" to your friend.

Visualize the call!

Ok, don't hang up! Now it's time to visualize the call. Go to slide 13. In the JS console:

visualizeMediaStream(window.stream);

You should see a lovely visualization of the audio in your microph

Meta

  • No warranty expressed or implied. Software is as is.
  • MIT License
  • Made with โ™ฅ by Twilio Seattle

twilio-webrtc-ruby's People

Contributors

crtr0 avatar enilsen16 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.