Deploying Unomi/jCustomer objects from Jahia modules

November 14, 2023

General use cases

In many situations, it is required to deploy Unomi/jCustomer objects from a Jahia module. This capability is offered by jExperience, and you'll only need to add the object (usually a json file) in the right folder of your jahia module. 

The root folder to add any jCustomer object is src/main/resources/META-INF/jexperience/

The subfolders depend on the type of object that you need to deploy: 

  • properties for json files defining profile properties 
  • rules for json files defining rules 
  • segments for json files defining segments
  • conditions  for json files defining conditions 
  • groovy/actions for groovy files defining actions

Example: To add the "contacts" segment, jExperience adds a json file at the following location: src/main/resources/META-INF/jexperience/segments/contacts.json

When the module containing the jCustomer / Apache Unomi objects is started, the objects will be deployed using jCustomer REST API. Note that this logic will always overwrite any existing object in jCustomer, which is convenient when you wish to update them, but it also means that such objects shouldnt be modified from the UI, otherwise these modifications will be erased next time your module is started. 

Focus: Deploy a JSON schema from a Jahia module

This feature is available since jExperience 3.0 / jCustomer 2.0.

Jcustomer validate the received events thanks to JSON schema. So it will be necessary to provide your JSON schemas to validate your custom events.
Jcustomer provides a system to extends existing schemas and adding new schemas.

Extending existing event types

You can find the documentation for the extension of JSON schema in the Apache Unomi documentation.

How to add an extension through a Jahia module:

To add JSON schema extension from a Jahia module, you simply have to add your json files into the folder META-INF/jexperience/schemas of a module that you will deploy on your Jahia instance. Your Jahia instance needs to be connected to JCustomer to load the files

Managing custom events types

Add a schema with a Jahia module:

You can find the documentation for the extension of JSON schema in the Apache Unomi documentation.


To add JSON schema from a Jahia module, you simply have to add your json files at the same location as the extensions, in the folder META-INF/jexperience/schemas of a module that you will deploy on your Jahia instance. Your Jahia instance needs to be connected to JCustomer to load the files.

Simple example of a JSON shema for the click event:

{
  "$id": "https://jexperience.jahia.com/schemas/json/events/click/1-0-0",
  "$schema": "https://json-schema.org/draft/2019-09/schema",
  "self": {
    "vendor": "org.modules.jexperience",
    "target": "events",
    "name": "click",
    "format": "jsonschema",
    "version": "1-0-0"
  },
  "title": "ClickEvent",
  "type": "object",
  "allOf": [
    {
      "$ref": "https://unomi.apache.org/schemas/json/event/1-0-0"
    }
  ],
  "properties": {
    "source": {
      "$ref": "https://unomi.apache.org/schemas/json/items/page/1-0-0"
    },
    "target": {
      "$ref": "https://unomi.apache.org/schemas/json/item/1-0-0"
    }
  },
  "unevaluatedProperties": false
}