Skip to main content

REFERENCE

Developer Reference

Authentication, APIs, SDKs, Flow Agent processors and parameter resolution, in full.

Action Object — EMIT

An EMIT action sends a custom event into the workflow.

  1. 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.

  2. 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.

  3. Examples​

    To send a button with an EMIT action from Push Message:

    1. Choose Expression in the Template field's dropdown.
    2. 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',
    },
    },
    },
    ],
    };
    })()

Ready to get started?

Want to see how Asgard fits your team? Talk to us.

Contact us