Actions

An action, within an action policy, will define what to do upon trigger activation. An action is always passed the data message or the event that triggered it as datacontext for templating purpose or cherry picking a particular field within that data. Some actions give you the ability to template their output. The templating language used is Mustache. You can use fields of your triggering data (event or message) by leveraging the mustache variable mechanism.

Email notification

This action serves the purpose of sending email to one or multiple recipients when a trigger is activated.

Representation of an email action
{
    "to": [] of String,
    "cc": [] of String,
    "cci": [] of String,
    "subjectTemplate": String,
    "contentTemplate": String
}

to

A List of String each representing a valid email

cc

A List of String each representing a valid email

cci

A List of String each representing a valid email

subjectTemplate

A string representing a Mustache template. This will be use to render the email subject.

contentTemplate

A string representing a Mustache template. This will to render the email content.

Example of an action policy sending an email on a state change event
{
    "id": "6c95837b-251d-41d8-95f1-42facdf8e71e",
    "name": "some_user_friendly_name",
    "enabled": true,
    "triggers": {
        "stateChange": {
            "filter": {
                "ruleIds": ["22222222-2222-2222-2222-222222222222"]
            },
            "version": 1
        }
    },
    "actions":
    {
        "emails": [{
            "to": ["notification@orange.com"],
            "cc": ["cc@orange.com"],
            "cci": ["cci@orange.com"],
            "subjectTemplate": "State change for {{stateKey}}",
            "contentTemplate": "{{stateKey}} change from state {{previousState}} to state {{newState}} at {{timestamp}}"
    }
}

In this example, the fields stateKey, previousState, newState, timestamp are referencing the event message which generates the notification. The event message is available in the data context of the notification process.

SMS notification

This action serves the purpose of sending sms to one or multiple recipients (MSISDNs) when a trigger is activated.

Representation of an SMS action
{
    "destinationPhoneNumbers": [] of String,
    "contentTemplate": String
}

destinationPhoneNumbers

a collection of string representing each a recipient msisdn

contentTemplate

A string representing a Mustache template. It will be rendered as the sms content.

Example of an action policy sending an sms on a fired event
{
    "id": "6c95837b-251d-41d8-95f1-42facdf8e71e",
    "name": "some_user_friendly_name",
    "enabled": true,
    "triggers": {
        "matchingFired": {
            "filter": {
                "ruleIds": ["22222222-2222-2222-2222-222222222222"]
            },
            "version": 1
        }
    },
    "actions":
    {
        "sms": [{
                "destinationPhoneNumbers": ["+33123456789"],
                "contentTemplate": "Event fired at {{timestamp}} with value : {{value}}"
            }]
    }
}

HTTP Push notification

This action serves the purpose of sending a message to a webhook server when a trigger is activated.

Representation of an HTTP Push action
{
    "id": "6c95837b-251d-41d8-95f1-42facdf8e71e",
    "name": "some_user_friendly_name",
    "enabled": true,
    "triggers": {
        "deviceActivity": {
            "filter": {
                "deviceIds": ["urn:lo:nsid:sensor:temp001"],
                "ruleIds": ["22222222-2222-2222-2222-222222222222"]
            },
            "version": 1
        }
    },
    "actions": {
        "httpPush": [{
            "webhookUrl": "https://hooks.myservice.com/services/SOMEWEBHOOKREFERENCE",
            "headers": {"authorization": ["Bearer 00000000-0000-0000-0000-000000000000"]},
            "retryOnFailure": true,
            "content": "{\"text\": \"Devices {{deviceIds}} activity change triggered by activity rule: {{ruleIds}} : at {{timestamp}}\"}"
        }]
    }
}

FIFO notification

This action serves the purpose of sending a message to a FIFO when a trigger is activated.

Representation of a FIFO action
{
    "fifoName": String,
    "noRetention": Boolean
}

fifoName

Name of the FIFO to send the message to. See FIFO usage to consume messages

noRetention

If true, messages will be immediately dropped if there is no active subscription to the FIFO at the time of message publication. If false, messages will be persisted on disk until consumed or expired based on the expiration delay defined in your offer settings.

Representation of sending an event message to a FIFO
{
    "id": "6c95837b-251d-41d8-95f1-42facdf8e71e",
    "name": "some_user_friendly_name",
    "enabled": true,
    "triggers": {
       "deviceStatus": {
          "version": 1,
          "filter": {
             "connectors": ["mqtt"],
             "groupPaths": [{"path": "/lyon", "includeSubPath": true}]
          }
       }
    },
    "actions": {
        "fifoPublish": [{
            "fifoName": "myFifo",
            "noRetention": false
        }]
    }
}

Azure Event Hubs notification

This action serves the purpose of sending a message to an Azure Event Hub instance when a trigger is activated.

Representation of sending an event message to an Azure Event Hub
{
   "name": "some_user_friendly_name",
   "enabled": true,
   "triggers": {
      "dataMessage": {
         "version": 1
      }
   },
   "actions": {
      "azureEventHubs": [
         {
            "eventHubsNamespace": "myEventHubsNamespace",
            "eventHubName": "myEventHubName",
            "sharedAccessKeyName": "mySharedAccessKeyName",
            "sharedAccessKey": "mySharedAccessKey",
            "content": "{\"text\": \"new message sent by device {{metadata.source}} at {{timestamp}}\"}",
            "retryOnFailure": false
         }
      ]
   }
}

Datacontexts for templating

Actions template can have 3 kinds of data contexts :

These are used as the root object of the mustache templating engine.