Triggers

Triggers are patterns that when matched create an Event. Triggers contain a JSON object string called pattern this string contains two keys; from and to.

Example

If I wanted to track each time a Device travels specifically from one Hub to another I would create a trigger with the following pattern.

let trigger = {
  name: "Entering the Store",
  pattern: {
    from: "HUBID",
    to: "HUBID"
  }
}

// Pattern must be stringified
trigger.pattern = JSON.stringify(trigger.pattern)


// Send to API
var request = require("request")

var options = { method: 'POST',
  url: 'https://api.echolo.io/v1/trigger',
  body: trigger,
  headers: 
   { 'x-api-key': 'x-api-key',
     token: 'token', 'app-id': 'app-id' } }

request(options, (error, response, body) => {
  if (error) throw new Error(error)
  console.log(body)
})