Action object

Describes the Array object of the Action key within an Event object.

Events support a wide variety of types for the action object based on a: email, sms, telegram, web-hook, set-variable, slack-webhook, voice, ubifunction and user. This causes the JSON action object to be highly nested and have many variants in order to support all the above types.

In its base form, the action object follows this structure:

{
	  "data": {},
    "name": "", // String
    "type": "Type of action", // Options: ["email", "sms", "telegram", "web-hook", "set-variable", "slack-webhook", "voice", "ubifunction", "user"]
    "isGeneric": true, // Options: [true, false]. Defaults to true
    "repeatAction": false, // Options: [true, false]. Defaults to false
    "idGroupAction": "", // String. Recommendation: at least 5 characters
    "back_to_normal": false, // Options: [true, false]. Defaults to false
    "maxRepetitions": "", // String or Integer. Defaults to none
    "repeatInterval": {} // Object containing value and unit for the repeated action
}

Each key represents the following:

PropertyTypeDescription
dataObjectObject containing data about the action (please see below)
nameStringName of Action
typeStringType of action, valid values are: email, sms, telegram, web-hook, set-variable, slack-webhook, voice, ubifunction and user
isGenericBooleanTrue if Action is generic
repeatActionBooleanTrue if Action should be repeated. If repeatAction is False, maxRepetitions and repeatInterval are hidden
maxRepetitionsNumberNumber of maximum repetitions of the Action. Required when repeatAction is active
repeatIntervalObjectObject containing value and unit for the repeated action. Required when repeatAction is active. unit: can be T (minutes), H (hours) or D (days). The maximum values per unit are as follows: {"T": 43200, "H": 168, "D": 90}
idGroupActionStringId of the Group Action
back_to_normalBooleanTrue if action has a "Back to Normal" action configured

data Object - Attribute of actions Array

The data key within an action object holds an object as well, which has the below structure based on the value of the type key:

// This structure applies to when "type" is "email" 
{
  "emails": [], // Array or string separated by ",". Defaults to []
  "message": "", // String
  "subject": "" // String
}
// This structure applies to when "type" is "sms" or "telegram"
{
  "message": "", // String
  "numbers": [
    {
      "number": "", // String. Defaults to ""
      "country": {
        "id": "", // String. Defaults to ""
        "label": "", // String. Defaults to ""
        "value": "" // Required field. Country indicative
      }
  	}
  ]
}
// This structure applies to when "type" is "web-hook" 
{
  "url": "", // String.  URL required field
  "method": "", // Options: ["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE"]
  "headers": {}, // Object for request headers
  "payload": "{}" // String. Decode payload
}
// This structure applies to when "type" is "set-variable" 
{
  "value": "", // String or Integer. Defaults to None
  "context": {}, // Object with variable context. Defaults to {}
  "variables": [{}], // Array of objects
  "device_groups": [{}] // Array of objects
}
// This structure applies to when "type" is "slack-webhook" 
{
  "url": "", // String.  URL required field
  "message": "", // String
  "icon_url": "", // Optional
  "username": "", // String required
  "icon_emoji": "", // Optional
  "channel_label": "" // String
}
// This structure applies to when "type" is "voice" 
{
  "voice": "alice", // String. Defaults to "alice"
  "message": "", // String
  "numbers": [
    {
      "number": "", // String. Defaults to ""
      "country": {
        "id": "", // String. Defaults to ""
        "label": "", // String. Defaults to ""
        "value": "" // Required field. Country indicative
      }
  	}
  ],
  "language": "en" // String. Minimum lenght = 2 and maximum lenght = 5. Defaults to "en"
}
// This structure applies to when "type" is "ubifunction" 
{
  "method": "", // Options: ["get", "post"]
  "headers": {}, // Object for request headers
  "message": "", // String. Required field
  "ubi_function": {
    "id": "", // String
    "url": "" // String.  URL required field
  }
}
// This structure applies to when "type" is "user" 
{
  "message": "", // String
  "subject": "", // String
  "userIds": [], // Array containing user ids
  "contactMethods": [] // Options: ["voice", "telegram", "sms", "email"]. Defaults to []. Choice one or more
}

Each key represents the following:

PropertyTypeDescriptionAction Type
emailsArrayArray of email addresses an email should be sent toEmail
messageStringContent of emailEmail, SMS, Phone Call, Slack, UbiFunction, User
subjectStringSubject line of emailEmail, User
numbersArrayContains Objects with information about the phone number, e.g. country and number, the SMS should be sent toPhone Call, SMS
languageString2 letter code of language of the phone callPhone Call
voiceStringType of voice for the phone call. Defaults to "alice"Phone Call
valueNumberValue that should be sent to VariableSet Variable
contextObjectContext of Value that should be sent to VariableSet Variable
timestampStringTimestamp in milliseconds of Variable that should be sent to VariableSet Variable
variablesArrayContains Objects containing the id and the name of the VariableSet Variable
device_groupsArrayContains Objects with information about the id of device group, variable_label, isMultipleGlobalEvent and deviceGroup_nameSet Variable
urlStringWebHook of Slack AppSlack, Webhook
icon_urlStringUrl of icon of Slack AppSlack
usernameStringSlack usernameSlack
icon_emojiStringEmoji icon of Slack AppSlack
channel_labelStringChannel message should be sent toSlack
methodStringHTTP Method used for Webhook and UbiFunctionWebHook, UbiFunction
headersObjectHeader Object of WebHook or UbiFunction requestWebHook, UbiFunction
payloadStringJSON payload in string formatWebHook
ubi_functionObjectContains Objects about the id and url of the UbiFunctionUbiFunction
contactMethodsArrayList of choice: ["email", "sms", "telegram", "voice"]], Default = \ [ ]User
userIdsArrayContains all the userIds. Default = \ [ ]User

Here are examples of the data object with its different possible variants:

// This structure applies to when "type" is "email" 
{
  "emails": [
    "[email protected]"
  ],
  "message": "Hey there, {{variable.name}} was {{last_value}} at {{trigger_timestamp|timestampformat('America/Bogota')}}.",
  "subject": "{{variable.name}} alert!"
}
// This structure applies to when "type" is "sms" or "telegram"
{
  "message": "Hey there, {{variable.name}} was {{last_value}} at {{trigger_timestamp|timestampformat('America/Bogota')}}.",
  "numbers": [
    {
      "number": "+57 3123456789",
      "country": {
        "id": "CO",
        "label": "Colombia",
        "value": "+57"
      }
    }
  ]
}
// This structure applies to when "type" is "web-hook" 
{
  "url": "http://example.com/?do=foobar",
  "method": "POST",
  "headers": {
    "Content-Type": "application/json"
  },
  "payload": "{ \"name\": \"{{device.name}}\", \"value\": \"{{last_value}}\", \"datetime\": \"{{timestamp|timestampformat('America/Bogota')}}\" }"
}
// This structure applies to when "type" is "set-variable" 
{
  "value": "100",
  "context": {},
  "variables": [
    {
      "id": "64beb73a404ca2000ddf41d0",
      "name": "Variable 1"
    }
  ]
}
// This structure applies to when "type" is "slack-webhook" 
{
  "url": "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX",
  "message": "Hey there, {{variable.name}} was {{last_value}} at {{trigger_timestamp|timestampformat('America/Bogota')}}.",
  "icon_url": "",
  "username": "test-ubidots",
  "icon_emoji": "",
  "channel_label": "#example-channel"
}
// This structure applies to when "type" is "voice" 
{
  "voice": "alice",
  "message": "Hey there, {{variable.name}} was {{last_value}} at {{trigger_timestamp|timestampformat('America/Bogota')}}.",
  "numbers": [
    {
      "number": "+57 3123456789",
      "country": {
        "id": "CO",
        "label": "Colombia",
        "value": "+57"
      }
    }
  ],
  "language": "en"
}
// This structure applies to when "type" is "ubifunction" 
{
  "method": "post",
  "headers": {
    "Content-Type": "application/json"
  },
  "message": "{ \"name\": \"{{device.name}}\", \"value\": \"{{last_value}}\", \"datetime\": \"{{timestamp|timestampformat('America/Bogota')}}\" }",
  "ubi_function": {
    "id": "64bec5dc3abcb1000e327b2a",
    "url": "https://parse.ubidots.com/prv/username/test"
  }
}
// This structure applies to when "type" is "user" 
{
  "message": "Hey there, {{variable.name}} was {{last_value}} at {{trigger_timestamp|timestampformat('America/Bogota')}}.",
  "subject": "{{variable.name}} alert!",
  "userIds": [
    "64d3e8a0433e82000e773bfa"
  ],
  "contactMethods": [
    "voice",
    "telegram",
    "sms",
    "email"
  ]
}