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

Building a caller ID routing plugin


This simple caller ID plugin will let your user assign caller IDs to incoming phone numbers.

We're going to limit this to call flows, so that you can have the caller ID handled differently for each option in a call flow.

For example, if you set up extensions, you could say, if the extension is 1 and the call is coming from 1234567890, forward the call to voice mail; however, if the extension is 2 and the call is coming from 1234567890, call a sales person.

Getting ready

The complete source code for this recipe can be found in the Chapter10/Recipe5 folder in the source code for this book.

How to do it…

Now let's set up a caller ID system. This system will let us define a set of actions based on the caller's phone number. So, for example, you could set it so that when your Mom calls, the system sends her directly to voice mail. Use the following steps to do so:

  1. In the plugins folder, create a folder and name it callerid.

  2. Within the callerid folder, create another...