Update automation rule in Account
Update a automation rule in account
curl --request PATCH \
--url https://app.chatwoot.com/api/v1/accounts/{account_id}/automation_rules/{id} \
--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/{id}"
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.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
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/{id}', 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/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
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/{id}"
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("PATCH", 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.patch("https://app.chatwoot.com/api/v1/accounts/{account_id}/automation_rules/{id}")
.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/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.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>"
}
]
}{
"description": "<string>",
"errors": [
{
"field": "<string>",
"message": "<string>",
"code": "<string>"
}
]
}Authorizations
Authenticate with Authorization: Bearer <token> using a user API token from Profile Settings. Available in Chatwoot v4.19.0 and later.
Path Parameters
The ID of the automation rule to be updated.
The numeric ID of the account
Body
Rule name
"Add label on message create event"
The description about the automation and actions
"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
conversation_created, conversation_updated, conversation_resolved, message_created "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
curl --request PATCH \
--url https://app.chatwoot.com/api/v1/accounts/{account_id}/automation_rules/{id} \
--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/{id}"
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.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
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/{id}', 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/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
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/{id}"
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("PATCH", 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.patch("https://app.chatwoot.com/api/v1/accounts/{account_id}/automation_rules/{id}")
.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/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.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>"
}
]
}{
"description": "<string>",
"errors": [
{
"field": "<string>",
"message": "<string>",
"code": "<string>"
}
]
}
