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
Purpose: Deliver the final output of a workflow accompanied by a message.
Functionality: Accept multiple message options and randomly select one to send when more than one is provided. Supports embedding variables within messages for dynamic content generation.
Configurations
Messages
Description: The core configuration is the "Messages" collection, where one or more message templates can be added.
Usage:
Add messages by clicking + Add message.
Use
(x)or type/within messages to quickly insert variables dynamically.When multiple messages are present, the component picks one at random to send.
Implementation Details
The component acts as a terminal node in the workflow data pipeline.
Message selection algorithm:
If only one message exists, that message is always sent.
If multiple messages exist, one message is selected randomly (uniform distribution).
Variable substitution is supported within messages, allowing dynamic content injection based on the workflow's context or data.
The component does not modify the workflow data but appends or associates the selected message with the output.
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
Workflow Engine: The Message component receives the final processed data from previous workflow steps.
Variable Resolver: It relies on a variable resolution mechanism to substitute placeholders in messages with actual runtime data.
Output Handler: The output (data + selected message) is sent downstream to whatever system or interface consumes the final workflow output (e.g., UI, API response, messaging service).
Message Configuration UI: The component integrates with a user interface that allows users to input and manage message templates, including variable insertion shortcuts.
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:
MessageComponentholds the list of messages and exposes methods to select a random message and send the final output.It receives processed
WorkflowDatacontaining variables and payload.It interacts with
VariableResolverto replace variables in the selected message.Finally, it outputs the combined message and data to the next system component or endpoint.
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.