← Return to Top Page 日本語

Gravio Action Flow Development Guide

Table of Contents

1. Overview of Action Configuration View

In the Action Configuration View, you can write programs that are executed by triggers. These programs are called “Actions.”

In a typical use case, sensor data triggers multiple actions and passes multiple parameters to those actions.

To create or edit an action, follow these steps:

  1. Go to the server overview screen
  2. Click the middle icon at the bottom of the server card
  3. From the displayed UI, click the “+” mark in the top left menu to add an action

2. Steps to Create an Action

To create a new action:

  1. Click the “+” symbol in the top right of the Action Configuration View in the edge server
  2. Enter a name for the action file that will store the new action (e.g., NewAction.acs)
  3. Press OK, and the new action file will be registered and displayed in the list
  4. Double-click the action file to open the action editor

In the action editor, actions are composed of “steps” that are arranged from left to right in the execution sequence.

To add a new step:

  1. Click the “+” icon in the top right
  2. Select a new action component from the “Action Component Library”
  3. After selecting a component, a configuration screen appears where you can configure the step and access or process its variables

3. Variables and Variable Types Available in Actions

The following types of variables can be used within action programs:

Action Property

Action Variable

Component Property

Component Variable

Trigger Variable

Trigger Property

Variable Types and Type Conversion

Available variable types are:

Variable Type Description
Int Integer
Double Floating point
String String
Bool true/false
DateTime Date and time
Byte array Byte array
Array Array
Object Object

Conversion between types is possible. Conversion rules are defined as follows:

Operators

The following operators can be used in action programs:

Arithmetic Operators:

Comparison Operators:

Logical Operators:

4. How to Reference Object Data

When referencing Object type variable values in actions, use dot notation or bracket notation.

For example, with JSON data like this:

{
  "id": "XXXXXX",
  "source": {
    "channel": 4,
    "bacId": "YYYYYY"
  },
  "common": {
    "description": "Face Recognition",
    "time": "2019-06-17T07:53:22.986Z"
  },
  "fr": {
    "candidates": [
      {
        "customId": "00001",
        "displayName": "Person B",
        "similiarityScore": "0.7272"
      }
    ]
  }
}

To reference fr.candidates[0].displayName, use either:

tv.Data.fr.candidates[0].displayName

Or, when key names contain spaces or hyphens:

tv.Data["fr"]["candidates"][0]["displayName"]
tv.Data.fr.candidates[0]["display Name"]  // For key names containing spaces

These access methods can also be used in action conditions:

cv.Payload.fr.candidates[0].displayName == "Person B"

They can also be used in trigger conditions. For example, to trigger an action only for males in IVAR:

tv.Data.iod.gender == "MALE"

5. Action Component Operation

Action components provide component variables for input payload (cv.Payload) and output payload (cv.Payload).

Input Payload

Output Payload

6. Using Pre Mappings / Post Mappings

When selecting a component in the Action Editor screen, the Pre Mappings / Post Mappings editing area appears on the right.

How to Write Expressions

  1. Press the “+” button to display the input field
  2. Write the variable name on the left and the expression to assign to the variable on the right

Expressions can include:

The evaluation result type of the right-hand expression is automatically converted to the left-hand type.

You can also use comparison operators to return boolean values:

Available Functions

Functions available in Pre Mappings / Post Mappings expressions:

String Functions: Len, Contains, RuneCount, HasPrefix, HasSuffix, Index, Join, LastIndex, Repeat, Replace, Split, ToLower, ToUpper, Trim, TrimLeft, TrimRight, TrimPrefix, TrimSuffix

Type Conversion Functions: ToBool, ToInt, ToFloat, ToString, ToDate, ToBinary, ToJSON

Encoding Functions: URLPathEscape, URLPathUnescape, URLQueryEscape, URLQueryUnescape, MD5, SHA1, SHA256, BASE64, DecodeBASE64, BASE64URL, DecodeBASE64URL

Date Functions: Now, Year, Month, Day, Hour, Minute, Second, Weekday, ToLocal, ToUTC, ToTimezone, DateFormat, DateParse

Environment Variables: Env

Regular Expression Functions: RegExpMatch, RegExpFind, RegExpFindSubmatch, RegExpFindAll, RegExpReplace, UUID

7. Action Execution Flow and Debugging

Debug Log Output

You can output debug logs by pressing the button in the top left of the component. Debug logs display the values of tp/tv/ap/av/cp/cv properties and variables.

Action Program Processing Order

Action programs are processed in the following order:

  1. Get component variables including Payload from the queue
  2. If there are PostMappings values from the previous component, assignment is performed
  3. PreMappings expressions are evaluated and values are assigned
  4. Component executes processing according to properties
  5. Create new component variables including Payload based on component processing results
  6. PostMappings expressions are evaluated, and result values are stored in new component variables including Payload
  7. Pass new component variables including Payload to the next component’s queue
  8. Repeat process (return to 1)

When debug log function is ON, variable contents after step 3 (PreMappings evaluation and assignment) are output. This allows you to check variable states at each step.

Note that while components normally operate independently in parallel, when executing actions with debug log output, synchronous processing occurs in the action engine.

8. File Path Notation

Files specified in component properties can use various file path formats. Here’s how to write paths for different cases.

Default Reference/Save Location When File Path Is Not Specified

The default location varies by OS:

Various File Path Notation Methods

1. Files in data folder

For non-Windows

File Path Description
sample.txt Specifies sample.txt in actmgr/data folder
./sample.txt Specifies sample.txt in actmgr/data folder

For Windows

File Path Description
sample.txt Specifies sample.txt in actmgr/data folder
.\sample.txt Specifies sample.txt in actmgr/data folder

2. Files with Relative Paths from data folder

For non-Windows

File Path Description
../../../../gravio/sample.txt Specifies gravio/sample.txt 4 levels up from actmgr/data folder

For Windows

File Path Description
..\..\..\..\gravio/sample.txt Specifies gravio\sample.txt 4 levels up from actmgr/data folder

3. Files with Absolute Paths

For non-Windows

File Path Description
/home/gravio/sample.txt Specifies home/gravio/sample.txt under root

For Windows

File Path Description
c:\temp\sample.txt Specifies temp\sample.txt under c: drive

Note: These examples assume reading a sample.txt file.

9. Specifying Attachments

Some action components, such as email sending and HTTP sending, handle attachments. Here’s how to specify attachments.

Attachments

Multiple files can be specified as attachments. File path notation differs by OS environment, so follow these guidelines.

Specifying Attachments in Windows

In Windows, actmgr\data is automatically stored in file paths. Path specification is also possible.

Note: When folder or file names contain spaces, they must be enclosed in " (double quotes).

Basic Examples:

Absolute Path Examples:

Multiple Files and Wildcards:

You can specify multiple files and use wildcards. Use ; (semicolon) as separator for multiple files and * (asterisk) for wildcards.

Specifying Attachments in Mac, Linux, RaspberryPI, Gravio Hub

In Unix-based systems, actmgr/data is automatically stored in file paths. Path specification is also possible.

Note: When folder or file names contain spaces, they must be enclosed in " (double quotes).

Basic Examples:

Absolute Path Examples:

Multiple Files and Wildcards:

You can specify multiple files and use wildcards. Use ; (semicolon) as separator for multiple files and * (asterisk) for wildcards.

By using the correct path separators and file specification methods for your OS environment, you can properly specify attachments. Remember to always enclose paths containing spaces in double quotes.