message.mdx


Overview

The Message component is designed to serve as the final step in a workflow by producing the ultimate output of that workflow. Its primary function is to send out a message that can be either static (fixed text) or dynamic (containing variables). When multiple messages are configured, the component randomly selects one to deliver, enabling variability in responses or outputs.

This component is typically used in systems where workflows culminate in communication or notification—such as chatbots, automated email responders, or messaging platforms—providing a flexible and configurable way to deliver final data along with customized messages.


Detailed Explanation

Purpose and Functionality


Configurations

Messages


Implementation Details


Usage Example

// Pseudo-configuration example

const messages = [
  "Hello, {{userName}}! Your order #{{orderId}} is confirmed.",
  "Hi {{userName}}, thanks for your purchase! Order #{{orderId}} will be shipped soon.",
  "Greetings {{userName}}! Your order #{{orderId}} has been processed."
];

// On workflow completion:
const selectedMessage = selectRandom(messages);
const finalOutput = {
  data: workflowData,
  message: interpolateVariables(selectedMessage, workflowData.variables)
};

send(finalOutput);

Here, selectRandom picks one message at random, and interpolateVariables replaces placeholders like {{userName}} with actual values from the workflow data.


Interaction with Other System Components


Visual Diagram

classDiagram
    class MessageComponent {
        +messages: List<String>
        +selectRandomMessage() String
        +sendMessage(data: Object) Object
    }

    class WorkflowData {
        +variables: Object
        +payload: Object
    }

    class VariableResolver {
        +resolve(message: String, variables: Object) String
    }

    WorkflowData --> MessageComponent : provides data
    MessageComponent --> VariableResolver : requests variable substitution
    MessageComponent --> "Final Output" : sends message + data

Diagram Explanation:


Summary

The message.mdx file documents a Message component that finalizes workflow data by sending out configurable messages. It supports multiple messages with random selection and dynamic variable insertion, making it adaptable for many communication use cases. This component is the terminal step in workflows, bridging processed data and user-facing messages or notifications.