Automation Rule
Add a new automation rule
Add a new automation rule to account
POST
/
api
/
v1
/
accounts
/
{account_id}
/
automation_rules
Add a new automation rule
curl --request POST \
--url https://app.chatwoot.com/api/v1/accounts/{account_id}/automation_rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--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://app.chatwoot.com/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 = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', '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://app.chatwoot.com/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://app.chatwoot.com/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 => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://app.chatwoot.com/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("Authorization", "Bearer <token>")
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://app.chatwoot.com/api/v1/accounts/{account_id}/automation_rules")
.header("Authorization", "Bearer <token>")
.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://app.chatwoot.com/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["Authorization"] = 'Bearer <token>'
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
userBearerAuthuserApiKey
Authenticate with Authorization: Bearer <token> using a user API token from Profile Settings. Available in Chatwoot v4.19.0 and later.
Path Parameters
The numeric ID of the account
Body
application/json
Rule name
Example:
"Add label on message create event"
The description about the automation and actions
Example:
"Add label support and sales on message create event if incoming message content contains text help"
The event when you want to execute the automation actions
Available options:
conversation_created, conversation_updated, conversation_resolved, message_created Example:
"message_created"
Enable/disable automation rule
Array of actions which you want to perform when condition matches, e.g add label support if message contains content help.
Array of conditions on which conversation filter would work, e.g message content contains text help.
Response
Success
- object[]
- object
Show child attributes
Show child attributes
⌘I
Add a new automation rule
curl --request POST \
--url https://app.chatwoot.com/api/v1/accounts/{account_id}/automation_rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--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://app.chatwoot.com/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 = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', '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://app.chatwoot.com/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://app.chatwoot.com/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 => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://app.chatwoot.com/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("Authorization", "Bearer <token>")
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://app.chatwoot.com/api/v1/accounts/{account_id}/automation_rules")
.header("Authorization", "Bearer <token>")
.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://app.chatwoot.com/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["Authorization"] = 'Bearer <token>'
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>"
}
]
}
