SlideShare a Scribd company logo
IBM Watson Internet of Things
IBM Watson IoT Platform
Action Manager Concepts &
API Overview
Version 1.0
IBM Watson Internet of Things
Agenda
•Overview
•Resources
– Actions
– Triggers
•Actions API Overview
•Triggers API Overview
•Processing Walkthrough
IBM Watson Internet of Things
Overview
•The Action Manager is a general purpose component that can invoke actions when
events occur within the platform
•Examples of events that could trigger actions:
– Embedded rule fires
– Device/Thing State update (future)
– Configuration change (future)
•Examples of the types of Action that could be supported:
– Webhook
– Email (future)
– MQTT (future)
– etc…
IBM Watson Internet of Things
Agenda
•Overview
•Resources
– Actions
– Triggers
•Actions API Overview
•Triggers API Overview
•Processing Walkthrough
IBM Watson Internet of Things
Resources – Actions
• An action represents the action to be performed, i.e.:
– Invoke a webhook
– Send an email
– Publish an MQTT event
– Etc..
• The Action resource:
– Encapsulates all of the metadata required to perform the
action
– Is intended to be agnostic of how it is invoked
v Allows different triggers to be defined for the same action
– Defines a common set of metadata
v Name
v Id
v Description
v Type
v Configuration
v Enabled
v Etc…
Action
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
…
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com",
"refs": {
"triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers"
}
}
IBM Watson Internet of Things
Resources – Actions
•The Action resource is polymorphic
Action
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
…
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com",
"refs": {
"triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers"
}
}
IBM Watson Internet of Things
Resources – Actions
•The Action resource is polymorphic
•The type of the action is defined by the type
property
Action
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
…
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com",
"refs": {
"triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers"
}
}
IBM Watson Internet of Things
Resources – Actions
•The Action resource is polymorphic
•The type of the action is defined by the type
property
•The value of the configuration property varies
depending on the type of the action
Action
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
…
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com",
"refs": {
"triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers"
}
}
IBM Watson Internet of Things
Resources – Webhook Actions
•A Webhook Action is used to invoke a webhook
Action
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [
{
"name": "mycustomheader",
"value": "{{somevalue}}"
}
],
"body": "{"id" : {{theId}}, "data": "{{theData}}"}"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com",
"refs": {
"triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers"
}
}
Webhook
Action
IBM Watson Internet of Things
Resources – Webhook Actions
•A Webhook Action is used to invoke a webhook
•The configuration property must define the
following properties:
– targetUrl
Action
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [
{
"name": "mycustomheader",
"value": "{{somevalue}}"
}
],
"body": "{"id" : {{theId}}, "data": "{{theData}}"}"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com",
"refs": {
"triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers"
}
}
Webhook
Action
IBM Watson Internet of Things
Resources – Webhook Actions
•A Webhook Action is used to invoke a webhook
•The configuration property must define the
following properties:
– targetUrl
•It can also define the following optional
properties:
– method (defaults to POST)
– contentType (defaults to application/json)
– username
– password
– headers (defaults to empty array)
– body (defaults to empty string)
Action
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [
{
"name": "mycustomheader",
"value": "{{somevalue}}"
}
],
"body": "{"id" : {{theId}}, "data": "{{theData}}"}"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com",
"refs": {
"triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers"
}
}
Webhook
Action
IBM Watson Internet of Things
Resources – EMail Actions (future)
•An EMail Action is used to send an email
Action
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "email",
"enabled": true,
"configuration": {
"host": "smtp.gmail.com",
"port": 587,
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"to": [
"jane.doe@us.ibm.com",
],
"cc": [],
"bcc": [],
"subject": "{{alertType}} alert from the WIoTP Platform"
"content": "The state has changed {{state}}",
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com",
"refs": {
"triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers"
}
}
Email
Action
IBM Watson Internet of Things
Resources – EMail Actions (future)
•An EMail Action is used to send an email
•The configuration property must define the
following properties:
– host
– port
– username
– password
– to
Action
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "email",
"enabled": true,
"configuration": {
"host": "smtp.gmail.com",
"port": 587,
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"to": [
"jane.doe@us.ibm.com",
],
"cc": [],
"bcc": [],
"subject": "{{alertType}} alert from the WIoTP Platform"
"content": "The state has changed {{state}}",
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com",
"refs": {
"triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers"
}
}
Email
Action
IBM Watson Internet of Things
Resources – EMail Actions (future)
•An EMail Action is used to send an email
•The configuration property must define the
following properties:
– host
– port
– username
– password
– to
•It can also define the following optional
properties:
– subject (defaults to empty string)
– content (defaults to empty string)
– cc (defaults to empty array)
– bcc (defaults to empty array)
Action
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "email",
"enabled": true,
"configuration": {
"host": "smtp.gmail.com",
"port": 587,
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"to": [
"jane.doe@us.ibm.com",
],
"cc": [],
"bcc": [],
"subject": "{{alertType}} alert from the WIoTP Platform"
"content": "The state has changed {{state}}",
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com",
"refs": {
"triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers"
}
}
Email
Action
IBM Watson Internet of Things
Resources – Action Variables
•The properties defined on the configuration
object can also include variables
Action
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [
{
"name": "mycustomheader",
"value": "{{somevalue}}"
}
],
"body": "{"id" : {{theId}}, "data": "{{theData}}"}"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com",
"refs": {
"triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers"
}
}
IBM Watson Internet of Things
Resources – Action Variables
•The properties defined on the configuration
object can also include variables
•Variables are defined using Mustache syntax
http://mustache.github.io/mustache.5.html
Action
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [
{
"name": "mycustomheader",
"value": "{{somevalue}}"
}
],
"body": "{"id" : {{theId}}, "data": "{{theData}}"}"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com",
"refs": {
"triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers"
}
}
IBM Watson Internet of Things
Resources – Action Variables
•The properties defined on the configuration
object can also include variables
•Variables are defined using Mustache syntax
http://mustache.github.io/mustache.5.html
•An action can define a maximum of 32 unique
variables
•The values of the variables are defined by the
triggers for the action (more on this later)
Action
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [
{
"name": "mycustomheader",
"value": "{{somevalue}}"
}
],
"body": "{"id" : {{theId}}, "data": "{{theData}}"}"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com",
"refs": {
"triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers"
}
}
IBM Watson Internet of Things
Resources – Action Variables
•The following features of Mustache are
supported:
– Variables
{{myVariable}}
– Sections
{{#mySection}}
Hello {{name}}
{{/mySection}}
– Inverted Sections
{{^myInvertedSection}}
No name specified!!!
{{/myInvertedSection}}
– Comments
{{! A Comment}}
Action
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [
{
"name": "mycustomheader",
"value": "{{somevalue}}"
}
],
"body": "{"id" : {{theId}}, "data": "{{theData}}"}"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com",
"refs": {
"triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers"
}
}
IBM Watson Internet of Things
Resources – Action Variables
•The following features of Mustache are not
supported:
– Partials
{{> myPartial}}
– Lambdas
– Setting delimiters
{{=<% %>=}}
<% erb_style_tags %>
<%={{ }}=%>
Action
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [
{
"name": "mycustomheader",
"value": "{{somevalue}}"
}
],
"body": "{"id" : {{theId}}, "data": "{{theData}}"}"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com",
"refs": {
"triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers"
}
}
IBM Watson Internet of Things
Agenda
•Overview
•Resources
– Actions
– Triggers
•Actions API Overview
•Triggers API Overview
•Processing Walkthrough
IBM Watson Internet of Things
Resources – Triggers
•In order for an action to be invoked, you need to
define at least one trigger for the action
– Triggers are a sub-resource of an Action in the REST
resource hierarchy
•A trigger:
– Maps an internal event within the platform onto
the target action
– Defines a common set of metadata
v Name
v Id
v Description
v Type
v VariableMappings
v Configuration
v Enabled
v Etc…
Trigger
{
"id": "5848040f6522050001db0e20",
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "rule",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
…
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
IBM Watson Internet of Things
Resources – Triggers
•The Trigger resource is polymorphic
Trigger
{
"id": "5848040f6522050001db0e20",
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "rule",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
…
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
IBM Watson Internet of Things
Resources – Triggers
•The Trigger resource is polymorphic
•The type of the trigger is defined by the type
property
Trigger
{
"id": "5848040f6522050001db0e20",
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "rule",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
…
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
IBM Watson Internet of Things
Resources – Triggers
•The Trigger resource is polymorphic
•The type of the trigger is defined by the type
property
•The value of the configuration property varies
depending on the type of the trigger
Trigger
{
"id": "5848040f6522050001db0e20",
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "rule",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
…
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
IBM Watson Internet of Things
Resources – Rule Triggers
•A Rule Trigger invokes an Action when an
embedded rule fires
Trigger
{
"id": "5848040f6522050001db0e20",
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "rule",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
"logicalInterfaceId": "123456789012345678901234",
"ruleId": "098765432109876543210987",
"type": "device",
"typeId": "TempSensor",
"instanceId": "ts001"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
Rule
Trigger
IBM Watson Internet of Things
Resources – Rule Triggers
•A Rule Trigger invokes an Action when an
embedded rule fires
•The configuration property must define the
following properties:
– logicalInterfaceId
– ruleId
v A wildcard (*) can be specified for the ruleId property
v Specifies that the action will be invoked if any of the
rule on the logical interface fire
– type
v One of device, thing or *
– typeId
v The id of the device or thing type or *
– instanceId
v The id of the device or thing or *
Trigger
{
"id": "5848040f6522050001db0e20",
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "rule",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
"logicalInterfaceId": "123456789012345678901234",
"ruleId": "098765432109876543210987",
"type": "device",
"typeId": "TempSensor",
"instanceId": "ts001"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
Rule
Trigger
IBM Watson Internet of Things
Resources – State Triggers (future)
•A State Trigger invokes an Action when the state
of a Device/Thing changes
Trigger
{
"id": "5848040f6522050001db0e20",
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "state",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
"logicalInterfaceId": "123456789012345678901234",
"type": "device",
"typeId": "TempSensor",
"instanceId": "ts001"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
State
Trigger
IBM Watson Internet of Things
Resources – State Triggers (future)
•A State Trigger invokes an Action when the state
of a Device/Thing changes
•The configuration property must define the
following properties:
– logicalInterfaceId
– type
v One of device, thing or *
– typeId
v The id of the device or thing type or *
– instanceId
v The id of the device or thing or *
Trigger
{
"id": "5848040f6522050001db0e20",
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "state",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
"logicalInterfaceId": "123456789012345678901234",
"type": "device",
"typeId": "TempSensor",
"instanceId": "ts001"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
State
Trigger
IBM Watson Internet of Things
Resources – Trigger Variable Mappings
•The variable mappings defined by a Trigger specify
how to map data from the platform event to the
variables required by the action
Trigger
{
"id": "5848040f6522050001db0e20",
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "rule",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
…
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
IBM Watson Internet of Things
Resources – Trigger Variable Mappings
•The variable mappings defined by a Trigger specify
how to map data from the platform event to the
variables required by the action
•The keys are the names of the variables defined in
the action configuration
Trigger
{
"id": "5848040f6522050001db0e20",
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "rule",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
…
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
IBM Watson Internet of Things
Resources – Trigger Variable Mappings
•The variable mappings defined by a Trigger specify
how to map data from the platform event to the
variables required by the action
•The keys are the names of the variables defined in
the action configuration
•The values are JSONata expressions
Trigger
{
"id": "5848040f6522050001db0e20",
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "rule",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
…
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
IBM Watson Internet of Things
Agenda
•Overview
•Resources
– Actions
– Triggers
•Actions API Overview
•Triggers API Overview
•Processing Walkthrough
IBM Watson Internet of Things
Actions API Overview
•CRUD operations can be performed against the actions resource using the
APIs shown below
•NOTE: The actions resource does not follow the draft/active model used by
other IM resources. You do not need to activate changes in order for them
to be effective.
POST /actions
PUT /actions/{actionId}
DELETE /actions/{actionId}
GET /actions
GET /actions/{actionId}
PATCH /actions/{actionId}
IBM Watson Internet of Things
Creating an Action Resource
• In order to create an action you need to perform a HTTP
POST against the /actions resource, as shown below:
• NOTE:
For security reasons, the username and password properties
are obfuscated in the responses to the REST API calls
Action
POST /actions
{
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [ {"name": "mycustomheader", "value": "{{somevalue}}"} ],
"body": "{"id" : {{theId}}, "data": "{{theData}}"}"
}
}
IBM Watson Internet of Things
Agenda
•Overview
•Resources
– Actions
– Triggers
•Actions API Overview
•Triggers API Overview
•Processing Walkthrough
IBM Watson Internet of Things
Triggers API Overview
•CRUD operations can be performed against the triggers resource using the
APIs shown below
•NOTE: The triggers resource does not follow the draft/active model used by
other IM resources. You do not need to activate changes in order for them
to be effective.
POST /triggers
PUT /triggers/{triggerId}
DELETE /triggers/{triggerId}
GET /triggers
GET /triggers/{triggerId}
IBM Watson Internet of Things
Creating a Trigger Resource
• Once an action has been created in the Platform, the
next step is to create a trigger resource
– Triggers are a sub-resource of an action in the REST
resource hierarchy
• In order to create a trigger you need to perform a HTTP
POST against the /actions/{actionId}/triggers resource,
as shown below:
Action
POST /actions/{actionId}/triggers
{
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "rule",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
"logicalInterfaceId": "123456789012345678901234",
"ruleId": "098765432109876543210987",
"type": "device",
"typeId": "TempSensor",
"instanceId": "ts001"
}
}
Trigger
IBM Watson Internet of Things
Agenda
•Overview
•Resources
– Actions
– Triggers
•Actions API Overview
•Triggers API Overview
•Processing Walkthrough
IBM Watson Internet of Things
Action-Mgr Service Processing Walkthrough
{
"id": "5848040f6522050001db0e20",
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "rule",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
"logicalInterfaceId": "123456789012345678901234",
"ruleId": "098765432109876543210987",
"type": "device",
"typeId": "TempSensor",
"instanceId": "ts001"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [
{
"name": "mycustomheader",
"value": "{{somevalue}}"
}
],
"body": "{"id" : {{theId}}, "data": "{{theData}}"}"
},
…
}
Rule Trigger Webhook Action
•A rule trigger and webhook action have been created within the platform
IBM Watson Internet of Things
Action-Mgr Service Processing Walkthrough
{
"id": "5848040f6522050001db0e20",
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "rule",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
"logicalInterfaceId": "123456789012345678901234",
"ruleId": "098765432109876543210987",
"type": "device",
"typeId": "TempSensor",
"instanceId": "ts001"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [
{
"name": "mycustomheader",
"value": "{{somevalue}}"
}
],
"body": "{"id" : {{theId}}, "data": "{{theData}}"}"
},
…
}
{
"type": "device",
"typeId" : "TempSensor",
"instanceId" : "ts001",
"logicalInterfaceId": "123456789012345678901234",
"ruleId": "098765432109876543210987",
"ruleCondition": "$state.temperature > 40",
"state": {
"equipmentId": "12345",
"temperatureReading": 45
},
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
Rule Event Rule Trigger Webhook Action
•A rule trigger and webhook action have been created within the platform
•When a rule fires…
IBM Watson Internet of Things
Action-Mgr Service Processing Walkthrough
{
"id": "5848040f6522050001db0e20",
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "rule",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
"logicalInterfaceId": "123456789012345678901234",
"ruleId": "098765432109876543210987",
"type": "device",
"typeId": "TempSensor",
"instanceId": "ts001"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [
{
"name": "mycustomheader",
"value": "{{somevalue}}"
}
],
"body": "{"id" : {{theId}}, "data": "{{theData}}"}"
},
…
}
{
"type": "device",
"typeId" : "TempSensor",
"instanceId" : "ts001",
"logicalInterfaceId": "123456789012345678901234",
"ruleId": "098765432109876543210987",
"ruleCondition": "$state.temperature > 40",
"state": {
"equipmentId": "12345",
"temperatureReading": 45
},
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
Rule Event Rule Trigger Webhook Action
•A rule trigger and webhook action have been created within the platform
•When a rule fires…
•… the Action Manager checks to see if there is a matching rule trigger
IBM Watson Internet of Things
Action-Mgr Service Processing Walkthrough
{
"id": "5848040f6522050001db0e20",
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "rule",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
"logicalInterfaceId": "123456789012345678901234",
"ruleId": "098765432109876543210987",
"type": "device",
"typeId": "TempSensor",
"instanceId": "ts001"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
{
"type": "device",
"typeId" : "TempSensor",
"instanceId" : "ts001",
"logicalInterfaceId": "123456789012345678901234",
"ruleId": "098765432109876543210987",
"ruleCondition": "$state.temperature > 40",
"state": {
"equipmentId": "12345",
"temperatureReading": 45
},
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
Rule Event Rule Trigger
{
"someValue": "myHeaderValue"
}
Variable Dictionary
•Having found a matching trigger, the Action Manager evaluates the variable
mappings to create the variable dictionary
•The first variable mapping (someValue) simply contains a constant value, so
this is added to the dictionary
IBM Watson Internet of Things
Action-Mgr Service Processing Walkthrough
{
"id": "5848040f6522050001db0e20",
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "rule",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
"logicalInterfaceId": "123456789012345678901234",
"ruleId": "098765432109876543210987",
"type": "device",
"typeId": "TempSensor",
"instanceId": "ts001"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
{
"type": "device",
"typeId" : "TempSensor",
"instanceId" : "ts001",
"logicalInterfaceId": "123456789012345678901234",
"ruleId": "098765432109876543210987",
"ruleCondition": "$state.temperature > 40",
"state": {
"equipmentId": "12345",
"temperatureReading": 45
},
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
Rule Event Rule Trigger
{
"someValue": "myHeaderValue",
"theId": "12345"
}
Variable Dictionary
•The second variable mapping (theId) is assigned the value of the
state.equipmentId property from the rule notification event
IBM Watson Internet of Things
Action-Mgr Service Processing Walkthrough
{
"id": "5848040f6522050001db0e20",
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "rule",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
"logicalInterfaceId": "123456789012345678901234",
"ruleId": "098765432109876543210987",
"type": "device",
"typeId": "TempSensor",
"instanceId": "ts001"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
{
"type": "device",
"typeId" : "TempSensor",
"instanceId" : "ts001",
"logicalInterfaceId": "123456789012345678901234",
"ruleId": "098765432109876543210987",
"ruleCondition": "$state.temperature > 40",
"state": {
"equipmentId": "12345",
"temperatureReading": 45
},
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
Rule Event Rule Trigger
{
"someValue": "myHeaderValue",
"theId": "12345",
"theData": "45"
}
Variable Dictionary
•The third variable mapping (theData) is assigned the value of the
state.temperatureReading property from the rule notification event
IBM Watson Internet of Things
Action-Mgr Service Processing Walkthrough
{
"someValue": "myHeaderValue",
"theId": "12345",
"theData": "45"
}
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [
{
"name": "mycustomheader",
"value": "{{somevalue}}"
}
],
"body": "{"id" : {{theId}}, "data": "{{theData}}"}"
},
…
}
Webhook Action
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [
{
"name": "mycustomheader",
"value": "myHeaderValue"
}
],
"body": "{"id" : {{theId}}, "data": "{{theData}}"}"
},
…
}
Variable Dictionary Resolved Action
•Having created the variable dictionary, the Action Manager substitutes the
variables in the action with the corresponding values from the dictionary
•The variable someValue is replaced with the value myHeaderValue
IBM Watson Internet of Things
Action-Mgr Service Processing Walkthrough
{
"someValue": "myHeaderValue",
"theId": "12345",
"theData": "45"
}
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [
{
"name": "mycustomheader",
"value": "{{somevalue}}"
}
],
"body": "{"id" : {{theId}}, "data": "{{theData}}"}"
},
…
}
Webhook Action
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [
{
"name": "mycustomheader",
"value": "myHeaderValue"
}
],
"body": "{"id" : 12345, "data": "{{theData}}"}"
},
…
}
Variable Dictionary Resolved Action
•The variable theId is replaced with the value 12345
IBM Watson Internet of Things
Action-Mgr Service Processing Walkthrough
{
"someValue": "myHeaderValue",
"theId": "12345",
"theData": "45"
}
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [
{
"name": "mycustomheader",
"value": "{{somevalue}}"
}
],
"body": "{"id" : {{theId}}, "data": "{{theData}}"}"
},
…
}
Webhook Action
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [
{
"name": "mycustomheader",
"value": "myHeaderValue"
}
],
"body": "{"id" : 12345, "data": "45"}"
},
…
}
Variable Dictionary Resolved Action
•The variable theData is replaced with the value 45
IBM Watson Internet of Things
Action-Mgr Service Processing Walkthrough
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [
{
"name": "mycustomheader",
"value": "myHeaderValue"
}
],
"body": "{"id" : 12345, "data": "45"}"
},
…
}
Resolved Action
Watson IoT Platform
Action Manager
Device
Gateway
& Edge
Cognitive
Engine
Application
UI
Device
Device
Webhook
•Once all of the variables in the action have been
processed, the resolved action is used to invoke
the target webhook
IBM Watson Internet of Things
Backup
IBM Watson Internet of Things
Resources – Actions
• Retrieve the list of actions that have been defined for an organization in the Watson IoT
Platform
• The following query parameters are supported:
– _bookmark, _limit, _sort, name, type and enabled
{
"results": [ {
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [ {"name": "mycustomheader", "value": "{{somevalue}}"} ],
"body": "{"id" : {{theId}}, "data": "{{theData}}"}"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com",
"refs": {
"triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers"
}
} ],
"meta": {
"facets":{},
"total_rows": 1
}
}
GET /actions
IBM Watson Internet of Things
Resources – Actions
POST /actions
• Creates a new action for an organization in the Watson IoT Platform
• Example POST:
{
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [ {"name": "mycustomheader", "value": "{{somevalue}}"} ],
"body": "{"id" : {{theId}}, "data": "{{theData}}"}"
}
}
IBM Watson Internet of Things
Resources – Actions
POST /actions
• Example response body:
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [ {"name": "mycustomheader", "value": "{{somevalue}}"} ],
"body": "{"id" : {{theId}}, "data": "{{theData}}"}"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com",
"refs": {
"triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers"
}
}
IBM Watson Internet of Things
Resources – Actions
• Retrieve the metadata for a specific action
• Example response body:
GET /actions/{actionId}
{
"id": "5848040f6522050001db0e20",
"name" : "My Webhook Action",
"description" : "An example webhook action",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "http://webhook-sim/abcdef/senddata",
"method": "POST",
"contentType": "application/json",
"username": "john.doe@us.ibm.com",
"password": "passw0rd",
"headers": [ {"name": "mycustomheader", "value": "{{somevalue}}"} ],
"body": "{"id" : {{theId}}, "data": "{{theData}}"}"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com",
"refs": {
"triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers"
}
}
IBM Watson Internet of Things
Resources – Actions
• Perform an operation against the specified action
• Current supported operations are:
– invoke-action
• Example PATCH:
PATCH /actions/{actionId}
{
"operation": "invoke-action"
"variables": {
"someValue": "myHeaderValue",
"theId": "12345",
"theData": "45"
}
}
IBM Watson Internet of Things
Resources – Actions
• Example response body:
PATCH /actions/{actionId}
{
"message": "CUDAM0900I: The action 'Invoke Webhook Sim Action' was successfully invoked.",
"details": {
"id": "CUDAM0900I",
"properties": ["Invoke Webhook Sim Action"]
},
"result": {
"actionId": "5c52ec190ec83c004d8e02f1",
"successful": true,
"type": "webhook",
"status": 200,
"headers": {
"connection": "keep-alive",
"content-type": "text/html; charset=utf-8",
"Content-Length": "20",
"Date": "Thu, 31 Jan 2019 12:37:46 GMT",
"X-Powered-By": "Express"
},
"contentType": "text/html; charset=utf-8",
"body": "{ "success" : true }"
}
}
IBM Watson Internet of Things
Resources – Actions
• Update the metadata for an action
• The following metadata properties can be updated
– name
– description
– configuration
– enabled
PUT /actions/{actionId}
• Delete an action
DELETE /actions/{actionId}
IBM Watson Internet of Things
Resources – Triggers
• Retrieve the list of triggers that have been defined for an action
• The following query parameters are supported:
– _bookmark, _limit, _sort, name, type and enabled
{
"results": [ {
"id": "5848040f6522050001db0e20",
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "rule",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
"logicalInterfaceId": "123456789012345678901234",
"ruleId": "098765432109876543210987",
"type": "device",
"typeId": "TempSensor",
"instanceId": "ts001"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
} ],
"meta": {
"facets": {},
"total_rows": 1
}
}
GET /actions/{actionId}/triggers
IBM Watson Internet of Things
Resources – Triggers
POST /actions/{actionId}/triggers
• Creates a new trigger for an action
• Example POST:
{
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "rule",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
"logicalInterfaceId": "123456789012345678901234",
"ruleId": "098765432109876543210987",
"type": "device",
"typeId": "TempSensor",
"instanceId": "ts001"
}
}
IBM Watson Internet of Things
Resources – Triggers
POST /actions/{actionId}/triggers
• Example response body:
{
"id": "5848040f6522050001db0e20",
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "rule",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
"logicalInterfaceId": "123456789012345678901234",
"ruleId": "098765432109876543210987",
"type": "device",
"typeId": "TempSensor",
"instanceId": "ts001"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
IBM Watson Internet of Things
Resources – Triggers
• Retrieve the metadata for a specific trigger
• Example response body:
GET /actions/{actionId}/triggers/{triggerId}
{
"id": "5848040f6522050001db0e20",
"name" : "My Rule Trigger",
"description" : "An example rule trigger",
"type": "rule",
"enabled": true,
"variableMappings": {
"someValue": "myHeaderValue",
"theId": "$event.state.equipmentId",
"theData": "$event.state.temperatureReading"
},
"configuration": {
"logicalInterfaceId": "123456789012345678901234",
"ruleId": "098765432109876543210987",
"type": "device",
"typeId": "TempSensor",
"instanceId": "ts001"
},
"adminDisabled": false,
"adminDisabledReason": null,
"created": "2018-01-30T13:00:00Z",
"createdBy": "john.doe@us.ibm.com",
"updated": "2018-01-30T14:00:00Z",
"updatedBy": "fred.bloggs@uk.ibm.com"
}
IBM Watson Internet of Things
Resources – Triggers
• Update the metadata for a trigger
• The following metadata properties can be updated
– name
– description
– configuration
– variableMappings
– enabled
PUT /actions/{actionId}/triggers/{triggerId}
• Delete a trigger
DELETE /actions/{actionId}/triggers/{triggerId}

More Related Content

Similar to Watson IoT Action Manager Concepts & API Overview

Mobile services on windows azure (part2)
Mobile services on windows azure (part2)Mobile services on windows azure (part2)
Mobile services on windows azure (part2)Radu Vunvulea
 
javaScript and jQuery
javaScript and jQueryjavaScript and jQuery
javaScript and jQuery
Mehrab Hossain
 
[Serverless Meetup Tokyo #3] Serverless in Azure (Azure Functionsのアップデート、事例、デ...
[Serverless Meetup Tokyo #3] Serverless in Azure (Azure Functionsのアップデート、事例、デ...[Serverless Meetup Tokyo #3] Serverless in Azure (Azure Functionsのアップデート、事例、デ...
[Serverless Meetup Tokyo #3] Serverless in Azure (Azure Functionsのアップデート、事例、デ...
Naoki (Neo) SATO
 
Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
Frédéric Harper
 
An Introduction to webOS
An Introduction to webOSAn Introduction to webOS
An Introduction to webOSKevin Decker
 
Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22
Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22
Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22Frédéric Harper
 
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
Frédéric Harper
 
Automation: The Power of Workflows
Automation: The Power of WorkflowsAutomation: The Power of Workflows
Automation: The Power of Workflows
William McKee
 
Marketing Automation with dotCMS
Marketing Automation with dotCMSMarketing Automation with dotCMS
Marketing Automation with dotCMS
Jason Smith
 
Designing an API for the Internet of Things
Designing an API for the Internet of ThingsDesigning an API for the Internet of Things
Designing an API for the Internet of Things
Kevin Swiber
 
Implementing and Visualizing Clickstream data with MongoDB
Implementing and Visualizing Clickstream data with MongoDBImplementing and Visualizing Clickstream data with MongoDB
Implementing and Visualizing Clickstream data with MongoDB
MongoDB
 
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
Frédéric Harper
 
6.Web Servers
6.Web Servers6.Web Servers
6.Web Servers
Mayank Joneja
 
Hdv309 - Real World Sandboxed Solutions
Hdv309 - Real World Sandboxed SolutionsHdv309 - Real World Sandboxed Solutions
Hdv309 - Real World Sandboxed Solutionswoutervugt
 
WSO2Con USA 2017: Building a Secure Enterprise
WSO2Con USA 2017: Building a Secure EnterpriseWSO2Con USA 2017: Building a Secure Enterprise
WSO2Con USA 2017: Building a Secure Enterprise
WSO2
 
Mobile Software Engineering Crash Course - C06 WindowsPhone
Mobile Software Engineering Crash Course - C06 WindowsPhoneMobile Software Engineering Crash Course - C06 WindowsPhone
Mobile Software Engineering Crash Course - C06 WindowsPhoneMohammad Shaker
 
Medium TechTalk — iOS
Medium TechTalk — iOSMedium TechTalk — iOS
Medium TechTalk — iOS
jimmyatmedium
 
The top 10 security issues in web applications
The top 10 security issues in web applicationsThe top 10 security issues in web applications
The top 10 security issues in web applications
Devnology
 
Maintenance for MongoDB Replica Sets
Maintenance for MongoDB Replica SetsMaintenance for MongoDB Replica Sets
Maintenance for MongoDB Replica Sets
Igor Donchovski
 

Similar to Watson IoT Action Manager Concepts & API Overview (20)

Mobile services on windows azure (part2)
Mobile services on windows azure (part2)Mobile services on windows azure (part2)
Mobile services on windows azure (part2)
 
javaScript and jQuery
javaScript and jQueryjavaScript and jQuery
javaScript and jQuery
 
[Serverless Meetup Tokyo #3] Serverless in Azure (Azure Functionsのアップデート、事例、デ...
[Serverless Meetup Tokyo #3] Serverless in Azure (Azure Functionsのアップデート、事例、デ...[Serverless Meetup Tokyo #3] Serverless in Azure (Azure Functionsのアップデート、事例、デ...
[Serverless Meetup Tokyo #3] Serverless in Azure (Azure Functionsのアップデート、事例、デ...
 
Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
 
An Introduction to webOS
An Introduction to webOSAn Introduction to webOS
An Introduction to webOS
 
Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22
Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22
Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22
 
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
 
Automation: The Power of Workflows
Automation: The Power of WorkflowsAutomation: The Power of Workflows
Automation: The Power of Workflows
 
Marketing Automation with dotCMS
Marketing Automation with dotCMSMarketing Automation with dotCMS
Marketing Automation with dotCMS
 
Designing an API for the Internet of Things
Designing an API for the Internet of ThingsDesigning an API for the Internet of Things
Designing an API for the Internet of Things
 
Implementing and Visualizing Clickstream data with MongoDB
Implementing and Visualizing Clickstream data with MongoDBImplementing and Visualizing Clickstream data with MongoDB
Implementing and Visualizing Clickstream data with MongoDB
 
Cos 432 web_security
Cos 432 web_securityCos 432 web_security
Cos 432 web_security
 
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
 
6.Web Servers
6.Web Servers6.Web Servers
6.Web Servers
 
Hdv309 - Real World Sandboxed Solutions
Hdv309 - Real World Sandboxed SolutionsHdv309 - Real World Sandboxed Solutions
Hdv309 - Real World Sandboxed Solutions
 
WSO2Con USA 2017: Building a Secure Enterprise
WSO2Con USA 2017: Building a Secure EnterpriseWSO2Con USA 2017: Building a Secure Enterprise
WSO2Con USA 2017: Building a Secure Enterprise
 
Mobile Software Engineering Crash Course - C06 WindowsPhone
Mobile Software Engineering Crash Course - C06 WindowsPhoneMobile Software Engineering Crash Course - C06 WindowsPhone
Mobile Software Engineering Crash Course - C06 WindowsPhone
 
Medium TechTalk — iOS
Medium TechTalk — iOSMedium TechTalk — iOS
Medium TechTalk — iOS
 
The top 10 security issues in web applications
The top 10 security issues in web applicationsThe top 10 security issues in web applications
The top 10 security issues in web applications
 
Maintenance for MongoDB Replica Sets
Maintenance for MongoDB Replica SetsMaintenance for MongoDB Replica Sets
Maintenance for MongoDB Replica Sets
 

Recently uploaded

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 

Recently uploaded (20)

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 

Watson IoT Action Manager Concepts & API Overview

  • 1. IBM Watson Internet of Things IBM Watson IoT Platform Action Manager Concepts & API Overview Version 1.0
  • 2. IBM Watson Internet of Things Agenda •Overview •Resources – Actions – Triggers •Actions API Overview •Triggers API Overview •Processing Walkthrough
  • 3. IBM Watson Internet of Things Overview •The Action Manager is a general purpose component that can invoke actions when events occur within the platform •Examples of events that could trigger actions: – Embedded rule fires – Device/Thing State update (future) – Configuration change (future) •Examples of the types of Action that could be supported: – Webhook – Email (future) – MQTT (future) – etc…
  • 4. IBM Watson Internet of Things Agenda •Overview •Resources – Actions – Triggers •Actions API Overview •Triggers API Overview •Processing Walkthrough
  • 5. IBM Watson Internet of Things Resources – Actions • An action represents the action to be performed, i.e.: – Invoke a webhook – Send an email – Publish an MQTT event – Etc.. • The Action resource: – Encapsulates all of the metadata required to perform the action – Is intended to be agnostic of how it is invoked v Allows different triggers to be defined for the same action – Defines a common set of metadata v Name v Id v Description v Type v Configuration v Enabled v Etc… Action { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { … }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com", "refs": { "triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers" } }
  • 6. IBM Watson Internet of Things Resources – Actions •The Action resource is polymorphic Action { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { … }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com", "refs": { "triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers" } }
  • 7. IBM Watson Internet of Things Resources – Actions •The Action resource is polymorphic •The type of the action is defined by the type property Action { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { … }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com", "refs": { "triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers" } }
  • 8. IBM Watson Internet of Things Resources – Actions •The Action resource is polymorphic •The type of the action is defined by the type property •The value of the configuration property varies depending on the type of the action Action { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { … }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com", "refs": { "triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers" } }
  • 9. IBM Watson Internet of Things Resources – Webhook Actions •A Webhook Action is used to invoke a webhook Action { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ { "name": "mycustomheader", "value": "{{somevalue}}" } ], "body": "{"id" : {{theId}}, "data": "{{theData}}"}" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com", "refs": { "triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers" } } Webhook Action
  • 10. IBM Watson Internet of Things Resources – Webhook Actions •A Webhook Action is used to invoke a webhook •The configuration property must define the following properties: – targetUrl Action { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ { "name": "mycustomheader", "value": "{{somevalue}}" } ], "body": "{"id" : {{theId}}, "data": "{{theData}}"}" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com", "refs": { "triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers" } } Webhook Action
  • 11. IBM Watson Internet of Things Resources – Webhook Actions •A Webhook Action is used to invoke a webhook •The configuration property must define the following properties: – targetUrl •It can also define the following optional properties: – method (defaults to POST) – contentType (defaults to application/json) – username – password – headers (defaults to empty array) – body (defaults to empty string) Action { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ { "name": "mycustomheader", "value": "{{somevalue}}" } ], "body": "{"id" : {{theId}}, "data": "{{theData}}"}" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com", "refs": { "triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers" } } Webhook Action
  • 12. IBM Watson Internet of Things Resources – EMail Actions (future) •An EMail Action is used to send an email Action { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "email", "enabled": true, "configuration": { "host": "smtp.gmail.com", "port": 587, "username": "john.doe@us.ibm.com", "password": "passw0rd", "to": [ "jane.doe@us.ibm.com", ], "cc": [], "bcc": [], "subject": "{{alertType}} alert from the WIoTP Platform" "content": "The state has changed {{state}}", }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com", "refs": { "triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers" } } Email Action
  • 13. IBM Watson Internet of Things Resources – EMail Actions (future) •An EMail Action is used to send an email •The configuration property must define the following properties: – host – port – username – password – to Action { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "email", "enabled": true, "configuration": { "host": "smtp.gmail.com", "port": 587, "username": "john.doe@us.ibm.com", "password": "passw0rd", "to": [ "jane.doe@us.ibm.com", ], "cc": [], "bcc": [], "subject": "{{alertType}} alert from the WIoTP Platform" "content": "The state has changed {{state}}", }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com", "refs": { "triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers" } } Email Action
  • 14. IBM Watson Internet of Things Resources – EMail Actions (future) •An EMail Action is used to send an email •The configuration property must define the following properties: – host – port – username – password – to •It can also define the following optional properties: – subject (defaults to empty string) – content (defaults to empty string) – cc (defaults to empty array) – bcc (defaults to empty array) Action { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "email", "enabled": true, "configuration": { "host": "smtp.gmail.com", "port": 587, "username": "john.doe@us.ibm.com", "password": "passw0rd", "to": [ "jane.doe@us.ibm.com", ], "cc": [], "bcc": [], "subject": "{{alertType}} alert from the WIoTP Platform" "content": "The state has changed {{state}}", }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com", "refs": { "triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers" } } Email Action
  • 15. IBM Watson Internet of Things Resources – Action Variables •The properties defined on the configuration object can also include variables Action { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ { "name": "mycustomheader", "value": "{{somevalue}}" } ], "body": "{"id" : {{theId}}, "data": "{{theData}}"}" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com", "refs": { "triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers" } }
  • 16. IBM Watson Internet of Things Resources – Action Variables •The properties defined on the configuration object can also include variables •Variables are defined using Mustache syntax http://mustache.github.io/mustache.5.html Action { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ { "name": "mycustomheader", "value": "{{somevalue}}" } ], "body": "{"id" : {{theId}}, "data": "{{theData}}"}" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com", "refs": { "triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers" } }
  • 17. IBM Watson Internet of Things Resources – Action Variables •The properties defined on the configuration object can also include variables •Variables are defined using Mustache syntax http://mustache.github.io/mustache.5.html •An action can define a maximum of 32 unique variables •The values of the variables are defined by the triggers for the action (more on this later) Action { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ { "name": "mycustomheader", "value": "{{somevalue}}" } ], "body": "{"id" : {{theId}}, "data": "{{theData}}"}" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com", "refs": { "triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers" } }
  • 18. IBM Watson Internet of Things Resources – Action Variables •The following features of Mustache are supported: – Variables {{myVariable}} – Sections {{#mySection}} Hello {{name}} {{/mySection}} – Inverted Sections {{^myInvertedSection}} No name specified!!! {{/myInvertedSection}} – Comments {{! A Comment}} Action { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ { "name": "mycustomheader", "value": "{{somevalue}}" } ], "body": "{"id" : {{theId}}, "data": "{{theData}}"}" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com", "refs": { "triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers" } }
  • 19. IBM Watson Internet of Things Resources – Action Variables •The following features of Mustache are not supported: – Partials {{> myPartial}} – Lambdas – Setting delimiters {{=<% %>=}} <% erb_style_tags %> <%={{ }}=%> Action { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ { "name": "mycustomheader", "value": "{{somevalue}}" } ], "body": "{"id" : {{theId}}, "data": "{{theData}}"}" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com", "refs": { "triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers" } }
  • 20. IBM Watson Internet of Things Agenda •Overview •Resources – Actions – Triggers •Actions API Overview •Triggers API Overview •Processing Walkthrough
  • 21. IBM Watson Internet of Things Resources – Triggers •In order for an action to be invoked, you need to define at least one trigger for the action – Triggers are a sub-resource of an Action in the REST resource hierarchy •A trigger: – Maps an internal event within the platform onto the target action – Defines a common set of metadata v Name v Id v Description v Type v VariableMappings v Configuration v Enabled v Etc… Trigger { "id": "5848040f6522050001db0e20", "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "rule", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { … }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" }
  • 22. IBM Watson Internet of Things Resources – Triggers •The Trigger resource is polymorphic Trigger { "id": "5848040f6522050001db0e20", "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "rule", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { … }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" }
  • 23. IBM Watson Internet of Things Resources – Triggers •The Trigger resource is polymorphic •The type of the trigger is defined by the type property Trigger { "id": "5848040f6522050001db0e20", "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "rule", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { … }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" }
  • 24. IBM Watson Internet of Things Resources – Triggers •The Trigger resource is polymorphic •The type of the trigger is defined by the type property •The value of the configuration property varies depending on the type of the trigger Trigger { "id": "5848040f6522050001db0e20", "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "rule", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { … }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" }
  • 25. IBM Watson Internet of Things Resources – Rule Triggers •A Rule Trigger invokes an Action when an embedded rule fires Trigger { "id": "5848040f6522050001db0e20", "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "rule", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { "logicalInterfaceId": "123456789012345678901234", "ruleId": "098765432109876543210987", "type": "device", "typeId": "TempSensor", "instanceId": "ts001" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" } Rule Trigger
  • 26. IBM Watson Internet of Things Resources – Rule Triggers •A Rule Trigger invokes an Action when an embedded rule fires •The configuration property must define the following properties: – logicalInterfaceId – ruleId v A wildcard (*) can be specified for the ruleId property v Specifies that the action will be invoked if any of the rule on the logical interface fire – type v One of device, thing or * – typeId v The id of the device or thing type or * – instanceId v The id of the device or thing or * Trigger { "id": "5848040f6522050001db0e20", "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "rule", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { "logicalInterfaceId": "123456789012345678901234", "ruleId": "098765432109876543210987", "type": "device", "typeId": "TempSensor", "instanceId": "ts001" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" } Rule Trigger
  • 27. IBM Watson Internet of Things Resources – State Triggers (future) •A State Trigger invokes an Action when the state of a Device/Thing changes Trigger { "id": "5848040f6522050001db0e20", "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "state", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { "logicalInterfaceId": "123456789012345678901234", "type": "device", "typeId": "TempSensor", "instanceId": "ts001" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" } State Trigger
  • 28. IBM Watson Internet of Things Resources – State Triggers (future) •A State Trigger invokes an Action when the state of a Device/Thing changes •The configuration property must define the following properties: – logicalInterfaceId – type v One of device, thing or * – typeId v The id of the device or thing type or * – instanceId v The id of the device or thing or * Trigger { "id": "5848040f6522050001db0e20", "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "state", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { "logicalInterfaceId": "123456789012345678901234", "type": "device", "typeId": "TempSensor", "instanceId": "ts001" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" } State Trigger
  • 29. IBM Watson Internet of Things Resources – Trigger Variable Mappings •The variable mappings defined by a Trigger specify how to map data from the platform event to the variables required by the action Trigger { "id": "5848040f6522050001db0e20", "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "rule", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { … }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" }
  • 30. IBM Watson Internet of Things Resources – Trigger Variable Mappings •The variable mappings defined by a Trigger specify how to map data from the platform event to the variables required by the action •The keys are the names of the variables defined in the action configuration Trigger { "id": "5848040f6522050001db0e20", "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "rule", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { … }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" }
  • 31. IBM Watson Internet of Things Resources – Trigger Variable Mappings •The variable mappings defined by a Trigger specify how to map data from the platform event to the variables required by the action •The keys are the names of the variables defined in the action configuration •The values are JSONata expressions Trigger { "id": "5848040f6522050001db0e20", "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "rule", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { … }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" }
  • 32. IBM Watson Internet of Things Agenda •Overview •Resources – Actions – Triggers •Actions API Overview •Triggers API Overview •Processing Walkthrough
  • 33. IBM Watson Internet of Things Actions API Overview •CRUD operations can be performed against the actions resource using the APIs shown below •NOTE: The actions resource does not follow the draft/active model used by other IM resources. You do not need to activate changes in order for them to be effective. POST /actions PUT /actions/{actionId} DELETE /actions/{actionId} GET /actions GET /actions/{actionId} PATCH /actions/{actionId}
  • 34. IBM Watson Internet of Things Creating an Action Resource • In order to create an action you need to perform a HTTP POST against the /actions resource, as shown below: • NOTE: For security reasons, the username and password properties are obfuscated in the responses to the REST API calls Action POST /actions { "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ {"name": "mycustomheader", "value": "{{somevalue}}"} ], "body": "{"id" : {{theId}}, "data": "{{theData}}"}" } }
  • 35. IBM Watson Internet of Things Agenda •Overview •Resources – Actions – Triggers •Actions API Overview •Triggers API Overview •Processing Walkthrough
  • 36. IBM Watson Internet of Things Triggers API Overview •CRUD operations can be performed against the triggers resource using the APIs shown below •NOTE: The triggers resource does not follow the draft/active model used by other IM resources. You do not need to activate changes in order for them to be effective. POST /triggers PUT /triggers/{triggerId} DELETE /triggers/{triggerId} GET /triggers GET /triggers/{triggerId}
  • 37. IBM Watson Internet of Things Creating a Trigger Resource • Once an action has been created in the Platform, the next step is to create a trigger resource – Triggers are a sub-resource of an action in the REST resource hierarchy • In order to create a trigger you need to perform a HTTP POST against the /actions/{actionId}/triggers resource, as shown below: Action POST /actions/{actionId}/triggers { "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "rule", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { "logicalInterfaceId": "123456789012345678901234", "ruleId": "098765432109876543210987", "type": "device", "typeId": "TempSensor", "instanceId": "ts001" } } Trigger
  • 38. IBM Watson Internet of Things Agenda •Overview •Resources – Actions – Triggers •Actions API Overview •Triggers API Overview •Processing Walkthrough
  • 39. IBM Watson Internet of Things Action-Mgr Service Processing Walkthrough { "id": "5848040f6522050001db0e20", "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "rule", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { "logicalInterfaceId": "123456789012345678901234", "ruleId": "098765432109876543210987", "type": "device", "typeId": "TempSensor", "instanceId": "ts001" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" } { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ { "name": "mycustomheader", "value": "{{somevalue}}" } ], "body": "{"id" : {{theId}}, "data": "{{theData}}"}" }, … } Rule Trigger Webhook Action •A rule trigger and webhook action have been created within the platform
  • 40. IBM Watson Internet of Things Action-Mgr Service Processing Walkthrough { "id": "5848040f6522050001db0e20", "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "rule", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { "logicalInterfaceId": "123456789012345678901234", "ruleId": "098765432109876543210987", "type": "device", "typeId": "TempSensor", "instanceId": "ts001" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" } { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ { "name": "mycustomheader", "value": "{{somevalue}}" } ], "body": "{"id" : {{theId}}, "data": "{{theData}}"}" }, … } { "type": "device", "typeId" : "TempSensor", "instanceId" : "ts001", "logicalInterfaceId": "123456789012345678901234", "ruleId": "098765432109876543210987", "ruleCondition": "$state.temperature > 40", "state": { "equipmentId": "12345", "temperatureReading": 45 }, "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" } Rule Event Rule Trigger Webhook Action •A rule trigger and webhook action have been created within the platform •When a rule fires…
  • 41. IBM Watson Internet of Things Action-Mgr Service Processing Walkthrough { "id": "5848040f6522050001db0e20", "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "rule", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { "logicalInterfaceId": "123456789012345678901234", "ruleId": "098765432109876543210987", "type": "device", "typeId": "TempSensor", "instanceId": "ts001" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" } { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ { "name": "mycustomheader", "value": "{{somevalue}}" } ], "body": "{"id" : {{theId}}, "data": "{{theData}}"}" }, … } { "type": "device", "typeId" : "TempSensor", "instanceId" : "ts001", "logicalInterfaceId": "123456789012345678901234", "ruleId": "098765432109876543210987", "ruleCondition": "$state.temperature > 40", "state": { "equipmentId": "12345", "temperatureReading": 45 }, "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" } Rule Event Rule Trigger Webhook Action •A rule trigger and webhook action have been created within the platform •When a rule fires… •… the Action Manager checks to see if there is a matching rule trigger
  • 42. IBM Watson Internet of Things Action-Mgr Service Processing Walkthrough { "id": "5848040f6522050001db0e20", "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "rule", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { "logicalInterfaceId": "123456789012345678901234", "ruleId": "098765432109876543210987", "type": "device", "typeId": "TempSensor", "instanceId": "ts001" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" } { "type": "device", "typeId" : "TempSensor", "instanceId" : "ts001", "logicalInterfaceId": "123456789012345678901234", "ruleId": "098765432109876543210987", "ruleCondition": "$state.temperature > 40", "state": { "equipmentId": "12345", "temperatureReading": 45 }, "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" } Rule Event Rule Trigger { "someValue": "myHeaderValue" } Variable Dictionary •Having found a matching trigger, the Action Manager evaluates the variable mappings to create the variable dictionary •The first variable mapping (someValue) simply contains a constant value, so this is added to the dictionary
  • 43. IBM Watson Internet of Things Action-Mgr Service Processing Walkthrough { "id": "5848040f6522050001db0e20", "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "rule", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { "logicalInterfaceId": "123456789012345678901234", "ruleId": "098765432109876543210987", "type": "device", "typeId": "TempSensor", "instanceId": "ts001" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" } { "type": "device", "typeId" : "TempSensor", "instanceId" : "ts001", "logicalInterfaceId": "123456789012345678901234", "ruleId": "098765432109876543210987", "ruleCondition": "$state.temperature > 40", "state": { "equipmentId": "12345", "temperatureReading": 45 }, "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" } Rule Event Rule Trigger { "someValue": "myHeaderValue", "theId": "12345" } Variable Dictionary •The second variable mapping (theId) is assigned the value of the state.equipmentId property from the rule notification event
  • 44. IBM Watson Internet of Things Action-Mgr Service Processing Walkthrough { "id": "5848040f6522050001db0e20", "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "rule", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { "logicalInterfaceId": "123456789012345678901234", "ruleId": "098765432109876543210987", "type": "device", "typeId": "TempSensor", "instanceId": "ts001" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" } { "type": "device", "typeId" : "TempSensor", "instanceId" : "ts001", "logicalInterfaceId": "123456789012345678901234", "ruleId": "098765432109876543210987", "ruleCondition": "$state.temperature > 40", "state": { "equipmentId": "12345", "temperatureReading": 45 }, "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" } Rule Event Rule Trigger { "someValue": "myHeaderValue", "theId": "12345", "theData": "45" } Variable Dictionary •The third variable mapping (theData) is assigned the value of the state.temperatureReading property from the rule notification event
  • 45. IBM Watson Internet of Things Action-Mgr Service Processing Walkthrough { "someValue": "myHeaderValue", "theId": "12345", "theData": "45" } { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ { "name": "mycustomheader", "value": "{{somevalue}}" } ], "body": "{"id" : {{theId}}, "data": "{{theData}}"}" }, … } Webhook Action { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ { "name": "mycustomheader", "value": "myHeaderValue" } ], "body": "{"id" : {{theId}}, "data": "{{theData}}"}" }, … } Variable Dictionary Resolved Action •Having created the variable dictionary, the Action Manager substitutes the variables in the action with the corresponding values from the dictionary •The variable someValue is replaced with the value myHeaderValue
  • 46. IBM Watson Internet of Things Action-Mgr Service Processing Walkthrough { "someValue": "myHeaderValue", "theId": "12345", "theData": "45" } { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ { "name": "mycustomheader", "value": "{{somevalue}}" } ], "body": "{"id" : {{theId}}, "data": "{{theData}}"}" }, … } Webhook Action { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ { "name": "mycustomheader", "value": "myHeaderValue" } ], "body": "{"id" : 12345, "data": "{{theData}}"}" }, … } Variable Dictionary Resolved Action •The variable theId is replaced with the value 12345
  • 47. IBM Watson Internet of Things Action-Mgr Service Processing Walkthrough { "someValue": "myHeaderValue", "theId": "12345", "theData": "45" } { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ { "name": "mycustomheader", "value": "{{somevalue}}" } ], "body": "{"id" : {{theId}}, "data": "{{theData}}"}" }, … } Webhook Action { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ { "name": "mycustomheader", "value": "myHeaderValue" } ], "body": "{"id" : 12345, "data": "45"}" }, … } Variable Dictionary Resolved Action •The variable theData is replaced with the value 45
  • 48. IBM Watson Internet of Things Action-Mgr Service Processing Walkthrough { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ { "name": "mycustomheader", "value": "myHeaderValue" } ], "body": "{"id" : 12345, "data": "45"}" }, … } Resolved Action Watson IoT Platform Action Manager Device Gateway & Edge Cognitive Engine Application UI Device Device Webhook •Once all of the variables in the action have been processed, the resolved action is used to invoke the target webhook
  • 49. IBM Watson Internet of Things Backup
  • 50. IBM Watson Internet of Things Resources – Actions • Retrieve the list of actions that have been defined for an organization in the Watson IoT Platform • The following query parameters are supported: – _bookmark, _limit, _sort, name, type and enabled { "results": [ { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ {"name": "mycustomheader", "value": "{{somevalue}}"} ], "body": "{"id" : {{theId}}, "data": "{{theData}}"}" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com", "refs": { "triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers" } } ], "meta": { "facets":{}, "total_rows": 1 } } GET /actions
  • 51. IBM Watson Internet of Things Resources – Actions POST /actions • Creates a new action for an organization in the Watson IoT Platform • Example POST: { "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ {"name": "mycustomheader", "value": "{{somevalue}}"} ], "body": "{"id" : {{theId}}, "data": "{{theData}}"}" } }
  • 52. IBM Watson Internet of Things Resources – Actions POST /actions • Example response body: { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ {"name": "mycustomheader", "value": "{{somevalue}}"} ], "body": "{"id" : {{theId}}, "data": "{{theData}}"}" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com", "refs": { "triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers" } }
  • 53. IBM Watson Internet of Things Resources – Actions • Retrieve the metadata for a specific action • Example response body: GET /actions/{actionId} { "id": "5848040f6522050001db0e20", "name" : "My Webhook Action", "description" : "An example webhook action", "type": "webhook", "enabled": true, "configuration": { "targetUrl": "http://webhook-sim/abcdef/senddata", "method": "POST", "contentType": "application/json", "username": "john.doe@us.ibm.com", "password": "passw0rd", "headers": [ {"name": "mycustomheader", "value": "{{somevalue}}"} ], "body": "{"id" : {{theId}}, "data": "{{theData}}"}" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com", "refs": { "triggers": " /api/v0002/actions/5848040f6522050001db0e20/triggers" } }
  • 54. IBM Watson Internet of Things Resources – Actions • Perform an operation against the specified action • Current supported operations are: – invoke-action • Example PATCH: PATCH /actions/{actionId} { "operation": "invoke-action" "variables": { "someValue": "myHeaderValue", "theId": "12345", "theData": "45" } }
  • 55. IBM Watson Internet of Things Resources – Actions • Example response body: PATCH /actions/{actionId} { "message": "CUDAM0900I: The action 'Invoke Webhook Sim Action' was successfully invoked.", "details": { "id": "CUDAM0900I", "properties": ["Invoke Webhook Sim Action"] }, "result": { "actionId": "5c52ec190ec83c004d8e02f1", "successful": true, "type": "webhook", "status": 200, "headers": { "connection": "keep-alive", "content-type": "text/html; charset=utf-8", "Content-Length": "20", "Date": "Thu, 31 Jan 2019 12:37:46 GMT", "X-Powered-By": "Express" }, "contentType": "text/html; charset=utf-8", "body": "{ "success" : true }" } }
  • 56. IBM Watson Internet of Things Resources – Actions • Update the metadata for an action • The following metadata properties can be updated – name – description – configuration – enabled PUT /actions/{actionId} • Delete an action DELETE /actions/{actionId}
  • 57. IBM Watson Internet of Things Resources – Triggers • Retrieve the list of triggers that have been defined for an action • The following query parameters are supported: – _bookmark, _limit, _sort, name, type and enabled { "results": [ { "id": "5848040f6522050001db0e20", "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "rule", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { "logicalInterfaceId": "123456789012345678901234", "ruleId": "098765432109876543210987", "type": "device", "typeId": "TempSensor", "instanceId": "ts001" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" } ], "meta": { "facets": {}, "total_rows": 1 } } GET /actions/{actionId}/triggers
  • 58. IBM Watson Internet of Things Resources – Triggers POST /actions/{actionId}/triggers • Creates a new trigger for an action • Example POST: { "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "rule", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { "logicalInterfaceId": "123456789012345678901234", "ruleId": "098765432109876543210987", "type": "device", "typeId": "TempSensor", "instanceId": "ts001" } }
  • 59. IBM Watson Internet of Things Resources – Triggers POST /actions/{actionId}/triggers • Example response body: { "id": "5848040f6522050001db0e20", "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "rule", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { "logicalInterfaceId": "123456789012345678901234", "ruleId": "098765432109876543210987", "type": "device", "typeId": "TempSensor", "instanceId": "ts001" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" }
  • 60. IBM Watson Internet of Things Resources – Triggers • Retrieve the metadata for a specific trigger • Example response body: GET /actions/{actionId}/triggers/{triggerId} { "id": "5848040f6522050001db0e20", "name" : "My Rule Trigger", "description" : "An example rule trigger", "type": "rule", "enabled": true, "variableMappings": { "someValue": "myHeaderValue", "theId": "$event.state.equipmentId", "theData": "$event.state.temperatureReading" }, "configuration": { "logicalInterfaceId": "123456789012345678901234", "ruleId": "098765432109876543210987", "type": "device", "typeId": "TempSensor", "instanceId": "ts001" }, "adminDisabled": false, "adminDisabledReason": null, "created": "2018-01-30T13:00:00Z", "createdBy": "john.doe@us.ibm.com", "updated": "2018-01-30T14:00:00Z", "updatedBy": "fred.bloggs@uk.ibm.com" }
  • 61. IBM Watson Internet of Things Resources – Triggers • Update the metadata for a trigger • The following metadata properties can be updated – name – description – configuration – variableMappings – enabled PUT /actions/{actionId}/triggers/{triggerId} • Delete a trigger DELETE /actions/{actionId}/triggers/{triggerId}