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:
Property | Type | Description |
---|---|---|
data | Object | Object containing data about the action (please see below) |
name | String | Name of Action |
type | String | Type of action, valid values are: email , sms , telegram , web-hook , set-variable , slack-webhook , voice , ubifunction and user |
isGeneric | Boolean | True if Action is generic |
repeatAction | Boolean | True if Action should be repeated. If repeatAction is False, maxRepetitions and repeatInterval are hidden |
maxRepetitions | Number | Number of maximum repetitions of the Action. Required when repeatAction is active |
repeatInterval | Object | Object 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} |
idGroupAction | String | Id of the Group Action |
back_to_normal | Boolean | True if action has a "Back to Normal" action configured |
data
Object - Attribute of actions
Array
data
Object - Attribute of actions
ArrayThe 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:
Property | Type | Description | Action Type |
---|---|---|---|
emails | Array | Array of email addresses an email should be sent to | |
message | String | Content of email | Email, SMS, Phone Call, Slack, UbiFunction, User |
subject | String | Subject line of email | Email, User |
numbers | Array | Contains Objects with information about the phone number, e.g. country and number , the SMS should be sent to | Phone Call, SMS |
language | String | 2 letter code of language of the phone call | Phone Call |
voice | String | Type of voice for the phone call. Defaults to "alice" | Phone Call |
value | Number | Value that should be sent to Variable | Set Variable |
context | Object | Context of Value that should be sent to Variable | Set Variable |
timestamp | String | Timestamp in milliseconds of Variable that should be sent to Variable | Set Variable |
variables | Array | Contains Objects containing the id and the name of the Variable | Set Variable |
device_groups | Array | Contains Objects with information about the id of device group, variable_label , isMultipleGlobalEvent and deviceGroup_name | Set Variable |
url | String | WebHook of Slack App | Slack, Webhook |
icon_url | String | Url of icon of Slack App | Slack |
username | String | Slack username | Slack |
icon_emoji | String | Emoji icon of Slack App | Slack |
channel_label | String | Channel message should be sent to | Slack |
method | String | HTTP Method used for Webhook and UbiFunction | WebHook, UbiFunction |
headers | Object | Header Object of WebHook or UbiFunction request | WebHook, UbiFunction |
payload | String | JSON payload in string format | WebHook |
ubi_function | Object | Contains Objects about the id and url of the UbiFunction | UbiFunction |
contactMethods | Array | List of choice: ["email", "sms", "telegram", "voice"]], Default = \ [ ] | User |
userIds | Array | Contains 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"
]
}