Notifications and OPAC messaging
Editing Notifications and OPAC messaging
Koha has mechanism to send messages to patrons and staff user that includes the ability to use message templates and send emails. LibLime proposes to enhance messaging by adding the following:
- creating a messaging preferences tab in the OPAC so that patrons can control what types of messages they receive.
- enhance the letters template mechanism to allow header, footer, and repeating section templates.
- add SMS as a delivery mechanism and unify it with other delivery options.
- add support to send messages via an interface with a telephony system.
- add the option to retrieve messages via RSS feeds
- add a central queue for messages so that processes to generate and send messages can be separated.
- add a mechanism to inject messages from another source (such as a library class scheduling system).
- unifying all of the code that can send emails and other types of messages into a single set of modules.
In addition, several circulation message types would be added:
- event or class notices
- notices sent when an item just becomes overdue
- notices sent in advance of an item's due date.
Details for enhancements to notifications and OPAC messaging
Initial author: Daniel Sweeney (daniel.sweeney at liblime dot com)
Overview
Libraries want to send a variety of notices and alerts to patrons from Koha. Patrons want to be able to control how they receive these notifications and in some cases, whether or not they receive them at all.
This specification discusses the various general requirements for enhancements to Koha's notification system.
Pre-Existing Functionality
Koha provides the following notifications by default:
- Overdue notices.
- Acquisitions Claim.
- Serial Routing List
- New patron registration
Each of these is installed at system startup. Administrators can add more notices in the tools area. Notices are defined using a templating system that can interpolate single values into the text of the notice. The single values are drawn directly from the database—in general the templates substitution tokens have the form table.column and draw directly from the database. There is no way to include a sub-template or to repeat a section of the template. The templates also include a name and a message subject. These are stored in the letter table.
Each notice has a Koha module—one of Catalogue, Serials (Routing List), Claim Acquisition, Claim Serial Issue, or Members. This is stored in the module field in the letter table. This column does not seem to reference anything in the database.
Libraries may in some cases substitute or add new notice types to existing system functionality; for instance in the Notice/Status Triggers area it is possible to substitute or add a new Circulation notice to the overdue notice processing system. The Koha Module associated with the notice indicates whether to include a notice in a particular functional area.
Koha patron records contain one set of addresses per record. These addresses include a primary postal address, primary email, telephone and cell-phone information, an alternate postal address and alternate contact information. There is no way to deactivate addresses or have them be valid for a specified period of time.
As part of recent and planned work, the following are being added to Koha:
- Item borrowed notice.
- Item returned notice.
- Courtesy notice.
- Class about-to-begin notice. This will be an interface with a separate library class scheduling system; the interface will be generalized to allow messages from an arbitrary third-party system to be injected into Koha's messaging system.
- Just-become-overdue notice. (This is distinct from the regular overdue notice.)
Many of the new notices are intended to be transmitted electronically, using email or SMS, rather then necessarily through postal mail. In particular, the new overdue notice is intended to be an immediate reminder that an item has gone overdue, while the regular overdue notice may go via postal mail and serves as a more ‘official’ notice.
Requirements / Description
Delivery mechanisms
- Multiple delivery mechanisms may be defined and configured for notifications. At a minimum the following will be supported:
- Postal Mail.
- E-mail.
- SMS text messaging, either through an email gateway or an dedicated SMS gateway.
- Syndication feeds, using RSS or Atom.
- A telephone circulation system. This system may read prepared information out of the Koha database.
- Delivery mechanisms will have different configuration points. Most of them will be associated with a specific address from the patron record. For instance, the SMS delivery mechanism will use the Mobile Phone element in the Patron record, and if this column is empty for a given patron, the patron will not be able to use this delivery mechanism.
- The Postal Mail delivery mechanism is somewhat special—it is the default if other addresses are not available.
- Most delivery mechanisms will use a specific address in the patron record, and will not be available for a specific patron if that patron does not have the appropriate address. (Syndication feeds are an exception to this rule—they are not associated with a specific address.)
- Delivery mechanisms will be configured per branch in a multi-branch Koha installation.
Notification Configuration
- Each notification will have its own configuration options. For instance administrators will be able to configure the Item Borrowed and Item Returned notifications so that they are sent for particular patron category/item type combinations.
- As in previous releases, the module column in the letter table will determine whether particular notifications can be configured for particular purposes. (This implies that the module field does not reference just a list of Koha modules—it’s essentially a generic notice type.)
- For a given notification, administrators will be able to choose a different template for each delivery mechanism. This implies that multiple templates will exist in the letters table, one for each delivery mechanism. (It’s possible that some delivery mechanisms use entirely different templates that the letters in the regular Koha system—for instance if they create non-textual output somewhere. The regular Koha system is sufficient for many purposes, though.)
- The set of notifications in the system will be stored in the authorized_values table. This set of authorized values will establish the range of values in the letter.module column. (Alternately, a new table for notification types could be added, but Koha seems to use the authorized_values table for this kind of thing.)
Configuring patron access to notifications
- Patrons will be able to configure some notifications in the public catalog; some notifications will only be configured by administrators. Administrators will decide this for each notification and for each patron category.
- Patrons will be able to turn off some notifications entirely. Administrators will decide this for each notification and for each patron category.
- A new tab would be added to the default template for patron empowerment to house the alert setup information
- When selected the user would be presented with the options to define the following:
- for each defined message type, whether the patron wants to receive it via SMS, email, or RSS, or any combination thereof.
- for certain message types, whether the patron wishes to receive a digest version of the message.
- mobile phone number for SMS messages
- When selected the user would be presented with the options to define the following:
- By default, email and rss messages would come in a digested format. SMS messages specified to be delivered in a digested format will only indicate the number of items due in ‘x’ days and does not include the titles of the items. Patrons must be allowed to enter/define a cell phone number that they wish to have the SMS messages sent to. This number can be distinct from any number in their patron record.
Notification configuration for a specific delivery mechanism.
- For a given notification and delivery mechanism, administrators may decide whether it is possible to send the notification in digested mode.
- Digest mode may not make sense for some combinations of notification and delivery mechanism—delivery mechanisms may specify that they do not support digest mode.
Patron Notification Configuration
- If a specific notification can be configured by patrons, patrons may be allowed to:
- Select what delivery mechanisms they wish to use for the notification (they may select more than one.) Patrons must have the appropriate address for the notification to select it.
- Opt-out of the notification, if opting out is available for the specific notification type.
- Choose whether to receive the notification in “Digest” mode. In “Digest” mode multiple notifications will be batched together into one single communication.
- Circulation staff will be able to set the delivery mechanisms for patrons just as patrons can. This will be part of a new new "Messaging tab".
Notification templates
- Note that the below is a simple suggestion to provide the minimum functionality. If a better template solution already exists in the Perl community, then we should use it. The primary requirement is that the templates are able to handle repeated data for digested messages, for instance for overdue notices to be able to populate a static header and footer, with a repeated entry for each item that is overdue.
- Each notification template will have access to a variety of fields from the database to populate the template form. These fields will be different for each notification.
- Each notification template may have three subtemplates—a header, a body and a footer.
- The header subtemplate will always be at the top of the message.
- The body template will be placed after the header.
- If a notification template is supporting digested output, then the body template will be repeated for each entry in the digest. For instance for overdue notices, the body will be repeated for each overdue item.
- The footer template will be placed after the body.
- The header and footer subtemplates may be reused for more than one notice, even in non-digest mode.
Syndication feeds
- If syndication feeds are available as a delivery mechanism, and notifications are configured to support them, then the syndication feeds will be produced by notification templates like the ones that produce textual notices for email. The templates will produce items or entries in the feed in XML format.
- A separate process will take each generated item or entry and place it in a syndication feed.
- The feeds will use RSS 2.0.
- For Syndication feeds, digesting does not make sense—the mechanism that builds the feed will take care of grouping the individual items or entries together into a feed. There are some dependencies within an RSS feed between different elements in the XML stream.
- Items will be placed in the feed using the date that they are generated by the system—we will not re-sort them in the feed according to some internal date like the item due date. The data in each entry will indicate the due dates. (This is consistent with Atom feeds from Google Calendar, which seem to make some sense.)
- Items will be removed from the feed after a specific length of time. This length of time will be set as part of the configuration of the delivery mechanism. The default will be 30 days.
- Syndication feeds for all patron-specific notifications will require authorization using http authentication. The user name and password will be the same user name and password the patron uses to log in to the OPAC. (This is consistent with the Gmail Atom feeds, which most feed-readers can now use.)
- It must be possible to configure Koha so that the feeds are only available on https (SSL-protected) connections. Some libraries may not be overly concerned about this, or may not have SSL certificates, so this will not be required.
- Each notification will have its own syndication feed.
Logging outgoing messages
- Some customers require that all outgoing messages be logged.
- LibLime proposes to create a message queue. This queue would be used to:
- stage messages that have been prepared (e.g., by the overdue notices job)
- store messages for the staff log
- store messages for use by RSS feeds
- allow a generic job to be written that processes the message queue and sends the messages.
- If an explicit message queue is used, staff should be able to see the contents of the message queue, but not edit it.
- When patrons transactions are anonymized, corresponding entries in the message queue should be anonymized as well.
Repeatable email, telephone and mobile phone fields
- The five patron ‘contact’ fields, Phone (home), Phone (work), Phone (cell), E-mail (home) E-mail (work) and fax, will become repeatable.
- Staff may add new values to these fields, as well as deleting old values.
- Patrons may add new values to these fields, but may not delete old values.
- Patrons may not add duplicate addresses of the same type (although they may add duplicates of different types, for instance the same number for Phone (home) and Fax.)
- When patrons have added new values for contact fields, the values the patron adds will be protected from being overwritten by the patron loader.
- The patron loader will be able to add multiple fields for the 5 contact types by including more than one comma-separated value in the appropriate field in the CSV input file. (The comma-separated values must be appropriately escaped in the file.)
- For delivery mechanisms that use these address types, patrons will be able to choose any active address of the given type as the desired contact for that delivery mechanism.
- Administrators may decide for each patron category whether to allow patrons to add new addresses in the public catalog. This will be part of the pre-existing patron category setup.
Patron address and contact deactivation
- It will be possible for staff to deactivate and reactivate any of the patron addresses, except the main postal address.
- When an address is deactivated, it will not be used to send messages, and any messages that would be sent using that address will not be sent at all.
- For repeatable addresses as above, individual addresses may be deactivated without deactivating all the addresses of that type.
- If a particular address is deactivated, and the patron loader replaces it, it will still be deactivated (in other words the patron loader will not change the activation status of an address.)
- Patrons will see that a particular address is deactivated in the public catalog on the patron page. They will not be able to reactivate the address.
- If a patron tries to add an address to their patron record that is deactivated, Koha will prevent them. (This should be taken care of by the prevention of loading duplicate addresses of the same type above.)
- In the “Tools” area, administrators will be able to upload a file of addresses of a given type to activate or deactivate. The file will be a simple text file with one address per line.
- For each line, all matching addresses of the given type will be activated or deactivated.
- If an address appears in the file but not in the database, a warning will be logged for the administrator to see after the job is complete.
- If an address appears in the file and matches more than one patron, a warning will be logged for the administrator to see after the job is complete. The information about all matching patrons will appear. The matching addresses will still be activated or deactivated.
- Some delivery mechanisms can immediately tell if an address is invalid. Delivery mechanisms will be able to deactivate addresses on their own.
- Other delivery mechanisms can’t always tell right away that an address is invalid, so administrators will have to gather the invalid addresses from wherever the delivery stack puts them and process them down to a text file to deactivate the addresses.
Security and Privileges
- The “Delivery Mechanisms” area in Administration will be controlled using a single yes/no privilege—if administrators lack this privilege they will be unable to enter this area. That being said, since Delivery Mechanisms are branch-specific, administrator’s branch affiliations will also allow or prevent them from editing Delivery Mechanisms for specific branches.
- Circulation staff may edit patron’s delivery mechanisms if they have sufficient privileges to edit the patron itself—there is no specific permission controlling the alert delivery mechanisms.
- Circulation staff may edit patron addresses using the existing privileges.
- Administrators will be able to edit whether a patron category can edit addresses in the public catalog based on existing security allowing access to patron categories.
Open Questions and notes
- The above doesn’t really discuss non-Patron notices like the acquisitions claims.
- Telephone gateways appear may become another delivery mechanism.
- The syndication feeds have some interesting caching issues—it’s not clear whether Koha should hold on to particular entries in the feed or for how long. The feed itself does not know whether or not the patron has actually used it, or whether the items have been returned. We provide a configurable default of 30 days in the delivery mechanism.
- Atom support for the feeds may be desirable, but we have experience with RSS feeds now so it may be faster to just go that way and keep Atom in mind.
- It may make sense to add fallback functionality, where if, for instance, an SMS message fails, then we try to send using the email delivery method. This presents some problems—it’s hard to know consistently whether a delivery has succeeded or failed, and administrators will have to maintain the delivery mechanism hierarchy.