Overview

As the name implies, a Global Action is a mechanism within Foundry that allows the user to perform an "Action" (i.e. send an alert, trigger, and integration, communicate to another device, etc) when certain conditions are met. There are three ways to initiate a Global Action


  1. You can associate the action as a formula field on a particular device type. For example, if you wanted to trigger a message to connected vents in a greenhouse when the temperature of the greenhouse was greater than 100 degrees, you would add a formula field to the ObjecType of "greenhouse" to trigger the action "Open Vents" when the temperature is greater than 100.
  2. You can trigger an action on a result set of a complex search. For example, find all greenhouse in the state of AZ, whose vents are currently open, and where temperatures are less than 80, then send an "action" to close all the vents.
  3. You can trigger an action on a Group of objects. For example, change a subscription fee to all the devices in the "monthly subscription" group.


Types of Global Actions

There are multiple types of Global Actions that can be defined:

  1. HTTP Post Message - this will send an HTTP Post message to any endpoint
  2. HTTP Get Message - this will send an HTTP Get message to any endpoint
  3. HTTP Put Message - this will send an HTTP Put message to any endpoint
  4. HTTP Delete Message - this will send an HTTP Delete message to any endpoint
  5. MQTT message - this will publish an MQTT message on a specific topic
  6. Lambda function - this will invoke a lambda function for the given objects.
  7. Send to Analytics - this will send data to the Thinglogix Analytics engine.


Constructing Payloads

The payload contains JSON data that will be sent to the resulting action. The payloads can hold strings, numbers, or variables.

    - String: Strings must be encapsulated by quotes.

    - Numbers: Numbers do not have to be encapsulated by strings.

    - Object Attributes: Attributes be used to send data that is in the object that the Global Action is invoked from. Variables in payloads are formatted so that brackets surround the attributes JSON key (You can find the associated attribute JSON key in edit object template page). For example, if you have an attribute on your object named "Temperature" with a JSON key "temperature" you could the attribute in the template as "[temperature]" (The quotes means this will be evaluated as a string) or [temperature] (No quotes means it will be evaluated as a number)


Example:

{"test_string": "string", "test_num": 3, "deviceId": "[deviceId]"}


Common Problems:

    - A string isn't encapsulated by quotes.

    - The JSON key for a variable does not exist on the object.

    - A variable that you are expecting to be a number actually contains a string.


System Variables:

Other System level variables that are also available for the payload are:

  • accountId - account ID that the object belongs
  • Created - user who created the object
  • deviceId - object uuid
  • typeId - object type Id
  • Updated - user that most recently updated the object


Lambda Invoke

To create a new HTTP Post message you will create a new Object of type "Global Action" and provide the required attributes:

  • Name
  • Action Type = Lambda Function
  • Lambda ARN - this is the endpoint for your message
  • payload - this is the actual data that will be sent to the endpoint, note the "merge variables" within the payload.


HTTP Call

To create a new HTTP Post message you will create a new Object of type "Global Action" and provide the required attributes:

  • Name
  • Action Type = HTTP POST, PUT, DELETE, or GET
  • HTTP URL - this is the endpoint for your message
  • HTTP Headers - Use this to add any HTTP headers to your payload.
  • MQTT Publish Topic - The topic you want to the returned data to publish to.
  • payload - this is the actual data that will be sent to the endpoint, note the "merge variables" within the payload.


MQTT Publish

To create a new HTTP Post message you will create a new Object of type "Global Action" and provide the required attributes:

  • Name
  • Action Type = MQTT Publish
  • MQTT Publish Topic - The topic you want to publish to. You can specify a specific topic, "com.thinglogix/device/123", or use a variable like "[mqtt_topic]" to grab topic from the object you will be invoking the action from.
  • payload - this is the actual data that will be sent to the endpoint, note the "merge variables" within the payload.


Example attribute of Global Action for MQTT Publish

    The action will publish to the attribute, mqtt_topic, which is specified in the device that invokes the Global Action.


Invoking a Global Action

Once you create this Global Action Object it is  available to use within the system:

  • Formula Fields:
  • From Advanced Search
  • From Group