Book Image

Twilio Best Practices

Book Image

Twilio Best Practices

Overview of this book

Table of Contents (15 chapters)
Twilio Best Practices
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

The Twilio platform makes it simple to integrate telephony—both calls as well as SMS and MMS messages—into your code without expensive hardware requiring a manual setup. However, getting started on such a powerful platform can be daunting.

This book will teach you how to build powerful real-time applications on the Twilio platform from start to finish, making use of phone calls and SMS messages. You'll be introduced to TwiML, the REST API, and Twilio Client before you start building two real-life applications and diving deeper into issues such as testing and security.

What this book covers

Chapter 1, Working with TwiML, covers TwiML, which is Twilio's XML-based language, that directs how Twilio handles incoming calls and SMSes and places outgoing calls. The actions in TwiML are called verbs, and we'll look at all of them and how they're used.

Chapter 2, Exploring the REST API, takes you through interacting with the data in your Twilio account, as well as placing calls and sending SMS messages. You'll learn how to set up the PHP API library, how to interact directly with the API using a tool called Postman, and how to use the API's most useful features.

Chapter 3, Calling in the Browser with Twilio Client, introduces Twilio Client, which is a way of making and receiving phone calls directly within your applications, in a browser or mobile app, without using a physical phone. You'll discover how this works at a high level and how to practically implement it in your code.

Chapter 4, Twilio in the Real World, takes you through building two real Twilio applications: a callback request tool for your website and a simple conference calling service with fully explained code samples.

Chapter 5, Twilio in your language, goes beyond the PHP code we've used in most of the book, showing how to download and configure Twilio's API libraries for Ruby, Python, C#, Java, Node, and Salesforce.com.

Chapter 6, Securing your Twilio App, helps you keep your application and Twilio credit secure with two-factor authentication on your Twilio account. We will verify that the requests you're receiving really come from Twilio and will set up a circuit breaker to detect bugs and account misuse.

Chapter 7, Testing, Debugging, and Deploying Twilio Apps, explains how to test your apps before you release them into the wild and then how to monitor and maintain them later using the App Monitor and Request Inspector.

Chapter 8, Online Resources, contains some helpful links to help you get the most from this book and follow Twilio's best practices.

What you need for this book

For this book, you'll need a computer with a text editor and a web browser. You'll also need a web server to run PHP code. You can use a paid hosting provider (see Chapter 8, Online Resources, for recommendations) or set this up on your own computer.

If you'd like to run a PHP-compatible web server on your own computer:

Who this book is for

If you're a developer in any programming language looking to get started with integrating Twilio into your applications, or if you're hoping to perfect your skills after already trying Twilio, then this book is for you.

This book will provides full code samples in PHP, JavaScript, and HTML, but it will be useful no matter what language you choose to use, showing you how to structure your applications, plus how and where to interact with Twilio.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The <Play> verb lets you play audio."

A block of code is set as follows:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>Twilio Best Practices is number one!</Say>
</Response>

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

<p>
   access this conference, participants should dial
   <your phone number here> and use access code {{
   $conference->access_code }}.
 </p>

Any command-line input or output is written as follows:

composer require "watson/validating:0.10.*"

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Once you've got your number, head back to the Numbers screen and click on the one you've just bought."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.