Automations API
The Automations API manages workflow automation rules that trigger actions based on events, schedules, or webhooks.
Automation Object
{
id: string; // UUID
organization_id: string; // UUID of the organization
name: string; // Automation name
description?: string; // Description of what this automation does
trigger_type: string; // event, time, webhook
trigger_config: object; // Configuration for the trigger
conditions: object[]; // Array of conditions that must be met
actions: object[]; // Array of actions to execute
enabled: boolean; // Whether the automation is active
created_at: string; // ISO timestamp
updated_at: string; // ISO timestamp
}
Trigger Types
| Type | Description |
|---|---|
event | Triggered by system events (ticket created, status changed, etc.) |
time | Triggered on a schedule or after a time delay |
webhook | Triggered by incoming webhook calls |
List Automations
Retrieve all automations for the organization.
Procedure: automations.list
Authentication: Required
Input: None
Example:
curl -X GET "https://your-domain.com/api/trpc/automations.list" \
-H "Cookie: your-session-cookie"
Response:
{
"result": {
"data": {
"json": [
{
"id": "uuid",
"name": "Auto-assign billing tickets",
"description": "Assign tickets with 'billing' tag to the billing team",
"trigger_type": "event",
"trigger_config": {
"event": "ticket.created"
},
"conditions": [
{
"field": "tags",
"operator": "contains",
"value": "billing"
}
],
"actions": [
{
"type": "assign",
"config": {
"assigneeId": "user-uuid"
}
}
],
"enabled": true,
"created_at": "2024-01-01T00:00:00.000Z"
}
]
}
}
}
Get Automation
Retrieve a single automation by ID.
Procedure: automations.get
Authentication: Required
Input:
{
id: string; // Automation UUID
}
Example:
curl -X GET "https://your-domain.com/api/trpc/automations.get?input=%7B%22id%22:%22automation-uuid%22%7D" \
-H "Cookie: your-session-cookie"
Response:
{
"result": {
"data": {
"json": {
"id": "uuid",
"name": "Auto-assign billing tickets",
"description": "Assign tickets with 'billing' tag to the billing team",
"trigger_type": "event",
"trigger_config": {...},
"conditions": [...],
"actions": [...],
"enabled": true,
"created_at": "2024-01-01T00:00:00.000Z"
}
}
}
}
Create Automation
Create a new automation rule.
Procedure: automations.create
Authentication: Required
Input:
{
name: string; // 1-200 characters
description?: string; // Optional description
triggerType: 'event' | 'time' | 'webhook';
triggerConfig: object; // Trigger-specific configuration
conditions?: object[]; // Array of conditions (default: [])
actions: object[]; // Array of actions to execute
enabled?: boolean; // default: true
}
Example - Event-based Automation:
curl -X POST "https://your-domain.com/api/trpc/automations.create" \
-H "Content-Type: application/json" \
-H "Cookie: your-session-cookie" \
-d '{
"json": {
"name": "Escalate urgent tickets",
"description": "Notify team lead when urgent ticket is created",
"triggerType": "event",
"triggerConfig": {
"event": "ticket.created"
},
"conditions": [
{
"field": "priority",
"operator": "equals",
"value": "urgent"
}
],
"actions": [
{
"type": "notify",
"config": {
"channel": "email",
"recipients": ["lead@company.com"],
"template": "urgent_ticket"
}
},
{
"type": "add_tag",
"config": {
"tag": "escalated"
}
}
],
"enabled": true
}
}'
Example - Time-based Automation:
curl -X POST "https://your-domain.com/api/trpc/automations.create" \
-H "Content-Type: application/json" \
-H "Cookie: your-session-cookie" \
-d '{
"json": {
"name": "Auto-close resolved tickets",
"description": "Close tickets that have been resolved for 7 days",
"triggerType": "time",
"triggerConfig": {
"schedule": "0 0 * * *",
"timezone": "UTC"
},
"conditions": [
{
"field": "status",
"operator": "equals",
"value": "resolved"
},
{
"field": "updated_at",
"operator": "older_than",
"value": "7d"
}
],
"actions": [
{
"type": "update_status",
"config": {
"status": "closed"
}
}
],
"enabled": true
}
}'
Response:
{
"result": {
"data": {
"json": {
"id": "uuid",
"name": "Escalate urgent tickets",
"trigger_type": "event",
"enabled": true,
"created_at": "2024-01-15T10:30:00.000Z"
}
}
}
}
Update Automation
Update an existing automation.
Procedure: automations.update
Authentication: Required
Input:
{
id: string; // Required, automation UUID
name?: string; // 1-200 characters
description?: string;
triggerType?: 'event' | 'time' | 'webhook';
triggerConfig?: object;
conditions?: object[];
actions?: object[];
enabled?: boolean;
}
Example:
curl -X POST "https://your-domain.com/api/trpc/automations.update" \
-H "Content-Type: application/json" \
-H "Cookie: your-session-cookie" \
-d '{
"json": {
"id": "automation-uuid",
"conditions": [
{
"field": "priority",
"operator": "in",
"value": ["urgent", "high"]
}
]
}
}'
Response:
{
"result": {
"data": {
"json": {
"id": "uuid",
"name": "Escalate urgent tickets",
"conditions": [...],
"updated_at": "2024-01-15T11:00:00.000Z"
}
}
}
}
Delete Automation
Permanently delete an automation.
Procedure: automations.delete
Authentication: Required
Input:
{
id: string; // Automation UUID
}
Example:
curl -X POST "https://your-domain.com/api/trpc/automations.delete" \
-H "Content-Type: application/json" \
-H "Cookie: your-session-cookie" \
-d '{"json":{"id":"automation-uuid"}}'
Response:
{
"result": {
"data": {
"json": {
"success": true
}
}
}
}
Notes:
- This is a hard delete, not a soft delete
- Cannot be undone
Toggle Automation
Enable or disable an automation without deleting it.
Procedure: automations.toggle
Authentication: Required
Input:
{
id: string; // Automation UUID
enabled: boolean; // New enabled state
}
Example:
curl -X POST "https://your-domain.com/api/trpc/automations.toggle" \
-H "Content-Type: application/json" \
-H "Cookie: your-session-cookie" \
-d '{"json":{"id":"automation-uuid","enabled":false}}'
Response:
{
"result": {
"data": {
"json": {
"id": "uuid",
"enabled": false,
"updated_at": "2024-01-15T11:00:00.000Z"
}
}
}
}
Trigger Configuration
Event Triggers
{
event: string; // Event name to listen for
}
Available Events:
| Event | Description |
|---|---|
ticket.created | New ticket is created |
ticket.updated | Ticket is updated |
ticket.status_changed | Ticket status changes |
ticket.assigned | Ticket is assigned |
ticket.priority_changed | Ticket priority changes |
conversation.created | New conversation/reply added |
customer.created | New customer is created |
Time Triggers
{
schedule: string; // Cron expression
timezone: string; // IANA timezone (e.g., "America/New_York")
}
Cron Format: minute hour day-of-month month day-of-week
Examples:
0 9 * * 1-5- 9 AM on weekdays0 0 * * *- Midnight daily*/15 * * * *- Every 15 minutes
Webhook Triggers
{
path: string; // Webhook endpoint path
method: string; // HTTP method (POST, GET)
secret?: string; // Optional secret for validation
}
Conditions
Conditions determine when an automation should run. All conditions must be met (AND logic).
{
field: string; // Field to check
operator: string; // Comparison operator
value: any; // Value to compare against
}
Operators
| Operator | Description | Example |
|---|---|---|
equals | Exact match | {"field": "status", "operator": "equals", "value": "open"} |
not_equals | Not equal | {"field": "priority", "operator": "not_equals", "value": "low"} |
contains | Array contains | {"field": "tags", "operator": "contains", "value": "billing"} |
not_contains | Array doesn't contain | {"field": "tags", "operator": "not_contains", "value": "spam"} |
in | Value in list | {"field": "status", "operator": "in", "value": ["open", "pending"]} |
not_in | Value not in list | {"field": "status", "operator": "not_in", "value": ["closed"]} |
greater_than | Numeric comparison | {"field": "ticket_count", "operator": "greater_than", "value": 10} |
less_than | Numeric comparison | {"field": "ticket_count", "operator": "less_than", "value": 5} |
older_than | Time comparison | {"field": "created_at", "operator": "older_than", "value": "24h"} |
newer_than | Time comparison | {"field": "updated_at", "operator": "newer_than", "value": "1h"} |
is_empty | Field is null/empty | {"field": "assignee_id", "operator": "is_empty", "value": true} |
is_not_empty | Field has value | {"field": "assignee_id", "operator": "is_not_empty", "value": true} |
Actions
Actions are executed when the trigger fires and conditions are met.
{
type: string; // Action type
config: object; // Action-specific configuration
}
Available Actions
update_status - Change ticket status
{
"type": "update_status",
"config": {
"status": "pending"
}
}
update_priority - Change ticket priority
{
"type": "update_priority",
"config": {
"priority": "high"
}
}
assign - Assign ticket to user
{
"type": "assign",
"config": {
"assigneeId": "user-uuid"
}
}
add_tag - Add a tag to ticket
{
"type": "add_tag",
"config": {
"tag": "escalated"
}
}
remove_tag - Remove a tag from ticket
{
"type": "remove_tag",
"config": {
"tag": "new"
}
}
notify - Send notification
{
"type": "notify",
"config": {
"channel": "email",
"recipients": ["user@example.com"],
"template": "escalation"
}
}
send_reply - Auto-reply to ticket
{
"type": "send_reply",
"config": {
"content": "Thank you for contacting us...",
"internal": false
}
}
webhook - Call external webhook
{
"type": "webhook",
"config": {
"url": "https://api.example.com/webhook",
"method": "POST",
"headers": {"Authorization": "Bearer token"}
}
}
Example Automations
Auto-categorize by keyword
{
"name": "Tag billing tickets",
"triggerType": "event",
"triggerConfig": {"event": "ticket.created"},
"conditions": [
{"field": "subject", "operator": "contains", "value": "invoice"}
],
"actions": [
{"type": "add_tag", "config": {"tag": "billing"}}
]
}
SLA reminder
{
"name": "SLA breach warning",
"triggerType": "time",
"triggerConfig": {"schedule": "*/30 * * * *", "timezone": "UTC"},
"conditions": [
{"field": "status", "operator": "in", "value": ["open", "pending"]},
{"field": "priority", "operator": "equals", "value": "urgent"},
{"field": "created_at", "operator": "older_than", "value": "2h"}
],
"actions": [
{"type": "notify", "config": {"channel": "slack", "template": "sla_warning"}}
]
}
Auto-assign based on expertise
{
"name": "Route technical tickets",
"triggerType": "event",
"triggerConfig": {"event": "ticket.created"},
"conditions": [
{"field": "tags", "operator": "contains", "value": "technical"},
{"field": "assignee_id", "operator": "is_empty", "value": true}
],
"actions": [
{"type": "assign", "config": {"assigneeId": "tech-team-lead-uuid"}}
]
}