Skip to main content

REFERENCE

Developer Reference

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

Action Object — Message

A Message action sends a given text message on the user's behalf.

  1. Basic usage​

    A Message action makes tapping a button send text to the bot, exactly as if the user had typed it. It supports plain text and can carry a payload.

  2. Structure​

    JSON​

    {
    "type": "MESSAGE",
    "text": "I'd like to book a table",
    "payload": {
    "action": "reservation"
    }
    }

    Properties​

    type (required)​

    The action's type, always "MESSAGE".

    text (required)​

    The text sent when the button is tapped.

    payload (optional)​

    Additional data, carrying structured values through to later processors.

  3. Examples​

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

    1. Choose Expression in the Template field's dropdown.
    2. Enter the following JavaScript in the editor.

    A support menu​

    (() => {
    return {
    type: 'BUTTON',
    title: 'Support',
    text: 'Which service do you need?',
    buttons: [
    {
    label: 'Order status',
    action: {
    type: 'MESSAGE',
    text: 'I want to check my order',
    },
    },
    {
    label: 'Book a table',
    action: {
    type: 'MESSAGE',
    text: "I'd like to book a table",
    },
    },
    ],
    };
    })()

    Carrying a payload​

    (() => {
    return {
    type: 'BUTTON',
    title: 'Product questions',
    text: 'Which product would you like to know about?',
    buttons: [
    {
    label: 'Specifications',
    action: {
    type: 'MESSAGE',
    text: 'Please give me the full specifications',
    payload: {
    product_id: 'laptop_001',
    inquiry_type: 'specifications',
    },
    },
    },
    {
    label: 'Pricing',
    action: {
    type: 'MESSAGE',
    text: 'Please give me the pricing',
    payload: {
    product_id: 'laptop_001',
    inquiry_type: 'pricing',
    },
    },
    },
    ],
    };
    })()

Ready to get started?

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

Contact us