Segment JSON schema

LaunchRules.json

This is an optional file that defines the launch rules for a segment
{
  "voicePattern": array [
    {
      "domain": string (required),
      "name": array [
        string
      ],
      "phrase": array [
        string
      ]
    }
  ],
  "rules": array [
    {
      "comment": string,
      "argumentObject": object (required) {
        "cueVoice": string (required),
        "cueVoiceArgs": array [
          string
        ],
        "args": any (required)
      },
      "trigger": object {
        "time": array [
          time
        ],
        "repeat": array [
          integer
        ],
        "placeEvent": array [
          enum ["HOME_ENTER", "HOME_EXIT", "OFFICE_ENTER", "OFFICE_EXIT"]
        ],
        "transportationEvent": array [
          enum ["GOING_TO_WORK", "LEAVING_WORK"]
        ],
        "activityChange": array [
          {
            "beforeActivity": array [
              enum ["STAYING", "WALKING", "RUNNING", "GETTING_ON_VEHICLE", "RIDING_BICYCLE"]
            ],
            "afterActivity": array [
              enum ["STAYING", "WALKING", "RUNNING", "GETTING_ON_VEHICLE", "RIDING_BICYCLE"]
            ]
          }
        ],
        "geofence": array [
          {
            "geo": geo (required),
            "enterExit": enum (required) ["ENTER", "EXIT"]
          }
        ],
        "systemStart": array [
          number
        ]
      },
      "state": object {
        "timeSlot": array [
          {
            "startTime": time (required),
            "endTime": time (required)
          }
        ],
        "intervalFromPrevious": array [
          integer
        ],
        "place": array [
          enum ["HOME", "OFFICE", "OTHER_PLACE"]
        ],
        "transportation": array [
          enum ["GOING_TO_WORK", "LEAVING_WORK"]
        ],
        "activity": array [
          enum ["STAYING", "WALKING", "RUNNING", "GETTING_ON_VEHICLE", "RIDING_BICYCLE"]
        ],
        "geolocation": array [
          geo
        ],
        "dayOfWeek": array [
          enum ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"]
        ]
      }
    }
  ]
}

Example

Properties

"voicePattern"

Start a segment by voice command.
When multiple start conditions are registered, it will trigger start if any of them matches.

"domain"

Set to "CUSTOMAPP" here.

"name"

The segment's name for voice command. User can launch the segment by speaking "Start segment-name" or "check segment-name".

"phrase"

You have the option to allow the user to speak naturally to launch your segment. You can use regular expression style syntax to make this natural speech possible. For instance "(open|launch) my (applications*|apps*)" You can provide the strings in upper or lowercase format.

"rules"

Start a segment by the defined rules.
When multiple start conditions are registered, it will trigger start if any of them matches.

"comment"

The description of the rule.

"argumentObject"

The argument object passed to the segment that is launched by the rule.

"cueVoice"

The script for the initial speech. The string for the cueVoice or the name of the audio file that contains the cueVoice are specified in the scripts.json file.

"cueVoiceArgs"

The strings to replace the ${ARG0}, ${ARG1}... arguments in the cueVoice strings specified in scripts.json for TTS.

"args"

The object that is passed to Segment's onStart callback.

"trigger"

The condition that triggers the strat of the segment if the current state matches any of the registered states in this schema.
When multiple conditions are registered, it will trigger start if any of them matches.

"time"

Triggers the start of the segment at a specific time.
When multiple conditions are registered, it will trigger start if any of them matches.

"repeat"

Periodically triggers the start of the segment .
The interval time for the trigger should be specified in minutes.

"placeEvent"

["HOME_ENTER", "HOME_EXIT", "OFFICE_ENTER", "OFFICE_EXIT"]

Triggers the start of the segment when entering to or exiting from home or office.
When multiple conditions are registered, it will trigger start if any of them matches.

"transportationEvent"

["GOING_TO_WORK", "LEAVING_WORK"]

Triggers the start of the segment when going to or leaving work
When multiple conditions are registered, it will trigger start if any of them matches.

"activityChange"

Triggers the start of the segment when the current activity has been changed.
When multiple conditions are registered, it will trigger start if any of them matches.

"beforeActivity"

["STAYING", "WALKING", "RUNNING", "GETTING_ON_VEHICLE", "RIDING_BICYCLE"]

A list of activities that the current activity switched from. Omitting means any activities.
When multiple conditions are registered, it will trigger start if any of them matches.

"afterActivity"

["STAYING", "WALKING", "RUNNING", "GETTING_ON_VEHICLE", "RIDING_BICYCLE"]

A list of activities that the current activity switched to. Omitting means any action.
When multiple conditions are registered, it will trigger start if any of them matches.

"geofence"

Triggers the start of the segment when entering to or exiting the given location.
When multiple conditions are registered, it will trigger start if any of them matches.

"geo"

The location that contains latitude, longitude and radius.

"enterExit"

["ENTER", "EXIT"]

Enter or exit the given location.

"systemStart"

Triggers the start of the segment after a certain time has been elapsed from the time when the system is launched or woken up. The elapsed time is specified in minutes.
When multiple conditions are registered, it will trigger start if any of them matches.

"state"

The state to be matched for a launch rule to trigger the start of the segment.
When multiple properties are registered, the launch rule can trigger the start of the segment only if all the properties are matched.

"timeSlot"

The time slot to be matched.
When multiple states are registered, it will trigger start if any of them matches.

"startTime"

The start of the time slot.

"endTime"

The end of the time slot

"intervalFromPrevious"

The interval from the previous launch to be matched.

"place"

["HOME", "OFFICE", "OTHER_PLACE"]

The surrounding to be matched.
When multiple places are registered, it will trigger start if any of them matches

"transportation"

["GOING_TO_WORK", "LEAVING_WORK"]

The transportation to be matched.
When multiple states are registered, it will trigger start if any of them matches

"activity"

["STAYING", "WALKING", "RUNNING", "GETTING_ON_VEHICLE", "RIDING_BICYCLE"]

The activities to be matched.
When multiple actions are registered, it will trigger start if any of them matches

"geolocation"

The location to be matched.
When multiple states are registered, it will trigger start if any of them matches

"dayOfWeek"

["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"]

The day of a week to be matched.
When multiple days are registered, it will trigger start if any of them matches

Sub Schemas

The schema defines the following additional types:

time (object)

The time schema.
{
  "hour": integer (required),
  "minute": integer (required)
}

Properties

"hour"

The hour of the time

Restrictions: Minimum: 0, Maximum: 23

"minute"

The minute of the time

Restrictions: Minimum: 0, Maximum: 59

geo (object)

The location schema.
{
  "latitude": number (required),
  "longitude": number (required),
  "radius": number (required)
}

Properties

"latitude"

The latitude value in degrees [DEG]

Restrictions: Minimum: -90, Maximum: 90

"longitude"

The longitude value in degrees [DEG]

Restrictions: Minimum: -180, Maximum: 180

"radius"

The accuracy of the location radius in meters.

Restrictions: Minimum: 100