Post

Another Random Media & Technology Post

WordPress + Twilio Text Notifications

WordPress + Twilio Text Notifications

Text notifications have become an important tool for communicating with clients and customers. Getting started with a Twilio account is free and the Twilio platform offers a number of exciting options for automating SMS & MMS communications. If you have a WordPress website, creating WordPress + Twilio text notifications turns out to be pretty simple!

When I first started working with the platform, I realized how easy it is to set up a notification on my own websites for alerting me when someone sends me an inquiry about Web Design or our Guest Suite.  Getting a text means I don’t have to always check my email to know right away when I’ve gotten an inquiry!

You can download Core Twilio Plugin for WordPress here. Once activated, you can add this code to the top of your theme’s functions.php file:

<?php 
use Twilio\Rest\Client;

Then, you can create a hook to any other WordPress plugin as shown below for the Booking Calendar and the Contact7 Plugins.


function text_notice() 
{
 $account_sid = 'Your Twilio Account SID'; 
 $auth_token = 'Your Twilio Auth Token'; 
 $client = new Client($account_sid, $auth_token);
 $to = 'Your Phone Number';
 $client->messages->create(
 // the number you'd like to send the message to
 $to,
 array(
 // A Twilio phone number you purchased at twilio.com/console (or your developer trial number)
 'from' => '+15551212',
 // the body of the text message you'd like to send
 'body' => "Someone sent you a message from CTH!"
 )); 
}
add_action( 'wpcf7_mail_sent', 'text_notice' );
add_action( 'wpdev_new_booking', 'text_notice' );

 
There are plenty of other uses, of course and pretty good support for their entire API (on their website). I’ve used Twilio to set up a text notification system that pulls names and phone numbers directly from a WordPress Events Plugin and schedules automatic text notifications ahead of the events.

Have you got an idea for text notifications that you’d like to use on your website? Let me know!

Leave a Comment