trigger.template.find

The trigger.template.find command is used to find and return a trigger template.

TR50 Request

// find by id									{
  "1": {
    "command": "trigger.template.find",
    "params": {
      "id": "53728d6b31004662fe000052"
    }
  }
}
// find by name
{
  "cmd": {
    "command": "trigger.template.find",
    "params": {
      "name": "trigger_template_name"
    }
  }
}

Request Parameters

Name Type Required Description

id

String Yes* The unique identifier of the trigger template.
name String The name of the trigger template.

*One of the above fields must be used to find the trigger template

TR50 Response

If the command is sent successfully a success message and the result is returned. Otherwise, an error and error message will be returned.

{
    "1": {
        "success": true,
        "params": {
            "id": "53728d6b31004662fe000052",
            "orgId": "534c36e53100460721000051",
            "orgKey": "DEV",
            "name": "Inventory status set template",
            "desc": "Update inventory ",
            "group": "testGroup",
            "naturalDesc": "if [[num]] < inventory, then publish [[thingKey]]",
            "fields": [
                {
                    "key": "num",
                    "type": "number"
                },
                {
                    "key": "thingKey",
                    "type": "string"
                }
            ],
            "trigger": "{
        \"desc\": \"Too hot\",
        \"eventType\": \"property.change\",
        \"event\": {
          \"thingKey\": \"$(event.thing.key)\",
          \"propKey\": \"[[temperaturePropertyKey]]\",
          \"operator\": \"gt\",
          \"operand\": [[propertyValue]]
        },
        \"actions\": {
          \"0\": {
            \"type\": \"alarm.publish\",
            \"params\": {
              \"thingKey\": \"$(event.thing.key)\",
              \"alarmKey\": \"[[temperatureAlarmKey]]\",
              \"state\": [[temperatureAlarmState]]
            },
            \"canvas\": {
              \"left\": \"241.846\",
              \"top\": \"236.830\",
              \"success\": \"success-end0\"
            },
            \"routes\": {
              \"success\": \"$endSuccess\",
              \"failure\": \"$endFailure\"
            }
          }
        },
        \"firstAction\": \"0\",
        \"canvas\": {
          \"event\": {
            \"left\": \"50.000\",
            \"top\": \"50.000\"
          },
          \"success-end0\": [
            {
              \"left\": \"261.824\",
              \"top\": \"304.754\"
            }
          ]
        }
      }",
            "createdBy": "user@example.com",
            "createdOn": "2017-05-16T21:22:35.226Z",
            "updatedBy": "user@example.com",
            "updatedOn": "2017-05-16T21:22:35.226Z"
        }
    }
}

Response Parameters

Name Type Description
id String The unique identifier of the trigger template.
orgId String The ID of the org.
orgKey String The key of the org.
name String The name of the trigger template.
desc String The description of the trigger template.
group String The arbitrary label of the group the template belongs to.
naturalDesc String A sentence (or set of sentences) that describe the trigger the template will generate, and how it's variables will be used.
trigger String The template used to create new triggers. See trigger.create for more information.
createdBy String  The creator of this trigger template.
createdOn String The creation timestamp of this trigger template.
updatedBy String The updater of this trigger template.
updatedOn String The update timestamp of this trigger template.