Message Actions

Attach and receive custom message actions, such as emoji reactions or read receipts, with ALO's messaging features.

Message actions is a list of custom objects you can attach to a message that has already been published. You can use this collection for whatever you need such as emoji reactions, read receipts, and more.

Send a message action

chat.sendMessageAction({
    channelId: "alpha",
    messageId: "799acb6d-cc1d-4fbd-8aa9-1d61ae2cbb92",
    action: {
        type: "emoji-reaction",
        userId: "1f2428c6-6212-49a7-b9a4-d950d2acfe68",
        emoji: "🥳"
    }
}).then(({ status }) => {
    // status = { error: (true|false), errorData: { statusCode<Integer>, message<String> } }
    if (status.error) {
        console.log(`Send Message Action Failed:
            Reason: ${status.errorData.message}
            (Status Code: ${status.errorData.statusCode})
        `);
        return;
    }
});

sendMessageAction({ channelId: string, messageId: string, action: object })

Receive a message action

You will receive an event every time a message action is sent in a channel that you are subscribed to.

chat.addEventListener((event) => {
    if (event.type === "message.action.new") {
        const { message, action } = event.data
        
        // You can get the entire array of message actions via:
        const { actions } = message;
    }
});

Last updated

Logo

© Copyright 2024 ALO.ai, Inc. • All Rights Reserved