O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Twilio Best Practices

Book Description

Learn how to build powerful real-time voice and SMS applications with Twilio

In Detail

Twilio makes it simple to integrate telephony - both phone calls as well as SMS and MMS messages - into your code without expensive hardware or manual setup.

This is an in-depth guide to working with the Twilio platform from start to finish, making it easy for any developer to integrate phone calls and SMS messages into their code.

Packed with lots of code examples, this book gets you up and running with Twilio in no time, enabling you to work with messages and calls in a variety of different ways. You'll not only learn how to build basic applications using Twilio, but also how to exploit Twilio's most powerful features, keep your Twilio integration secure, and test and debug the application thoroughly.

This book is the perfect guide from your first steps working with Twilio right up to becoming an expert, giving you all the best practices and top tips you need to build reliable and powerful telephony applications.

What You Will Learn

  • Develop applications that make and receive phone calls and messages
  • Access your call and SMS records and much more with the Twilio REST API
  • Replace physical phone hardware with calls in your browser or mobile app
  • Build powerful applications such as phone menus, call centers, and conferencing services
  • Work with Twilio in any programming language
  • Secure your application
  • Debug and test your Twilio integration thoroughly

Table of Contents

  1. Twilio Best Practices
    1. Table of Contents
    2. Twilio Best Practices
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Working with TwiML
      1. Where in my application will I be using TwiML?
      2. Getting started with TwiML
      3. Digging deeper – Twilio's requests
      4. The world of TwiML verbs
        1. <Say>
        2. <Play>
          1. <Pause>
        3. <Gather>
        4. <Record>
        5. <Message>
        6. <Enqueue>
          1. <Leave>
        7. <Dial>
          1. <Number>
          2. <Sip>
            1. SIP authentication
              1. Username and password protection
              2. Working with IP whitelisting
          3. <Client>
          4. <Conference>
          5. <Queue>
          6. <Hangup>
          7. <Redirect>
          8. <Reject>
      5. Best practices for working with TwiML
        1. Test locally using ngrok
          1. Windows
          2. Mac OS X and Linux (and others!)
        2. Make your application resilient with a fallback URL
        3. Use Twilio's applications to manage your TwiML URLs
      6. Summary
    9. 2. Exploring the REST API
      1. What is the Twilio REST API?
      2. Interacting with the API
        1. Authentication
        2. Fetching existing data
          1. Listing records
            1. Pagination
          2. Fetching an individual record
        3. Creating new records
        4. Modifying existing records
        5. Deleting an existing record
        6. Handling errors
      3. Getting started with the Twilio PHP library
        1. Downloading the PHP library
          1. Downloading the code manually
          2. Using a package manager
        2. Getting started
      4. Getting started with Postman
        1. Making your first request with Postman
        2. Getting the most out of Postman
          1. Sending parameters
          2. Using History and Collections
      5. Mastering call-related APIs
        1. Making a call
        2. Working with an existing call
        3. Listing previous calls
      6. Mastering messaging APIs
        1. Sending your first SMS
        2. Sending images using MMS
        3. Fetching an existing message
        4. Listing previous messages
      7. Working with phone numbers, accounts, and usage
        1. Phone numbers
          1. Outgoing caller IDs
          2. Short codes
        2. Accounts
          1. Creating a subaccount
          2. Managing an account's resources
          3. Suspending or closing a subaccount
            1. Suspending an account
            2. Closing an account
        3. Usage
      8. Summary
    10. 3. Calling in the Browser with Twilio Client
      1. What is Twilio Client?
      2. Where can I use Twilio Client?
      3. How does Twilio Client work?
        1. Setting up the client
        2. Placing outgoing calls
        3. Receiving inbound calls
        4. Interacting with calls in progress
      4. Adding Twilio Client to your web applications
        1. Setting up a TwiML application
        2. Building the frontend
        3. Generating a client token
        4. Powering our interactions with JavaScript
        5. Adding the TwiML
        6. Our very first Twilio Client call
      5. Receiving incoming calls in the browser
      6. Getting started with Twilio Client on iOS and Android
      7. Summary
    11. 4. Twilio in the Real World
      1. The callback request tool
        1. Preparing the project
          1. Installing the Twilio API library
          2. Preparing the MySQL database
          3. Creating a configuration file
        2. Creating the request form
        3. Responding to a callback request from an e-mail
        4. Writing the TwiML
        5. Listening for a call's status
        6. Wrapping up
      2. The conference calling tool
        1. Preparing the project
          1. Setting up your environment
          2. Setting up Laravel
          3. Setting up our database
        2. Building the CRUD interface
        3. Handling inbound calls
        4. Archiving conferences and storing recordings
      3. And you're done!
      4. Summary
    12. 5. Twilio in your language
      1. PHP – a recap
      2. Ruby
      3. Python
      4. C#
      5. Java
      6. Node.js
      7. Apex for Salesforce.com
      8. Summary
    13. 6. Securing your Twilio App
      1. Enabling two-factor authentication
      2. Verifying that requests are from Twilio
        1. HTTP Basic Authentication
        2. Verifying the signature
      3. Building a circuit breaker
      4. Summary
    14. 7. Testing, Debugging, and Deploying Twilio Apps
      1. The power of flowcharts
        1. A word on automated testing
      2. Using the App Monitor
        1. Using Triggers in the App Monitor
      3. Using the Request Inspector
      4. Fixing common errors
        1. 112** – HTTP errors
        2. 11750 – TwiML response body too large
        3. 12100 – document parse failure
        4. 13227 – no international authorization
        5. 13223-6 – phone number errors
      5. Summary
    15. 8. Online Resources
      1. Hosting providers
      2. Web frameworks
      3. Automated testing
      4. Using flowcharts
      5. What next?
    16. Index