Send SMS from WordPress using Msg91 and Socket
Send SMS from WordPress using Msg91 and Socket

DIY Guide to Send SMS from WordPress using MSG91 and Socket

Powering over just over 25% of the Internet is WordPress, world’s no 1 Content Management System. Be it startups, well established firms or bloggers like me, we all rely on WordPress. There are many reasons when it comes to choosing between Blogger, WordPress and Medium. But the features that make WordPress a class apart are that it is open sourceso you do virtually anything with it without actually violating anything and second is that it has almost infinite customisation options. Talking about doing anything with WordPress, have you ever wondered that you could SMS from WordPress ? Yes, Send SMS from WordPress. And today in this post, I’m going to guide you on how to Send SMS from WordPress using MSG91 and Socket. This is a DIY Step By Step Guide that will help you add SMS sending functionality with WordPress. So let’s get started !

Send SMS from WordPress using Msg91 and Socket
Send SMS from WordPress using Msg91 and Socket

Why Send SMS in first place ?

First of all, you might wonder “Why even send SMS from a WordPress Site ?(I knew this was coming !) And to answer that, I’d say there are a million reasons to do that (Can’t list all of them) From security point of view, you could send a SMS when anyone logged into your website. Or let’s say you are running an e-commerce website probably using Woo Commerce and you want to send out a transactional SMS to your customers. These are a few scenarios where in you’d want your website to be able to send SMS. Let’s see how MSG91 can help us here.

What is MSG91 and how do I use it ?

MSG91 is a SMS provider based in India. They provide SMS services to a wide range to clients including the likes to Axis Bank and MakeMyTrip. Being an Indian provider, it makes it much more easier for people to deal with them as they have a pretty good support and transactions are done in rupees. Also if you are a developer, then you would be surprised with the numerous offerings they have – .NET, Android, iOS and what not. That’s about MGS91.

Now you might ask what Socket is ? Well it’s a platform that allows you to interact with 3rd Party APIs at ease. What am I using Socket ? Two reasons for that. Firstly they don’t yet have a plugin for WordPress and secondly “Kuch Toofaani Karte Hain…” (Take the road less travelled)

Steps to Setup MSG91 and Socket

  1. Create an account with MSG91. Their DEMO account is free of charge and provides 100 transactional SMS and 9 promotional SMS. However to send your personalised message, you would need to purchase SMS credits.
  2. Once logged in, navigate to API section and ensure that the API endpoint is enabled. You should also see the AuthKeyCopy this AuthKey.
Navigate to API in MSG91 dashboard and note the AuthKey
Navigate to API in MSG91 dashboard and note the AuthKey
  1. In a new window, sign up / login to Socket. As mentioned earlier, Socket makes it very easy to use 3rd party APIs.
  2. Post login, Socket will ask you to create a flow. Enter a name for your flow and create. It will now give you a dedicated API endpoint to useCopy this URL.
Create a Flow and note down the flow url.
Create a Flow and note down the flow url.
  1. Hit the Dry Run button on top and it should work fine. On the page, click on Add API button.
  1. Search for MSG91 from the list and choose POST SEND SMS V2. It will automatically give you a skeleton in JSON
Search for MSG91 and choose POT Send SMS v2
Search for MSG91 and choose POT Send SMS v2
  1. Modify the code to send one message to one mobile number. As shown below, text alongside message contains the message to be sent and mobile will have the mobile number. If you have multiple mobile numbers, you comma to separate them.
Modify the JSON skeleton with the SMS message and mobile number
Modify the JSON skeleton with the SMS message and mobile number
  1. [Important Step] Click on Headers Tab and Copy and Paste the AuthKey from the MSG91 API tab. (Step 2).
  2. If done correctly, navigating to the API endpoint (the link generated in step 4) should send SMS to the mobile number mentioned in step 9.
  3. Congratulations ! You’ve successfully setup MSG91 with Socket.

These were the steps to configure MSG91 with Socket. So whenever you hit the Socket API endpoint, it is actually going to trigger the MSG91 API which is going to send the SMS. This is part 1 of the guide to Send SMS from WordPress using MSG91 and Socket. Let’s move to WordPress to complete the second half.

Steps to Setup WordPress

  1. Log in to your WordPress website. It’s highly recommended to test it on your test website before touching the live/production site.
  2. Here are going to make use of a Plugin called Hookpress. The Hookpress plugin is available via search. However if your hosting provider is running the latest version of PHP (PHP 7) then that version isn’t going to work. I’d suggest you to download the latest working Hookpress plugin from here.
  3. Navigate to Plugins area and upload the zip file to install and activate the Hookpress plugin. The plugin can be found under Settings -> WebHooks. Open it.
  4. Click on Add Web Hook button. For this post we want to send an SMS based on an action, thus we choose action.
Adding the Web Hook to WordPress
Adding the Web Hook to WordPress
  1. From the drop down we are going to choose wp_login. So what that basically means is that, our WordPress site will send a SMS every time a login is made.
  2. Choose fields from the list below. (If you are running PHP 7 and installed the Hookpress plugin from WordPress, you will not see the fields option and hence won’t be able to create a webhook)
    In the URL field, enter the dedicated URL (Step 4 of the earlier steps) and save.
  3. That’s it, now log off and log in and you should receive SMS on the mobile number. Easy isn’t it ?!

Mission Accomplished: Send SMS From WordPress

That brings us to the end of this DIY Guide to Send SMS from WordPress using MGS91 and Socket. Frankly this was the first time I was using both these services and wondered how much time it would take. But it was buttery smooth and I was able to get this entire thing running in less than an hour ! If you are not a developer, it might take some extra time. You can contact the tech team at MSG91 too. But it’s going to be easy. After this setup, my initial impressions of MSG91 is pretty good. The setup was quite simple and their sales team too. Got a call immediately after I signed up to see if all was well. The pricing seemed pretty cheap and the SMS are sent instantly.

So I would highly recommend you to try out MSG91. Be it your customers or readers, being connected to them will only help your business grow. And as MGS91 says, Your Job: Send, Our Mission: Deliver. This is Atulmaharaj signing off. Let me know how easy or difficult it was for you to follow this post. Since I’ve done it first hand, I would be able to help you out too. (to some extent) Drop in your queries in the comments below or tweet to me at @Atulmaharaj

About Atulmaharaj

A seasoned blogger and a content marketer for close to a decade now. I write about Food, Technology, Lifestyle, Travel, and Finance related posts. Blogging brings me joy and the best part is I get to read and e-meet so many amazing bloggers! PS: I'm also the founder for Socialmaharaj.com :) Favorite Quote: "Traveling is like reading a book, one who hasn't traveled, hasn't turned a page.

Check Also

Atul giving opening remarks at KCD Hyderabad.

Organising The First KCD Hyderabad – My Amazing Experience

Being a food and travel blogger, I often attend a lot of food meet-ups where …

2 comments

  1. Good tool for sending SMS. Thanks for sharing 🙂 Atul

Share your thoughts

This site uses Akismet to reduce spam. Learn how your comment data is processed.