cancel
Showing results for 
Search instead for 
Did you mean: 

Configure custom notification email

mcaissie_
Confirmed Champ
Confirmed Champ

Hi,

I am trying to configure Nuxeo to use a custom template when sending "Modification alert" email notification. Here is what i done so far..

From a working installation (meaning that i subscribed on Modification alert and if i modify a folder i correctly get a modification notification email)

STEP 1: Removing the default modification notification

In the nuxeo-platform-notification-core-5.4.2

i modified notification-contribution.xml to disable the Modification notification by setting enabled="false"

The result was that the Modification option disapeared from the Alert interface as expected, and i stoped receiving notification email on modification of the folder. So far so good...

STEP 2: Adding a custom modification notification

1-i added in my own custom .jar (which i use to expose custom services) a copy of
/> OSGI-INF/notification-contribution.xml (with Modification enable="true")

2-i added a custom src/templates/modif.ftl

3-i added in the MANIFEST.FM a Nuxeo-Component: OSGI-INF/notification-contrib.xml

4-Restart.....

The result is that i now have the Modification option back in the interface, and if i modify the folder i get a notification email, except that i am not getting the custom modif.ftl template but still the default one.

Can someone indicates to me what is missing so i can get a custom email notification ?

Thanks Michel

1 ACCEPTED ANSWER

Benjamin_Jalon1
Elite Collaborator
Elite Collaborator

ARrrrrglll !!! Did you modify the file into the nuxeo-platform-notification-core-5.4.2 ? Bad, really bad 😄

In fact Nuxeo is extensible and you can override easily with your own bundle (Nuxeo jar) the Nuxeo ones. This is the philosophy of the platform. We provide a Framework and some Modules (DM, DAM, Social-Collaboration, ...) that can be a starting point for you. And you can override each part of the module.

So for your point you are near:

  1. DON'T TOUCH INTO THE NUXEO JAR ! I insist
  2. Do your step 2 but in your notification.xml file you must check that
  • the name of the component at the beginning of your XML file is different of the nuxeo ones. For instance <component name="com.yourcomapny.yourprojectname.ecm.platform.notification.service.NotificationContrib">
  • you must add this <require>org.nuxeo.ecm.platform.notification.service.NotificationContrib</require> (this is the name of the component that contains the contribution you want to override.
  • you must disable the default contribution as https://jira.nuxeo.com/browse/NXP-8105

With the require you ask to the runtime to deploy your contribution AFTER the Nuxeo one. As you give the same name of the notification, the service will override with yours.

So your contribution must be something like:

<?xml version="1.0" encoding="UTF-8"?>
<component name="com.caristix.nuxeo.ecm.platform.notification.service.NotificationContrib">
  <require>org.nuxeo.ecm.platform.notification.service.NotificationContrib</require>
  <extension target="org.nuxeo.ecm.platform.ec.notification.service.NotificationService" point="notifications">
    <notification name="Modification" enabled="false"></notification>
    <notification name="Modification" channel="email" availablein="Workspace" autosubscribed="true"
      template="yourtemplate" subject="Document modified" 
      label="label.nuxeo.notifications.modif"> 
      <event name="documentModified"/>
    </notification>

Last point, you can use the new Nuxeo version, Nuxeo 5.5 that brings really cool features..

Hope this will be the solution 😄

View answer in original post

5 REPLIES 5

Benjamin_Jalon1
Elite Collaborator
Elite Collaborator

ARrrrrglll !!! Did you modify the file into the nuxeo-platform-notification-core-5.4.2 ? Bad, really bad 😄

In fact Nuxeo is extensible and you can override easily with your own bundle (Nuxeo jar) the Nuxeo ones. This is the philosophy of the platform. We provide a Framework and some Modules (DM, DAM, Social-Collaboration, ...) that can be a starting point for you. And you can override each part of the module.

So for your point you are near:

  1. DON'T TOUCH INTO THE NUXEO JAR ! I insist
  2. Do your step 2 but in your notification.xml file you must check that
  • the name of the component at the beginning of your XML file is different of the nuxeo ones. For instance <component name="com.yourcomapny.yourprojectname.ecm.platform.notification.service.NotificationContrib">
  • you must add this <require>org.nuxeo.ecm.platform.notification.service.NotificationContrib</require> (this is the name of the component that contains the contribution you want to override.
  • you must disable the default contribution as https://jira.nuxeo.com/browse/NXP-8105

With the require you ask to the runtime to deploy your contribution AFTER the Nuxeo one. As you give the same name of the notification, the service will override with yours.

So your contribution must be something like:

<?xml version="1.0" encoding="UTF-8"?>
<component name="com.caristix.nuxeo.ecm.platform.notification.service.NotificationContrib">
  <require>org.nuxeo.ecm.platform.notification.service.NotificationContrib</require>
  <extension target="org.nuxeo.ecm.platform.ec.notification.service.NotificationService" point="notifications">
    <notification name="Modification" enabled="false"></notification>
    <notification name="Modification" channel="email" availablein="Workspace" autosubscribed="true"
      template="yourtemplate" subject="Document modified" 
      label="label.nuxeo.notifications.modif"> 
      <event name="documentModified"/>
    </notification>

Last point, you can use the new Nuxeo version, Nuxeo 5.5 that brings really cool features..

Hope this will be the solution 😄

Hi bjalon , tx for your quick answer

I finally got it working

mcaissie_
Confirmed Champ
Confirmed Champ

First:

If i put , it disable also the one i want to add.

Here is what i just tried; 1- I disable the <notification name="Modification" 2- I created a new <notification name="Modification2" with a different name but using the same event.

The only problem remaining is to use the custom .ftl file i put in my own src/templates folder in my .jar. I am still receiving the default modification email template.

So i guess i need something in the NotificationService extension so that points to the src/templates folder in my .jar and not in the default templates folder

Any hint on this ?

org.nuxeo.ecm.platform.notification.service.NotificationContrib

<notification name="Subscriptions updated" channel="email" enabled="true" availableIn="Workspace"
  autoSubscribed="true" template="subscriptionsUpdated" subject="New subscription" label="label.nuxeo.notifications.subscriptions.updated">
  <event name="subscriptionAssigned"/>
</notification>

<notification name="Modification" channel="email" enabled="false" availableIn="Workspace"
  autoSubscribed="false" template="modif" subject="Document modified" label="label.nuxeo.notifications.modif">
  <event name="documentModified"/>
</notification>

<notification name="Modification2" channel="email" enabled="true" availableIn="Workspace"
  autoSubscribed="false" template="modif" subject="Document modified" label="label.nuxeo.notifications.modif">
  <event name="documentModified"/>
</notification>

<template name="subscriptionsUpdated" src="templates/subscriptionsUpdated.ftl" />
<template name="modif" src="templates/modif.ftl" />


<template name="defaultNotifTemplate" src="templates/defaultNotifTemplate.ftl" />

patrek
Star Contributor
Star Contributor

If your are using maven, you need to put your templates in src/main/resources/templates

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.