V4 - MessageInterceptor¶
A utility workflow that formats and standardizes message output for other workflows, with special handling for interactive messages that include numbered options.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
This workflow serves as a message formatting service that can be called by other workflows to standardize their output. It's particularly useful for chatbots or interactive systems that need to present options to users in a consistent, numbered format.
How It Works¶
- Receives Input: Another workflow triggers this one, passing message data including the output text, output type, and any interactive options
- Formats Message: The workflow checks if the message type is "interactive" and if options are provided
- Adds Numbering: For interactive messages, it automatically numbers the options (1, 2, 3, etc.) and appends them to the original message
- Returns Result: The formatted message is returned to the calling workflow
Workflow Diagram¶
graph TD
A[When Executed by Another Workflow] --> B[formatMessage]
B --> C[setOutput]
Trigger¶
- Execute Workflow Trigger: This workflow is designed to be called by other workflows, not run independently
Nodes Used¶
| Node Type | Node Name | Purpose |
|---|---|---|
| Execute Workflow Trigger | When Executed by Another Workflow | Receives execution requests from other workflows |
| Code | formatMessage | Processes the input message and formats it with numbered options if needed |
| Set | setOutput | Structures the final output for the calling workflow |
External Services & Credentials Required¶
None - this is a pure processing workflow that doesn't connect to external services.
Environment Variables¶
None required.
Data Flow¶
Input Data Expected¶
1 2 3 4 5 | |
Output Data Returned¶
1 2 3 | |
Processing Logic¶
- If
outputTypeis "interactive" andoutputOptionscontains items, the workflow numbers each option and appends them to the original message - If
outputTypeis "plain" or no options are provided, the original message is returned unchanged - Options are numbered starting from 1 and separated by newlines
Error Handling¶
The workflow includes basic error prevention:
- Checks if outputOptions is an array before processing
- Verifies the array has items before attempting to format
- Falls back to the original message if formatting conditions aren't met
No explicit error handling nodes are present, so any JavaScript errors in the formatting code would cause the workflow to fail.
Known Limitations¶
- Currently archived and inactive (status shows
"active": false, "isArchived": true) - No validation of input data structure
- Limited error handling for malformed input
- No logging or debugging output for troubleshooting
Related Workflows¶
This workflow is designed to be called by other workflows but no specific relationships are documented in the provided context.
Setup Instructions¶
- Import Workflow: Import the JSON into your n8n instance
- Activate Workflow: Change the workflow status from archived to active
- Test Integration: Create a test workflow that calls this one with sample data:
1 2 3 4 5
{ "output": "Choose an option:", "outputType": "interactive", "outputOptions": ["Yes", "No", "Maybe"] } - Verify Output: Ensure the response includes properly numbered options
- Integrate: Update your existing workflows to call this message formatter when standardized output is needed
Calling This Workflow¶
Use the "Execute Workflow" node in your workflows with:
- Workflow ID: cxQFcXroslgLnYtl (or update after import)
- Data to Send: Include output, outputType, and outputOptions fields
- Wait for Completion: Enable to receive the formatted response