There are three main use cases for the message stack:

  1. Logging and displaying system events
  2. Notifying users when messages are generated
  3. Notifying users who subscribe to certain content

Logging and Displaying System Events

The basic use case for the message stack is a tool for logging and displaying system events. The events may be user initiated (e.g. a page is created) or system initiated. User-initiated events are sometimes called activity streams. Facebook's News Feed is a an example of an activity stream and Google has launched its own tool for tracking changes to files and folders in Google Drive.

In the message stack each message (entity instance) represents a record of what occurred. Different message types (entity bundles) can be used for different situations. For example one message sub type might be used to record information related to the creation of a web page, another might be used to record information about an e-commerce order etc.

You might think that a custom view on a page or series of pages might serve the same purpose but message entities provide much greater functionality:

  • Having a separate message entity provides a means of tracking changes to an entity (a web page, a site user etc.) over time.
  • Each message type is fieldable, meaning arbitrary data can be stored with a message.
  • Also, message types support view modes, which provide developers with a flexible means of rendering messages in different ways as required.
  • The message module supports localization so message types can be created to support multilingual web sites.
  • Last, but not least, message types can be created with tokens, so that messages can be dynamically generated based on the context at creation time.

One important note is that the Message module does not provide a way to create messages through the user interface. Developers will need to leverage different Drupal hooks, depending on the requirements of the site design. Fortunately, the module includes an example module that demonstrates some typical message types and the hook required to support them. In addition, the Message UI module provides a basic user interface which may be used to gain valuable insight into the architecture of the message stack.

Notifying users when messages are generated

A second major use case is to notify recipients when messages are generated. This functionality is provided by the Message Notify module which provides a method for sending a message via a notifier plugin. Message Notify comes with plugins for email and SMS and may be extended to other transport mechanisms as required. Message Notify includes an example module that demonstrates the usage of notifier plugins. The module also provides hook support for the Rules module, which may be an option for site builders who are familiar with the Rules module or who do not want to use Message Notify methods directly in their code.

Notifying users who subscribe to certain content

The third major use case is where users who subscribe to content will be notified when events occur that involve that content. This use case is implemented through the Message Subscribe module, which in turn leverages the Flag module, which provides subscribe functionality to users.

Comments

numerabilis’s picture

I was looking for this docs to find out how to config my website to notify people of new posts, be it a page, comment, forum topic... any news. It seems this doc is trying to explain how it works but I need to know how to get it running. I installed all modules but I am stuck, I don´t know next step.
I am writing down this comment here in the hope somebody add this config information in this documentation rather than look for it in the forum like an issue problem.
I am from Brazil (sorry by my english).

tepelena’s picture

I am having the same problem. There is poor documentation on how to get a simple message sent out. It would be nice if there was an example on how to implement this.

eahonet’s picture

I'm also trying to figure this out. I have gotten it to send notices, but haven't fully tested and finished code yet. I think this is a piece of functionality that requires code. The modules are the framework. But there's code to generate the messages. It's very flexible which means it can do A LOT, but there's not a GUI for all pieces of it. I didn't get much beyond installing the sample Test modules that come with these modules. Copied the Test modules to modules/custom/ and then enabled them. I think for one of them, I had to get a patch file from an issue ticket.

tepelena’s picture

That's for the update. It would have been nice if there was an example out there for a simple case such as comment notify.

eahonet’s picture

I can put one together, but probably not for another 3-4 weeks.

tepelena’s picture

That would be great. I have been looking for one for a year. 3-4 weeks is not that far. Thank you.