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

v1.7.3 - Plugin Update Notes

Rolls up 1.7.1 to 1.7.3.

Fixed

  • Sign-In Codes Always Reach The Right Account - When two accounts held the same phone number, sign in was meant to refuse the code. If one of those accounts had its number stored in a different place, which happens with imported accounts and with some other plugins, it was invisible to that check, so the refusal never happened and the code could sign whoever held the handset into the other account. Every place a number can be stored is now searched. Worth updating promptly if you have SMS sign-in switched on.
  • SMS Reaches Every Notification Type - With Notifications for HivePress, the types other extensions add, such as gallery access purchased, holiday started or a moderation hold, could never send a text and offered no SMS tick box to explain why, while bookings and messages worked normally. Everybody still starts opted out, so nobody receives a text they have not asked for.
  • No More False “Could Not Reach GitHub”, and update checks no longer hold up the Plugins screen.

Update via your dashboard as usual! :slight_smile:

Cheers,
Chris :v:

1 Like

v1.8.3 - Plugin Update Notes

Rolls up 1.8.0 to 1.8.3.

New

  • Quick Links On The SMS Tab - Jumping to each section, with a divider between them, so the delivery options, sign-in codes, event messages and removal setting are easy to find on what had become one long page.

Changed

  • Shorter, More Readable Descriptions - Trimmed to the essentials, wrapped at a readable width on wide screens, with wider tooltips beside the field labels. Nothing about sending, sign-in codes or your stored settings has changed.

  • Matching Settings Controls - The quick links stay in view as you scroll, a Save Changes tab sits on the right edge of the screen, and a back-to-top button appears once you have scrolled down. They now appear on the Integrations tab as well as the SMS tab.

Fixed

  • The API Key Secret on the Integrations tab has its show/hide button and normal field width back when you open Settings from the HivePress menu. The secret stayed hidden either way, but there was no way to check what you had pasted.

Update via your dashboard as usual! :slight_smile:

Cheers,
Chris :v:

v1.9.0 - Plugin Update Notes

New

  • Sell SMS access through Memberships - Twilio bills you for every text, so this release lets you make SMS part of a paid plan. With the HivePress Memberships extension active, each membership plan’s Settings box gains an “Allow SMS notifications” tick box. Tick it on one plan or more and notification texts go only to members of those plans; everyone else loses the SMS choice on their Notification Settings page and sees a short sentence with a link to your plans instead. Leave the box unticked on every plan and nothing changes.
  • Paid Access section - HivePress > Settings > SMS > Paid Access shows which plans currently include SMS and lets you reword the sentence other members see.
  • For developers - the hptw_sms_access filter, for sites that grant SMS access from their own membership or purchase system.

Texts to the administrator phone and sign-in codes are never limited, and the limit stays in force if Memberships is later switched off, so nobody is texted at your expense by accident.

Update via your dashboard as usual! :slight_smile:

Cheers,
Chris :v: