Note: This tutorial makes use of this simple Twilio Click-to-Call recipe, which includes the three PHP files referenced below:
- Navigate to Phone Numbers and click “Buy a new number”, then search and choose a phone number you like (make sure it supports “Voice” capabilities, and not just SMS or Fax)
- Click on the Phone Number you’d like to manage and under “Configure > Voice & Fax” add a Webhook to the URL where your
call-tracking.phpfile will be publicly available (ie. “example.com/call-tracking.php”).
- Copy & replace the following values in
- Twilio Phone Number (the number you bought from Twilio)
- Your Phone Number (the masked number you’d like to receive the call)
- Your Twilio Account SID & Auth Token (from here)
Be sure you have replaced the following lines:
- line 28,
- line 21 & 22,
- line 3,
- line 43,
clickToCall.phpto any LAMP server (make sure PHP is installed) and copy the official Twilio PHP Helper library (download from Github / install via Composer) into the same directory under
- Now you can paste the HTML snippet in
clickToCall-form.htmlanywhere online that you’d like to add click-to-call functionality 🎉 — simply update line 33 with your URL if needed.
- Voilà! You can test your click-to-call solution by calling your own numbers, and you should see your call activity appear under “Voice > Overview” in the Twilio Dashboard. Make sure you have paid to upgrade from a “Trial” account before testing — otherwise you can only call “Verified Numbers” and the Twilio trial message will always play.