This is the first article in a series highlighting some new ways to interact with your clients and customers. They will range from beginning to advanced.
When E-Moxie first started (officially in 2005, unofficially for years before that), we made websites that only lived on the Internet and some of the most the fancy features at the time were sending an e-mail. Comparing our capabilities then, to our capabilities now, times have changed. Boy did they change, drastically. iPhones didn’t exist. Cell phones could only make phone calls. High speed Internet access wasn’t nearly as abundant. IPTV? No sir. Video streaming was around in it’s infancy, but not anywhere near the capacity it is now. The cloud? You guessed it, not really there yet.
We live in a world where the gap between Internet based interactions are almost seamless with normal everyday interactions. There are services that help you interact with people in ways that were unimaginable before. They also just keep better.
I’m a huge fan of Twilio (and their t-shirts!). They are doing great things, and are enabling us to bridge the gap between our applications, voice calls and SMS. We’ve had GREAT success with integrating Twilio’s services in to our applications to streamline business processes. We’ve even used it to engage the people in our local community in some fun ways. Twilio creates a way for your website to make phone calls, receive phone calls, send text messages, and receive text messages! Now that we have the base of what they do and what you can do, let’s get down to making a simple web form to send a text message leveraging Twilio.
First things are first, if you haven’t already done so, sign up for Twilio’s service at www.twilio.com
Download the twilio-php library from GitHub. This demo is in PHP (we *might* be biased).
<?php require '/path/to/twilio-php/Services/Twilio.php'; if (count($_POST) > 0) { // Your Account SID from www.twilio.com/user/account $sid = "ACXXXXXX"; // Your Auth Token from www.twilio.com/user/account $token = "YYYYYY"; // Valid twilio phone number from your account $fromPhone = “”; $client = new Services_Twilio($sid, $token); $message = $client->account->sms_messages->create( $fromPhone, // From a valid Twilio number $_POST[‘to’] // Text this number $_POST[‘message’], ); print $message->sid; } ?>
<form action="" method="post"> <label for="to">To: </label><input id="to" type="text" name="to" /> <label for="message”">Message: </label><input id="message" type="text" name="message" /> <input type="submit" name="submit" value="Send" /> </form>
That’s it! This simple PHP script and form will allow you to enter a phone number to send a message to and a message to send for that number. The next article, we’ll talk about making voice calls and how you could implement them in your application.