2

I've searched here and in many forums. Here's what I'm trying to do.

I'm trying to create a system on php/mysql so a twilio phone number on a page will round robin through a list of phone numbers.

The numbers a specific twilio number relates to is this:

555-1212

555-3434

555-5656

555-7878

So it would be something like this:

twilio number called XX time : which number is dialed

1 : 555-1212

2 : 555-3434

3 : 555-5656

4 : 555-7878

5 : 555-1212

6 : 555-3434

etc.

Any advice or pointing me in the correct direction, i would truly appreciate it. I'm not sure how to or where to turn to help get this done.

  • I am trying to so something similar with SMS and Twilio so may be I can help. Can you be a bit more specific with your question so that I can see what exactly are you trying to do? – Maximus2012 Aug 01 '13 at 15:22
  • I'm trying to create a website that has a phone number on it (say, a phone number for a school). When you call that number, it has different secretary offices (A,B,C,D). I want to create something where the main number is called, and then it goes and calls phone number A the first time, the second time someone calls the main number, number B is called, C, then D. Once D is called (which would be the 4th call), the 5th call goes back to A. – Phil Krnjeu Aug 01 '13 at 23:04
  • could you store some sort of timestamp in your database to indicate when was the last time a particular phone no. was called and then based on that, call the next phone no. in the queue ? – Maximus2012 Aug 02 '13 at 13:14

1 Answers1

1

Twilio evangelist here.

I'd suggest checking out the Call Screening HowTo which shows you how to build almost exactly what your describing in PHP.

I believe the only change you would have to make to the sample code is to this line of code:

$number_index = isset($_REQUEST['number_index']) ? $_REQUEST['number_index'] : "0";

This line checks to see if a parameter named number_index is present and if not sets it to zero.

What you will need to change is to add a second check to see if the number_index is also equal to the last of the array and if it is, set the value to zero so the loop continues.

$number_index = isset($_REQUEST['number_index']) ? $_REQUEST['number_index'] : "0";
if ($number_index >= count($number)) $number_index = 0;

If course doing this will create an infinite loop, so I'd also suggest adding a way to short circuit that loop. You could add an additional parameter that lets you track how many times you've looped through your array and once that reaches a max, kills the loop.

Devin Rader
  • 10,260
  • 1
  • 20
  • 32