Twilio for HivePress (SMS Notifications)

Hey @everyone, :waving_hand:

SMS notifications have been on the communities wishlist since 2022, in topics like SMS TEXT MESSAGE notifications, Adding SMS and/or push notifications, SMS Notification Feature, Integration SMS alerts for customers and SMS notification with Twilio, among others. Last year I asked for guidance on the right way to build it, and @Ihor kindly pointed me at the hook that fires for every email notification, and I promised to share whatever I ended up with.

So here it is, my latest plugin:

Twilio for HivePress! :mobile_phone_with_arrow::tada:

It mirrors HivePress email notifications as text messages sent via Twilio. Whenever HivePress sends a notification (a listing is approved, a booking is confirmed, a message is received, etc.), the matching SMS goes to the recipient’s phone.

Features

  • Works with every HivePress email type automatically, including those added by the official extensions (Bookings, Marketplace, Messages, Requests and more), each with its own editable SMS message
  • Fully customisable SMS text per event, using the same tokens as HivePress emails, including model tokens such as %user.first_name% and fallbacks such as %listing_title | your listing%
  • Phone numbers come from a user attribute of your choice, so members manage their own number from their account settings
  • Optional phone field on the registration form, so the registration SMS can reach new users straight away
  • Optional administrator number for admin alerts (new listings, reports, vendor registrations)
  • Sends via a Twilio phone number or a Messaging Service, with numbers normalised to the international format automatically
  • The settings screen shows the last delivery error from Twilio, so a misconfigured account is never silent
  • Authenticates with a Twilio API key only; your account auth token is never stored, so a leaked key can be revoked without compromising your whole Twilio account
  • Updates directly from GitHub in your WordPress dashboard, including one-click updates

Planned updates

  • SMS login codes (OTP). A few of you have asked for phone-based login, most recently in Native OTP Login option and going back to 2FA for logging in and other actions. This plugin does not do login codes yet, but it is on my list to explore now the Twilio plumbing is in place.
  • Integration with my Notifications for HivePress extension, so SMS joins email, on-site and push as a per-type choice, and members decide for themselves which notifications reach their phone.
  • WhatsApp is off the cards for now. Business-initiated WhatsApp messages must use message templates pre-approved by Meta, so free-text notifications like these are rejected outside a live conversation window. If that changes, I will revisit it.

Before you start: your Twilio account

A free Twilio trial cannot deliver these messages, so plan for four steps in the Twilio console. This is what it took on my own account:

  1. Fund the account (upgrade off the free trial; the minimum top-up was 20 GBP for me). Trials only text verified numbers and usually reject free-text messages entirely.
  2. Create an API key on the API keys and tokens page, and enter its SID and secret in the plugin settings.
  3. Buy an SMS-capable phone number (roughly 2 GBP per month for a UK number, taken from the account balance, so the initial top-up covers it). In some countries, including the UK, Twilio asks for regulatory documentation first.
  4. Pass the Trust Hub compliance check (KYC). Until it is approved, every send is rejected.

The plugin surfaces each of these states on its settings screen, so you can always see which step still needs doing. Please also remember that texting people usually needs their consent under regulations such as PECR and GDPR, so only collect phone numbers with a clear explanation of how they will be used.

Download and installation

Download the latest release here :backhand_index_pointing_left:

  • then upload it via Plugins > Add New Plugin > Upload Plugin and activate. Setup instructions are in the readme, and the source and changelog live on GitHub.

The internals are source-verified against the current versions of HivePress and each supported extension, so the SMS side behaves exactly like the native email notifications it mirrors.

Thanks again to @Ihor for the pointers that shaped the whole approach. If you run into any issues, find bugs or think of an awesome new feature, please drop a reply below! :slight_smile:

Cheers,
Chris :v:

P.S. If this extension saved you time or money, consider buying me a coffee! Sharing these tools for free takes a lot of time and resources, and your support helps me keep doing it for the community.

ko-fi

2 Likes

Another big one from you!!!
So far i have been using WPNotif(connected to twillio + refined it a bit with claude) for sending SMS on new bookings, sent to the vendors.

This one will be interesting - i will take a look at it.

Thank you again for your amazing work!

Ivan

1 Like

Hi Chris,

Thank you for creating this and sharing it with the community, it’s a really useful addition to the HivePress ecosystem, and we truly appreciate the effort you’ve put into it!

We wanted to give you a heads up that we’re also planning to add similar functionality to the official HivePress ecosystem in the near future, as we understand how important this feature is for our users. We hope this doesn’t discourage you, community-driven plugins like yours are invaluable, and the work you’ve done here shows real dedication to the platform.

Thank you again for contributing and being such an active part of the HivePress community! :honeybee:

1 Like

v1.7.0 - Plugin Update Notes

New

  • SMS sign-in codes - Members with a phone number saved on their account can sign in with a code texted to them instead of a password.
  • Member notification preferences - With Notifications for HivePress, SMS joins on-site, email and push as a choice on each member’s own notification settings page.
  • Safety limits - Sign-in codes and member texts both carry hourly limits, so a fault or abuse cannot run up your Twilio bill.

Update via your dashboard as usual! :slight_smile:

Cheers,
Chris :v:

1 Like