campaign.template.create

The campaign.template.create command is used to create a campaign template.

TR50 Request

{
  "1": {
    "command": "campaign.template.create",
    "params": {
      "name": "My campaign template",
      "desc": "A sample campaign template",
      "group": "basic samples",
      "naturalDesc": "When the [[temperaturePropertyKey]] exceeds [[propertyValue]], change the [[temperatureAlarmKey]]
       state to [[temperatureAlarmState]]",
      "fields": [
        {
          "key": "temperaturePropertyKey",
          "desc": "The thing property key for a temperature",
          "type": "string"
        },
        {
          "key": "propertyValue",
          "desc": "The property value lower threshold",
          "type": "number"
        },
        {
          "key": "temperatureAlarmKey",
          "desc": "The thing alarm key for a temperature",
          "type": "string"
        },
        {
          "key": "temperatureAlarmState",
          "desc": "The alarm state",
          "type": "number"
        }
      ],
      "campaign": "{
        \"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\"
            }
          ]
        }
      }"
    }
  }
}

Request Parameters

Name Type Required Description
name String Yes The name of the campaign template.
desc String A description of the campaign template.
group String Yes An arbitrary label used to group templates.
naturalDesc String Yes A meaningful description usually with the variables.
fields Array An optional array containing a structure of variables used to customize a campaign based on the campaign template.
campaign String Yes The template used to create new campaigns. For more information, see campaign.create.

Fields Parameters

Name Type Required Description
key String Yes The name of the variable used in the campaign template.
desc String A description of the contents of the variable.
type String Yes The type of data the variable will contain.
options Array An array of possible options for the variable.

TR50 Response

If the command is sent successfully a success message and the id of the new campaign template is returned. Otherwise, an error and error message will be returned.

{
  "1": {
    "success": true,
    "params": {
      "id": "58b43ad4b2157c704f26005f"
    }
  }
}

Response Parameters

Name Type Description
id String The ID of the newly created campaign template.