Book Image

Twilio Cookbook: Second Edition

By : Roger Stringer
Book Image

Twilio Cookbook: Second Edition

By: Roger Stringer

Overview of this book

Table of Contents (20 chapters)
Twilio Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Phones are everywhere! From calling to texting, you use phones for business and personal use. Twilio provides an API that lets you combine phone calls and SMS messages with your websites.

Twilio Cookbook Second Edition will get you on the fast track to learn how to use Twilio with PHP and MySQL to add phone services and SMS to your websites. You'll also quickly learn how to set up systems such as a company directory, PBX, voicemail system, and order-tracking system and how to set up two-factor authentication.

What this book covers

Chapter 1, Into the Frying Pan, covers what you need to know about adding two-factor authentication to a website to verify users, sets up a basic order-verification system, adds the Click-to-Call functionality to a website, records phone calls, sets up a company directory, and explains how to use Twilio Client for Text-to-Speech.

Chapter 2, Now We're Cooking, begins by covering how to create usage records, screen calls to be actually answered by a person, buying a phone number, setting up a voicemail system, and building an emergency calling system.

Chapter 3, Conducting Surveys via SMS, builds a system that lets you add subscribers, build a survey, send surveys to subscribers, and view responses that come back.

Chapter 4, Building a Conference Calling System, shows you how to build a handy conference calling system that includes scheduling, notifying attendees, recording the conference call, joining the call from a browser or a phone, monitoring the conference, and muting attendees.

Chapter 5, Combining Twilio with Other APIs, shows you how to use Twilio with other APIs to add features, such as a local business search via text messages, a movie listings search, a weather lookup, and how to search using Google.

Chapter 6, Sending and Receiving SMS Messages, digs into the many SMS messaging features that Twilio provides, beginning with sending messages from a website, replying to messages from a phone, sending bulk SMS messages to a list of people, SMS order tracking to check on orders, serving a group chat platform, and sending SMS messages from a phone call.

Chapter 7, Building a Reminder System, uses Twilio's SMS services to let you schedule reminders, get notified of reminders, retrieve a list of reminders, cancel a reminder, and add another person to a reminder.

Chapter 8, Building an IVR System, shows you how to set up an Interactive Voice Response system, beginning with a basic phone tree, screening and recording calls, logging and reporting calls, looking up contacts on incoming calls using the HighRiseHQ API, and sending SMS messages to salesforce.com contacts.

Chapter 9, Building Your Own PBX, shows you how to set up subaccounts for each of your users, let the users buy their own phone numbers, accept incoming phone calls, make outgoing calls, and delete their accounts.

Chapter 10, Digging into OpenVBX, takes you into the world of building plugins for the OpenVBX system, starting with a call log plugin, going into a searchable company directory, collecting payments over the phone using Stripe, tracking orders, setting up a caller ID system, and testing call flows.

Chapter 11, Sending and Receiving Picture Messages, shows you how to use Twilio's Picture Messaging protocol to send and receive MMS messages, including sending messages from a phone to a website, building a photo gallery and sending pictures from a website to a phone.

Chapter 12, Call Queuing, introduces you to queuing calls for agents to answer and process. This is handy for call centers.

Chapter 13, Working with Twilio Client, shows you how to build a web-based softphone to handle incoming and outgoing calls without needing to use a phone.

What you need for this book

All you need to get started is a Twilio account; a web host; and a simple text editor, such as Notepad++, Emacs, or Vim; and an Internet connection.

Who this book is for

This book is for programmers who have already used PHP and MySQL in one way or another. It's for people who work with a lot of backend code and want to get up to speed with the world of Twilio. It's for people who want to use the capabilities of Twilio to let their websites handle phone calls and SMS messages.

The book is for both beginners and seasoned developers, assuming that you have some experience in PHP and MySQL already, but an in-depth knowledge is not necessary.

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 are shown as follows: "Let's set up our listener.php file to store all incoming messages and messages.php to view messages we've received."

A block of code is set as follows:

  <?php
    $accountsid = '';  //  YOUR TWILIO ACCOUNT SID
    $authtoken = '';  //  YOUR TWILIO AUTH TOKEN
    $fromNumber = '';  //  PHONE NUMBER CALLS WILL COME FROM
    $myUrl = '';    //  THE URL TO YOUR SCRIPT

    $dbhost = '';    //  YOUR DATABASE HOST
    $dbname = '';    //  YOUR DATABASE NAME
    $dbuser = '';    //  YOUR DATABASE USER
    $dbpass = '';    //  YOUR DATABASE PASS
  ?>

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: "We now have a menu option under the Admin menu called Test Call Flow."

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.

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.