ChatWoot icon

ChatWoot

Interact with ChatWoot API

Actions100

Overview

This node updates an existing Automation Rule within a specified ChatWoot account. It is useful for automating workflows in ChatWoot, such as modifying how conversations are handled based on specific events or message content. For example, you can update a rule to automatically add labels to conversations when certain keywords are detected in incoming messages.

Practical scenarios:

  • Adjusting automation rules as business requirements change (e.g., updating which labels are applied or which conditions trigger actions).
  • Enabling/disabling automation rules without manual intervention in the ChatWoot UI.
  • Modifying event triggers or action lists for existing automation rules programmatically.

Properties

Display Name Type Description
Account Id Number The numeric ID of the ChatWoot account where the automation rule exists.
Id Number The ID of the automation rule to be updated.
Name String Rule name. Specifies the new name for the automation rule.
Description String The description about the automation and actions.
Event Name Options The event that triggers the automation actions. Possible values: Conversation Created, Conversation Updated, Message Created.
Active Boolean Enable/disable the automation rule.
Actions JSON Array of actions to perform when the condition matches (e.g., add label support if message contains "help").
Conditions JSON Array of conditions that filter conversations (e.g., message content contains "help").

Output

The output will contain the updated automation rule's details in the json field. This typically includes:

  • The rule's ID
  • Name
  • Description
  • Event name
  • Active status
  • Actions array
  • Conditions array

Example output:

{
  "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",
  "active": true,
  "actions": [
    {
      "action_name": "add_label",
      "action_params": ["support"]
    }
  ],
  "conditions": [
    {
      "attribute_key": "content",
      "filter_operator": "contains",
      "query_operator": "nil",
      "values": ["help"]
    }
  ]
}

Note: The actual structure may include additional fields returned by the ChatWoot API.

Dependencies

  • External Service: Requires access to a ChatWoot instance with API enabled.
  • API Key: Needs valid ChatWoot API credentials (chatwootApi) configured in n8n.
  • n8n Configuration: The base URL for ChatWoot must be set in the credentials.

Troubleshooting

Common issues:

  • Invalid Account Id or Rule Id: If the provided IDs do not exist, the node will likely return a "Not Found" error from the ChatWoot API.
  • Authentication errors: If the API key is missing or incorrect, you may see authentication or authorization errors.
  • Malformed JSON in Actions/Conditions: If the JSON structure for actions or conditions is invalid, the API may reject the request with a parsing error.
  • Missing required properties: Omitting required fields like Account Id or Id will result in validation errors.

Error messages and resolutions:

  • "404 Not Found": Check that both Account Id and Rule Id are correct and exist in your ChatWoot instance.
  • "401 Unauthorized": Verify that your ChatWoot API credentials are correctly set up in n8n.
  • "400 Bad Request": Ensure that all required fields are filled and that JSON fields (Actions, Conditions) are properly formatted.

Links and References

Discussion