Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Look Who's Talking

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

Look Who's Talking

Avatar for Pablo Cantero

Pablo Cantero

March 09, 2013

More Decks by Pablo Cantero

Other Decks in Programming

Transcript

  1. We had a problem We needed a phone support 24x7

    in case the website becomes unavailable and other possible urgent issues.
  2. Solution We decided to use a Communication as a Service

    (CaaS) to register a fixed phone number in Brazil, which receives a call and redirects it to the developer on duty cellphone.
  3. Why Twilio? • No Contracts • Pay as you go

    • Simple and well documented API
  4. Brazilian pricing • To receive a call = 1¢/minute •

    To make a call = 33¢/minute • To send a text: starts at =1.2¢/message • Fixed brazilian number = 3$/month • Fixed american number = 1$/month
  5. account_sid      =  ENV["TWILIO_ACCOUNT_SID"] auth_token        =

     ENV["TWILIO_AUTH_TOKEN"] twiml_app_sid  =  ENV["TWILIO_TWIML_APP"] capability  =  Twilio::Util::Capability.new   account_sid,  auth_token capability.allow_client_outgoing  twiml_app_sid   token  =  capability.generate
  6. <ul  id="user-­‐list"  data-­‐token="<%=  token  %>"> <%  @users.each  do  |user|  %>

           <li>    <%=  user.name  %>  -­‐      <a  href="#"  rel="phone-­‐number">    <%=  user.name  %>    </a> </li> <%  end  %> </ul>
  7. <ul  id="user-­‐list"  data-­‐token="eyJ0...">    <li>          Pablo

     Cantero          <a  href="#"  rel="phone-­‐number">              +551199...          </a>      </li> </ul>
  8. $  -­‐>    Twilio.Device.setup  $("#user-­‐list").data  "token"      $("a[rel=phone-­‐number]").on  "click",

     (e)  -­‐>        e.preventDefault()        if  Twilio.Device.status()  !=  "ready"            Twilio.Device.disconnectAll()            return        $this  =  $  e.target        Twilio.Device.connect  $this.text()
  9. $(function(){    Twilio.Device.setup($("#user-­‐list").data("token"));      $("a[rel=phone-­‐number]").on("click",  function(e){      

     e.preventDefault();        if(Twilio.Device.status()  !==  "ready"){            Twilio.Device.disconnectAll();            return;        }        $this  =  $(e.target);        Twilio.Device.connect($this.text());    }); });
  10. #  /etc/monitrc   check  host  localhost  with  address  127.0.0.1  

     if  failed  port  8080        with  timeout  15  seconds        then        exec  "ruby  /usr/bin/notify-­‐site-­‐is-­‐down.rb'"
  11. #  /usr/bin/notify-­‐site-­‐is-­‐down.rb   require  "rubygems" require  "twilio-­‐ruby"   account_sid  =

     ENV["TWILIO_ACCOUNT_SID"] auth_token    =  ENV["TWILIO_AUTH_TOKEN"]   @client  =  Twilio::REST::Client.new(account_sid,   auth_token)   @client.account.SMS.messages.create(    from:  "+5511…",    to:  "+5511…",    body:  "Houston  we  have  a  problem,  the  website  is   down." )
  12. Twimlets https://www.twilio.com/labs/twimlets Twimlets are tiny web applications that implement basic

    voice and text functionality. Think of them as "Widgets" in the web world.
  13. Apps which talk • Alerts & Notifications • Rewards •

    Reminders • System administration • Sales Automation • Bike Sampa • Identity Verification • Security token • Support Roulette ;)