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
}
ParameterTypeRequiredDescription
namestringYesDisplay name for the action button
iconstringNoIcon identifier (ticket, user, link, phone, mail, etc.)
action_typestringYesType of action: webhook, url, or javascript
configobjectYesConfiguration object (varies by action type)
is_activebooleanNoWhether the action is enabled (default: true)
display_orderintegerNoSort order for display (default: 0)
{
"url": "https://api.example.com/endpoint",
"method": "POST",
"headers": { "Authorization": "Bearer token" },
"body": "{\"key\": \"{{contact.phone_number}}\"}"
}
FieldTypeRequiredDescription
urlstringYesWebhook endpoint URL
methodstringNoHTTP method (POST, GET, PUT, PATCH). Default: POST
headersobjectNoCustom HTTP headers
bodystringNoJSON request body template
{
"url": "https://crm.example.com/contact?phone={{contact.phone_number}}",
"open_in_new_tab": true
}
FieldTypeRequiredDescription
urlstringYesURL to open
open_in_new_tabbooleanNoOpen in new tab (default: true)
{
"code": "return { clipboard: contact.phone_number }"
}
FieldTypeRequiredDescription
codestringYesJavaScript 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:

VariableDescription
{{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
IconDescription
ticketSupport ticket
userUser/contact
bar-chartAnalytics/chart
linkLink
phonePhone
mailEmail
file-textDocument
external-linkExternal link
zapQuick action
globeWeb/globe
codeCode/script