This API creates an action of the specified action type. Actions are associated with rules which listen for events. When an event occurs that causes a rule to evaluate to true, then the Ayla Rule Engine performs the action(s) associated with the rule. Action names must be unique for a particular user. See also Get action types.
Actions include one or more parameters that supply the action with values (e.g. set the Blue_LED property to 1; post a json object to an endpoint). The action type dictates which parameters are required. The following are examples for some of the action types:
Datapoint
The required parameter is datapoint
, which contains an ARES expression that assigns a value to a to-device property.
Example request data
{ "action": { "name": "datapointExample", "type": "DATAPOINT", "parameters": { "datapoint": "DATAPOINT(TESTDSN_763168_004 , boolean_input_tp) = 1" } } }
URL
The required parameters are body
, a stringified JSON object, and endpoint
, a url. The primary purpose of this action type is to post the body
to the endpoint
, replacing placeholders in body
with values taken from the triggering event. It is the responsibility of the service to retrieve additional data as needed. The Alexa OAuth helper is an example of such a service.
Example request data
{ "action": { "name": "URL endpoint1", "type": "URL", "parameters": { "body": "{'key':'value'}", "endpoint": "https://webhooks/endpoint1" } } }
Example response data
{ "action": { "action_uuid": "a1234567-1234-1234-1234-a1234567890a", "name": "Set Blue_LED true", "user_uuid": "b1234567-1234-1234-1234-a1234567890a", "type": "DATAPOINT", "is_abstract": false, "parameters": { "datapoint": "DATAPOINT(AC000W000000001,Blue_LED) = 1" }, "rule_ids": [], "created_at": "2020-08-05T18:13:21.932Z", "updated_at": "2020-08-05T18:13:21.932Z", "created_by": "b1234567-1234-1234-1234-a1234567890a", "updated_by": "b1234567-1234-1234-1234-a1234567890a", "oem": "1234abcd" } }
Subscription
Subscription action is associated to a subscription rule and vice-versa.
Example request data
{ "action": { "name": "SubscriptionExample", "type": "SUBSCRIPTION" } }
Example response data
{ "action": { "action_uuid": "07aaf9d2-43c4-11ed-9d74-c7306797f69e", "name": "SubscriptionExample", "user_uuid": "6024f1c2-38fb-11eb-bc1f-0a580ae90a86", "type": "SUBSCRIPTION", "is_abstract": false, "parameters": { "ams_message_body": "{{{dpl_event}}}" }, "rule_ids": [], "created_at": "2022-10-04T09:07:53.985Z", "updated_at": "2022-10-04T09:07:53.985Z", "created_by": "6024f1c2-38fb-11eb-bc1f-0a580ae90a86", "updated_by": "6024f1c2-38fb-11eb-bc1f-0a580ae90a86" } }
Diagnostic
Example request data
{ "action": { "name": "actionName-foo", "type": "DIAGNOSTIC", "parameters": { "diagnostc_state_name": "red" }, "permissions": [ { "role": "OEM:Global IOT:Acme Telecom", "type": "UPDATE" }, { "role": "OEM:Global IOT:Acme Retail", "type": "READ" } ] } }
NOTE: If permissions are not set for a diagnostic rule, only the rule creator (OEM) will have CRUD access to the rule and the diagnostic states which the rule creates.
Example response data
{ "action": { "name": "actionName-foo", "action_uuid": "529cb330-296f-11e8-8438-df49af59a923", "user_uuid": "51ec7601-296f-11e8-8438-df49af59a923", "type": "DIAGNOSTIC", "parameters": { "diagnostc_state_name": "red" }, "permissions": [ { "role": "OEM:Global IOT:Acme Telecom", "type": "UPDATE", "created_at": "2018-03-16T23:11:13.895Z", "created_by": "51ec7601-296f-11e8-8438-df49af59a923" }, { "role": "OEM:Global IOT:Acme Retail", "type": "READ", "created_at": "2018-03-16T23:11:13.895Z", "created_by": "51ec7601-296f-11e8-8438-df49af59a923" } ], "created_at": "2018-03-16T23:11:13.895Z", "updated_at": "2018-03-16T23:11:13.895Z", "created_by": "51ec7601-296f-11e8-8438-df49af59a923", "updated_by": "51ec7601-296f-11e8-8438-df49af59a923" } }
AMS_SMS
Below, the destination_ids parameter is mandatory and it is a list of UUID's for the destination objects created in Ayla Message Service.
Example request data
{ “action“:{ "name" : "act-name-ILNVk--Του", "type" : "AMS_SMS", "is_abstract" : false, "parameters" : { "max_actions_per_minute" : "5", "foo" : "bar", "body" : "foo" }, "rule_ids" : ["d3c8e400-b77b-11ea-8ec2-e537e1897a31"], "destination_ids" : [ "d0aab414-b77b-11ea-8ec2-e537e1897a31", "d0aab415-b77b-11ea-8ec2-e537e1897a31", "d0aab416-b77b-11ea-8ec2-e537e1897a31" ] } }
Example response data
{ "action": { "action_uuid": "d82ab780-b77b-11ea-8ec2-e537e1897a31", "name": "act-name-ILNVk--Του", "user_uuid": "d0aab41c-b77b-11ea-8ec2-e537e1897a31", "type": "AMS_SMS", "is_abstract": false, "parameters": { "ams_message_body": "{{{dpl_event}}}", "max_actions_per_minute": "5", "foo": "bar", "body": "foo" }, "rule_ids": [ "d3c8e400-b77b-11ea-8ec2-e537e1897a31" ], "created_at": "2020-06-26T07:08:33.607Z", "updated_at": "2020-06-26T07:08:33.607Z", "created_by": "d0aab41c-b77b-11ea-8ec2-e537e1897a31", "updated_by": "d0aab41c-b77b-11ea-8ec2-e537e1897a31", "destination_ids": [ "d0aab414-b77b-11ea-8ec2-e537e1897a31", "d0aab415-b77b-11ea-8ec2-e537e1897a31", "d0aab416-b77b-11ea-8ec2-e537e1897a31" ] } }
AMS_APNS
Example request data
{ "action": { "name": "Action For APNS", "type": "AMS_APNS", "is_abstract": false, "parameters": { "device_key" : "xxxxx", "provider": "apns", "title": "Apns Title", "body": "apns body", "sound": null, "meta_data": "apns meta", "app_id": "aura_0dfc7900-Pw-kA-id", "active": true }, "rule_ids": [ "7fb7e0b0-8f89-11ea-b9ab-17f4983e21d14" ] } }
AMS_EMAIL
Example request data
{ "action": { "name": "Rule For email Test", "type": "AMS_EMAIL", "is_abstract": false, "parameters": { "provider": "smtp", "email_to": "[email protected]", "email_template_id": "1", "email_body": "email body", "email_subject": "Hello", "user_message": "Hello from Ayla", "active": true, "user_name": "Bob", "min_period_between_actions_in_seconds": "20" }, "rule_ids": [ "46c1d2f0-84eb-11ea-8f9b-23dcde955425" ] } }