You can now customize the webhook body within CloudChat Automations. Simply craft the JSON in the format expected by the destination system, without needing an intermediary tool just to convert data.
If you leave the body blank, CloudChat will continue sending the default format.
How to set up
-
Go to Settings > Automations and create or edit a rule.
-
Choose the event (for example, conversation created or conversation updated) and set the conditions.
-
Under Actions, select Send webhook and enter the destination URL.
-
In the Request Body (JSON) field, write the JSON using the variables below.
-
Save.
Variables
For custom attributes, replace KEY with the attribute key as registered in CloudChat.
Contact
- `{{ contact.id }}`: Contact ID
- `{{ contact.name }}`: Full name
- `{{ contact.first_name }}`: First name
- `{{ contact.last_name }}`: Last name
- `{{ contact.email }}`: Email
- `{{ contact.phone_number }}`: Phone number
- `{{ contact.custom_attribute.KEY }}`: Contact's custom attribute
Conversation Agent
- `{{ agent.id }}`: Agent ID
- `{{ agent.name }}`: Name
- `{{ agent.email }}`: Email
Conversation
- `{{ conversation.display_id }}`: Conversation number displayed on the screen
- `{{ conversation.id }}`: Internal conversation ID
- `{{ conversation.channel }}`: Channel (e.g., `Channel::Whatsapp`)
- `{{ conversation.contact_name }}`: Contact's name
- `{{ conversation.custom_attribute.KEY }}`: Conversation's custom attribute
- `{{ conversation.assignee.name }}`: Name of the agent the customer sees
- `{{ conversation.assignee.first_name }}`: Agent's first name
- `{{ conversation.recent_messages }}`: Latest messages in the conversation
Inbox and Account
- `{{ inbox.id }}`: Inbox ID
- `{{ inbox.name }}`: Inbox name
- `{{ account.id }}`: Account ID
- `{{ account.name }}`: Account name
Specifications
Always use | json after the variable. It automatically adds quotes and handles accents, quotes, and line breaks. If the field is empty, it sends null.
-
Correct:
"name": {{ contact.name | json }} -
Incorrect:
"name": "{{ contact.name }}" -
Incorrect:
"name": {{ contact.name }}
Example:
{
"email": {{ agent.email | json }},
"ticket": {{ conversation.display_id | json }},
"client": {{ contact.name | json }},
"channel": {{ inbox.name | json }}
}