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 '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"
      ]
    }
  ]
}'
{
  "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
    }
  ]
}

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

Response payload that contains automation rule(s) Array of automation rules (for listing endpoint)