Action Object — EMIT
An EMIT action sends a custom event into the workflow.
Basic usage
An EMIT action makes tapping a button raise a custom event, which a Listen Event processor in the workflow can receive and handle. The SDK can read the payload for further processing, which makes this a more flexible internal mechanism than a MESSAGE or URI action.
Structure
JSON
{
"type": "EMIT",
"eventName": "product_inquiry",
"payload": {
"productId": "P001",
"category": "electronics"
}
}
Properties
type (required)
The action's type, always "EMIT".
eventName (required)
The event's name. Underscore-separated names such as product_inquiry are the convention.
payload (optional)
The data the event carries, in any structured form.
Examples
To send a button with an EMIT action from Push Message:
- Choose
Expressionin the Template field's dropdown. - Enter the following JavaScript in the editor.
A support triage menu
(() => {
return {
type: 'BUTTON',
title: 'Support options',
text: 'Which kind of help do you need?',
buttons: [
{
label: 'Technical support',
action: {
type: 'EMIT',
eventName: 'support_request',
payload: {
category: 'technical',
priority: 'normal',
},
},
},
{
label: 'Billing',
action: {
type: 'EMIT',
eventName: 'support_request',
payload: {
category: 'billing',
priority: 'high',
},
},
},
],
};
})()
A product enquiry flow
(() => {
return {
type: 'BUTTON',
title: 'Product services',
text: 'Choose what you need:',
buttons: [
{
label: 'See the details',
action: {
type: 'EMIT',
eventName: 'product_inquiry',
payload: {
productId: 'laptop_001',
inquiryType: 'details',
},
},
},
{
label: 'Book now',
action: {
type: 'EMIT',
eventName: 'booking_flow_start',
payload: {
serviceType: 'restaurant',
restaurantId: 'brown_cafe_001',
priority: 'high',
},
},
},
],
};
})()