Extending Click-to-Call to Simultaneously Call Multiple Numbers
Time to read: 2 minutes
Simultaneously Call Multiple Numbers with Click-to-Call
Click-to-call is one of our most popular examples. With click-to-call you can allow visitors to your web site call you directly with a couple clicks. The process usually goes like this: the visitor enters their phone number on the web site and submits the form, a call is initiated to the visitor, once they answer the phone another call is initiated to the company and the two ends are connected.
Instead of having the application just call one number, what if we wanted to have it dial 5, 10, or more numbers simultaneously and let the first person who answers take care of the call? If no one answers after a short period of time, we’ll prompt the caller to record a message. In this post I’ll start with the existing click-to-call example and update it to support dialing multiple numbers simultaneously.
Key Changes in This Example
This example will update the current click-to-call example in a few key places:
- After the visitor submits the form our application will call them first instead of calling the agent first.
- Once the visitor answers the phone we will play a short message indicating that we are connecting their call.
- After the message we’ll use Twilio’s simultaneous dial technique to connect the visitor to an agent.
- If no agents respond after 30 seconds we’ll prompt the caller to record a message.
Starting the Call
We’ll start by adding a form to our HTML to collect the visitor’s phone number.
Once the user presses submit, the form sends the number (via POST) to makecall.php. Makecall.php uses the free Twilio PHP Helper library to call the company’s phone number. I’ve removed some of the error handling in the original example for brevity.
Handling the Call Once Connected
At this point the web site visitor’s phone will be ringing. When they answer, Twilio will process the TwiML returned from callback.php to direct the call. Again we’ll use the Twilio PHP Helper library to generate and output the TwiML.
Simultaneous dial isn’t the right solution in every situation. You should take care to use simultaneous dial in situations where you know the behavior of the called parties. Keep in mind that the first phone that picks up cancels all the other connections. If you dial an office phone system or a cellphone in airplane mode, it may pick up after a single ring, preventing the other phones from ringing long enough for a human to ever answer.
Related Posts
Related Resources
Twilio Docs
From APIs to SDKs to sample apps
API reference documentation, SDKs, helper libraries, quickstarts, and tutorials for your language and platform.
Resource Center
The latest ebooks, industry reports, and webinars
Learn from customer engagement experts to improve your own communication.
Ahoy
Twilio's developer community hub
Best practices, code samples, and inspiration to build communications and digital engagement experiences.