Skip to main content
POST
/
api
/
v1
/
accounts
/
{account_id}
/
automation_rules
Add a new automation rule
curl --request POST \
  --url https://airys.chat/api/v1/accounts/{account_id}/automation_rules \
  --header 'Content-Type: application/json' \
  --header 'api_access_token: <api-key>' \
  --data '
{
  "name": "Add label on message create event",
  "description": "Add label support and sales on message create event if incoming message content contains text help",
  "event_name": "message_created",
  "active": true,
  "actions": [
    {
      "action_name": "add_label",
      "action_params": [
        "support"
      ]
    }
  ],
  "conditions": [
    {
      "attribute_key": "content",
      "filter_operator": "contains",
      "query_operator": "OR",
      "values": [
        "help"
      ]
    }
  ]
}
'
import requests

url = "https://airys.chat/api/v1/accounts/{account_id}/automation_rules"

payload = {
"name": "Add label on message create event",
"description": "Add label support and sales on message create event if incoming message content contains text help",
"event_name": "message_created",
"active": True,
"actions": [
{
"action_name": "add_label",
"action_params": ["support"]
}
],
"conditions": [
{
"attribute_key": "content",
"filter_operator": "contains",
"query_operator": "OR",
"values": ["help"]
}
]
}
headers = {
"api_access_token": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {api_access_token: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Add label on message create event',
description: 'Add label support and sales on message create event if incoming message content contains text help',
event_name: 'message_created',
active: true,
actions: [{action_name: 'add_label', action_params: ['support']}],
conditions: [
{
attribute_key: 'content',
filter_operator: 'contains',
query_operator: 'OR',
values: ['help']
}
]
})
};

fetch('https://airys.chat/api/v1/accounts/{account_id}/automation_rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://airys.chat/api/v1/accounts/{account_id}/automation_rules",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Add label on message create event',
'description' => 'Add label support and sales on message create event if incoming message content contains text help',
'event_name' => 'message_created',
'active' => true,
'actions' => [
[
'action_name' => 'add_label',
'action_params' => [
'support'
]
]
],
'conditions' => [
[
'attribute_key' => 'content',
'filter_operator' => 'contains',
'query_operator' => 'OR',
'values' => [
'help'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"api_access_token: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://airys.chat/api/v1/accounts/{account_id}/automation_rules"

payload := strings.NewReader("{\n \"name\": \"Add label on message create event\",\n \"description\": \"Add label support and sales on message create event if incoming message content contains text help\",\n \"event_name\": \"message_created\",\n \"active\": true,\n \"actions\": [\n {\n \"action_name\": \"add_label\",\n \"action_params\": [\n \"support\"\n ]\n }\n ],\n \"conditions\": [\n {\n \"attribute_key\": \"content\",\n \"filter_operator\": \"contains\",\n \"query_operator\": \"OR\",\n \"values\": [\n \"help\"\n ]\n }\n ]\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("api_access_token", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://airys.chat/api/v1/accounts/{account_id}/automation_rules")
.header("api_access_token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Add label on message create event\",\n \"description\": \"Add label support and sales on message create event if incoming message content contains text help\",\n \"event_name\": \"message_created\",\n \"active\": true,\n \"actions\": [\n {\n \"action_name\": \"add_label\",\n \"action_params\": [\n \"support\"\n ]\n }\n ],\n \"conditions\": [\n {\n \"attribute_key\": \"content\",\n \"filter_operator\": \"contains\",\n \"query_operator\": \"OR\",\n \"values\": [\n \"help\"\n ]\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://airys.chat/api/v1/accounts/{account_id}/automation_rules")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["api_access_token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Add label on message create event\",\n \"description\": \"Add label support and sales on message create event if incoming message content contains text help\",\n \"event_name\": \"message_created\",\n \"active\": true,\n \"actions\": [\n {\n \"action_name\": \"add_label\",\n \"action_params\": [\n \"support\"\n ]\n }\n ],\n \"conditions\": [\n {\n \"attribute_key\": \"content\",\n \"filter_operator\": \"contains\",\n \"query_operator\": \"OR\",\n \"values\": [\n \"help\"\n ]\n }\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "payload": [
    {
      "id": 123,
      "account_id": 123,
      "name": "Add label on message create event",
      "description": "Add label support and sales on message create event if incoming message content contains text help",
      "event_name": "message_created",
      "conditions": [
        {
          "attribute_key": "content",
          "filter_operator": "contains",
          "values": [
            "help"
          ],
          "query_operator": "and"
        }
      ],
      "actions": [
        {
          "action_name": "add_label",
          "action_params": [
            "support",
            "sales"
          ]
        }
      ],
      "created_on": 123,
      "active": true
    }
  ]
}
{
"description": "<string>",
"errors": [
{
"field": "<string>",
"message": "<string>",
"code": "<string>"
}
]
}

Authorizations

api_access_token
string
header
required

This token can be obtained by visiting the profile page or via rails console. Provides access to endpoints based on the user permissions levels. This token can be saved by an external system when user is created via API, to perform activities on behalf of the user.

Path Parameters

account_id
integer
required

The numeric ID of the account

Body

application/json
name
string

Rule name

Example:

"Add label on message create event"

description
string

The description about the automation and actions

Example:

"Add label support and sales on message create event if incoming message content contains text help"

event_name
enum<string>

The event when you want to execute the automation actions

Available options:
conversation_created,
conversation_updated,
conversation_resolved,
message_created
Example:

"message_created"

active
boolean

Enable/disable automation rule

actions
object[]

Array of actions which you want to perform when condition matches, e.g add label support if message contains content help.

conditions
object[]

Array of conditions on which conversation filter would work, e.g message content contains text help.

Response

Success

payload
object