Skip to content

Custom Actions

Custom Actions are configurable buttons that appear in the chat interface, enabling quick integrations with external systems. Actions can call webhooks, open URLs, or execute JavaScript code.

Retrieve all custom actions for your organization.

Terminal window
GET /api/custom-actions
{
"status": "success",
"data": {
"custom_actions": [
{
"id": "uuid",
"name": "Create Ticket",
"icon": "ticket",
"action_type": "webhook",
"config": {
"url": "https://api.helpdesk.com/tickets",
"method": "POST",
"headers": { "Authorization": "Bearer token" },
"body": "{\"subject\": \"{{contact.name}}\"}"
},
"is_active": true,
"display_order": 0,
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
]
}
}

Retrieve a single custom action by ID.

Terminal window
GET /api/custom-actions/{id}
{
"status": "success",
"data": {
"id": "uuid",
"name": "Create Ticket",
"icon": "ticket",
"action_type": "webhook",
"config": {
"url": "https://api.helpdesk.com/tickets",
"method": "POST",
"headers": {},
"body": ""
},
"is_active": true,
"display_order": 0,
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
}

Create a new custom action.

Terminal window
POST /api/custom-actions
{
"name": "Create Support Ticket",
"icon": "ticket",
"action_type": "webhook",
"config": {
"url": "https://api.helpdesk.com/tickets",
"method": "POST",
"headers": {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
"body": "{\"subject\": \"WhatsApp: {{contact.name}}\", \"phone\": \"{{contact.phone_number}}\"}"
},
"is_active": true,
"display_order": 0
}
Parameter Type Required Description
name string Yes Display name for the action button
icon string No Icon identifier (ticket, user, link, phone, mail, etc.)
action_type string Yes Type of action: webhook, url, or javascript
config object Yes Configuration object (varies by action type)
is_active boolean No Whether the action is enabled (default: true)
display_order integer No Sort order for display (default: 0)
{
"url": "https://api.example.com/endpoint",
"method": "POST",
"headers": { "Authorization": "Bearer token" },
"body": "{\"key\": \"{{contact.phone_number}}\"}"
}
Field Type Required Description
url string Yes Webhook endpoint URL
method string No HTTP method (POST, GET, PUT, PATCH). Default: POST
headers object No Custom HTTP headers
body string No JSON request body template
{
"url": "https://crm.example.com/contact?phone={{contact.phone_number}}",
"open_in_new_tab": true
}
Field Type Required Description
url string Yes URL to open
open_in_new_tab boolean No Open in new tab (default: true)
{
"code": "return { clipboard: contact.phone_number }"
}
Field Type Required Description
code string Yes JavaScript code to execute
{
"status": "success",
"data": {
"id": "uuid",
"name": "Create Support Ticket",
"icon": "ticket",
"action_type": "webhook",
"config": { ... },
"is_active": true,
"display_order": 0,
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
}

Update an existing custom action.

Terminal window
PUT /api/custom-actions/{id}
{
"name": "Updated Action Name",
"is_active": false
}

All fields are optional. Only provided fields will be updated.

Delete a custom action.

Terminal window
DELETE /api/custom-actions/{id}
{
"status": "success",
"data": {
"status": "deleted"
}
}

Execute a custom action for a specific contact.

Terminal window
POST /api/custom-actions/{id}/execute
{
"contact_id": "uuid"
}

The response varies based on action type:

{
"status": "success",
"data": {
"success": true,
"message": "Webhook executed successfully",
"data": { ... },
"toast": {
"message": "Webhook executed successfully",
"type": "success"
}
}
}
{
"status": "success",
"data": {
"success": true,
"message": "Opening URL",
"redirect_url": "/api/custom-actions/redirect/token123"
}
}
{
"status": "success",
"data": {
"success": true,
"message": "JavaScript action executed",
"data": {
"code": "return { clipboard: contact.phone_number }",
"context": {
"contact": { ... },
"user": { ... },
"organization": { ... }
}
},
"toast": {
"message": "Action completed",
"type": "success"
}
}
}

Variables can be used in webhook URLs, bodies, and URL templates using {{variable}} syntax:

Variable Description
{{contact.id}} Contact’s unique ID
{{contact.phone_number}} Contact’s phone number
{{contact.name}} Contact’s display name
{{contact.profile_name}} Contact’s WhatsApp profile name
{{user.id}} Current user’s ID
{{user.name}} Current user’s full name
{{user.email}} Current user’s email
{{user.role}} Current user’s role
{{organization.id}} Organization’s ID
{{organization.name}} Organization’s name
Icon Description
ticket Support ticket
user User/contact
bar-chart Analytics/chart
link Link
phone Phone
mail Email
file-text Document
external-link External link
zap Quick action
globe Web/globe
code Code/script