This Tech Blog post discusses the new Instant Messaging feature coming to Jomres.

Jomres Messaging System

Jomres Messaging System (JMS) is the new tool for instant communications between property managers and guests. It's been written, from the ground up, to work with Jomres.

I did not want to use a library created by some other developers for this feature because I don't want my users (that's you) to incur any new costs if at all possible, and because by creating a bespoke system I will be able to maintain it into long into the future. For a feature as critical as Instant Messaging I feel it's better to have our own independant feature whereever possible.

 

In this blog post I'd like to introduce you to the feature, it's different components and plugins and what I aim to achieve with it.

Note: All messages are stored encrypted using the built-in Jomres encryption system. I believe that this is important because there's a strong possibility that guests may include personal information which needs to be protected.

Note : Currently this feature is Bootstrap 5 only.

Feature Plugins

Let's start with the feature's plugins.

Instant messaging looks simple, but it's not. There are a lot of moving parts which all go towards making something like Whatsapp or FB Messenger work. You have the storage mechanisms, client to client communications, the User Interface itself, handling of messages and of course notification features.

To address each of these different aspects I've broken the feature down into several main plugins. These are

  • API Feature Messages
  • Jomres Messaging System (User Interface)
  • Jomres Messaging System Parsers
  • Jomres Messaging Notification (not yet released, and will probably be a group of plugins)

The first two are mandatory. If you are writing an android or iphone app to use this functionality then only the API Feature Messages plugin is mandatory. Most sites, however, will probably need both.

Let's look at how these all hang together.

 Jomres Messaging System (JMS UI)

This is the User Interface, it offers the pages you see in the frontend that generate the chat form, conversations lists and other UI elements, such as a new Dashboard widget that lists all conversations.

Among other things it includes the ability to notify a user who's currently active on the site that there are messages waiting for them.

It also includes a cron task plugin that can trigger reminder notifications that a message is waiting for a response. It's this functionality that will trigger most notifications in the Notification plugin(s). The reminder policy currently is that if a message hasn't been marked as read within 5 minutes then a reminder webhook is created. Once that's been done then the next reminder date time is changed to 24 hours in the future.

API Feature Messages

The User Interface (JMS UI above) communicates with the database to retrieve messages, group member information etc through this REST API feature. I deliberately wanted this part to be a REST API feature because I want other client systems to be able to connect to the messaging system via OAuth2, not just the JSM UI plugin.

In the future it's not that hard to imagine scenarios where a guest messages the hotel, the JMS notification system sends the message off to a remote AI, and the AI responds directly to the guest via the REST API with a response. This is just one possible example, there are more scenarios and I'm sure you can think of some too. Making it so that all interactions with the users can happen via the messaging API gives scope for growth that is impossible to predict today.

Currently there are only 9 endpoints. It's possible that one or two more might be added, but for now I think that this API is more or less feature complete (unless I have a brainwave).

You can find the API documentation here.

All communication with this set of endpoints requires that the client send a valid OAuth2 token in the header of their message.

Because guests and property managers may not be familiar with setting up API client ID/secret pairs, and because the JMS UI has to send OAuth2 tokens as a part of their communication with the API to message properties, this plugin will detect if a logged in user has a key pair that has permission to access the Messaging API and if they don't it will automatically create one for them.

Jomres Messaging System Parsers

This plugin is a vehicle for delivering 08NNN numbered minicomponent plugins. When the API Feature Messages plugin pulls messages from the database, or inserts messages into the database, these messages are first handed off to the 08NNN scripts so that pre saving, and pre delivery parsing can occur.

What do I mean?

Let's have a look at one of the scripts in this package : j08200parse_booking_number.class.php

This script looks at messages that have been pulled from the database, and searches for any strings of numbers that are 8 characters long. If it finds some it then checks the database because booking numbers are 8 characters long. If it finds a corresponding booking then it modifies the 8 character string in the message to become a link to the booking. That link is then shown in the Jomres Messaging System chat UI which can be clicked.

This is just one example of how a parser can be used to rejig message contents to improve their usability. Is it possible that there could also be parsers that can translate content from one language to another? It's certainly possible and it's something I will be investigating in the future. I also hope to receive suggestions from you, my users. I can explore what's technically possible, but I rely on you to be the ideas people who say "Hey, Vince, what if we do...."

Jomres Messaging Notifications

As I said previously, this is not yet released because there's actually quite a lot we can do to notify property managers and guests that there are messages waiting for them.

My ultimate goal is for the notification system to fire off messages to Viber, Whatsapp, Emails, Messenger, SMS, Zapier or any other app that the user may use, to tell them that there's a response waiting for them.

The reality is that that's actually really difficult to achieve. Technically it's possible to do, but it requires asking each property manager to jump through loads of hoops to setup chat bots on the various services, or some other authentication process. Anybody who's ever run a system like Jomres (or, indeed, WordPress or Joomla) will understand that asking a non-technical person to do a technical thing is asking for trouble. I need to give this a lot more thought first, so in the beginning I'll probably release a simpler plugin that retrieves message reminder webhook events and sends emails to property managers and/or guests to let them know that there's a message waiting for them.

I have been looking at Twilio, and I think that that service offers functionality that would be of benefit to us, so maybe I can do something with that.

Message System Flow

Here I'll briefly describe how the message system plugins work together.

The JMS UI plugin overrides the Jomres Core contactowner script.

User visits the property details page

Non-logged in users

JMS users have to be registered, logged in users of the CMS to use the messaging system. This isn't an unusual policy, AirBNB has the same policy. It allows us to link messages to users and is a security feature because communications with the API demand an OAuth2 token which can only be given to a registered user. This is all done silently, but can only be done for logged in users.

In the Jomres Core contactowner script a user would just fill in a simple form that sends an email to the owner and/or the site administrator. We don't offer this feature in JMS because we want to ensure that the user's logged in first, so if the user's not logged in/registered we want to show, in this space, the CMS's login module instead.

The overridden contactowner minicomponent takes advantage of a new Jomres (10.5.4) feature that allows Jomres to show Joomla modules within Jomres template files. (Sorry Wordpress users, I don't have a WP analogue for this feature yet, but I will)

This leads us, in fact, to the only configuration you as a property manager will need to do for this plugin : Create a Joomla login module, using whichever login plugin (or Joomla core if you prefer) and in Site Configuration you will see a new Tab called Messaging System. Make a note of the module's ID in the Joomla module manager, then in this tab save that ID. That's it, you're done, you've now told the JMS which module to show where the old contact form used to be.

Logged in users

The logged in user is (currently) given a button in the UI where the old contact form used to appear. When the user clicks this button a modal opens which contains the conversation window. Modal windows are used because it keeps the guest on the property's page.

If the user has never messaged the property before then they're given a welcome message. In the message system a new "group chat" is created which consists of the property manager(s) for that property and all super property managers.

Message flow

All messages are added to the system via the REST API Messages feature. Before the message is saved it is parsed by 08100 numbered scripts which can modify/append messages if need be.

NB: One use that was suggested to me for this trigger point is for a profanity detector. Not to filter profanities, but as a way of detecting the mood of a conversation. If an algorithm detects that a series of messages suggested that one or more members of the chat were unhappy and an admin needs to step in this could possibly be act upon. What do you think?

Each group member has a row added for them, for the message, in the recipients table. This helps the system to correctly advise the user how many messages are unread for each conversation. 

Each message has a row added to the messages table.

Both recipient row and message events create a webhook event which could be handled by webhook watcher functionality.

$webhook_notification                           = new stdClass();
$webhook_notification->webhook_event = 'message_recipient_created';
$webhook_notification->webhook_event_description= 'Logs when a message is created, for a given user id';
$webhook_notification->webhook_event_plugin = 'api';
$webhook_notification->data = new stdClass();
$webhook_notification->data->message_id = $this->model->values->id;
$webhook_notification->data->recipient_id = $this->model->values->recipient_id;

 

$webhook_notification                            = new stdClass();
$webhook_notification->webhook_event = 'message_created';
$webhook_notification->webhook_event_description = 'Logs when a message is created';
$webhook_notification->webhook_event_plugin = 'api';
$webhook_notification->data = new stdClass();
$webhook_notification->data->message_id = $message_id;

 Because I don't want to overload a manager or guest's inbox with notifications of instant messages we won't initially send reminders about these two webhook events. They potentially have uses ( perhaps for sending the messages to a property's PMS?) but I think that sending notifications about a message that the user has already seen will be annoying, therefore the basic notification system instead will act on reminder webhooks (see below).

 

When a recipient row is created in the database one of it's columns is new_remind_date. The JMS UI plugin includes a cron script which will find any rows in this table that haven't been marked as read. If a user has any unread messages then a new webhook notification 'message_reminder' is created. The (as yet unfinished) Jomres Messaging Notification plugin would handle these notifications.

$webhook_notification                            = new stdClass();
$webhook_notification->webhook_event = 'message_reminder';
$webhook_notification->webhook_event_description = 'Unread message reminder triggered';
$webhook_notification->webhook_event_plugin = 'api';
$webhook_notification->data = new stdClass();
$webhook_notification->data->user_id = $user_unseen_messages['recipient_id'];
$webhook_notification->data->unread_count = $user_unseen_messages['unread_count']

Wrapping up

I hope that this introduction to the upcoming Instant Messaging feature has piqued your curiosity.

A few of the ideas I've highlighted here are just that, ideas. Every idea takes time to build, test and debug so I am unlikely to build solutions for all of those ideas if nobody shows an interest in them. If you like one of the ideas, or you have ideas of your own then please do contact me via the ticket system at https://tickets.jomres.net to discuss them further.

 

REST API, JMS , Instant Messaging

  • Created on .

ABOUT US

vince picDeveloped and maintained by Vince Wooll, Jomres was initially conceived in early 2005 as a Mambo based solution to a client’s hotel management needs. While it wasn't originally expected to be an online booking system it quickly morphed into one as users requested more and more features.

As the number of feature requests grew Vince knew that he would need to dedicate more time to the project and in July 2005 Jomres was released as a commercial project. Since then Jomres has become the world's oldest online booking plugin for any PHP CMS. It has been used in Joomla 1.0, 1.5, 2.5, 3 & 4 and WordPress 4, 5 & 6.

Aladar joined the project in 2010 after using Jomres for his own projects. He was active on the forum, helping other members of the community and eventually Vince invited him to join the team. Between 2010 and 2018 he was an integral part of the project and made many significant contributions.

Whilst not formally part of the Jomres project, Rodrigo Rocco and Vince have become firm friends. Rod is a freelancer who specialises in doing custom work for Jomres users and developing custom plugins for the system that take advantage of it's modular design. He has built many useful extensions including his fabulous Valentina Template Override Package.

Jomres and the Jomres Logo is trademarked and can't be used without written consent from the owner.

www.jomres.net is not affiliated with or endorsed by the Joomla! Project, Open Source Matters or the WordPress project. The Joomla! & WordPress names and logos are used under a limited license granted by Open Source Matters and the WordPress Projects.

© Copyright 2005 - 2022 Vince Wooll