V4 - MessageInterceptor¶
A utility workflow that formats messages for WhatsApp delivery by converting interactive content into appropriate templates or plain text. It acts as a message processing layer that transforms raw output into WhatsApp-compatible formats with proper button configurations and template mappings.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
How It Works¶
- Receives Input: The workflow is triggered by another workflow with message content, output options, output type, and channel information
- Formats Message: Processes the input to determine the appropriate WhatsApp format - either using predefined templates with buttons or converting to numbered plain text
- Maps Templates: Matches interactive options to specific WhatsApp template IDs from a predefined mapping table
- Outputs Result: Returns the formatted message along with any required template metadata for WhatsApp delivery
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 and expects four input parameters:
- output - The main message content
- outputOptions - Array of interactive button options
- outputType - Format type (plain, interactive, form_2_1, form_3_1)
- channel - Communication channel information
Nodes Used¶
| Node Type | Node Name | Purpose |
|---|---|---|
| Execute Workflow Trigger | When Executed by Another Workflow | Receives input parameters from calling workflows |
| Code | formatMessage | Processes message content and maps to WhatsApp templates |
| Set | setOutput | Structures the final output with formatted message and template data |
External Services & Credentials Required¶
No external services or credentials are required for this workflow. It operates as a pure message formatting utility.
Environment Variables¶
No environment variables are required for this workflow.
Data Flow¶
Input Parameters:
- output (string) - Main message text
- outputOptions (array) - Interactive button options
- outputType (string) - Format type indicator
- channel (string) - Channel information
Output:
- formattedMessage (string) - Processed message ready for delivery
- contentSid (string) - WhatsApp template ID if applicable
- contentVariables (string) - JSON string of template variables
Error Handling¶
The workflow includes basic error handling through: - Default fallback to plain text formatting when template mapping fails - Graceful handling of missing or invalid input parameters - Automatic conversion of interactive options to numbered lists when no template match is found
Known Limitations¶
- Template mapping is hardcoded and requires manual updates for new button combinations
- Limited to predefined WhatsApp template IDs
- No validation of input parameter formats
- Template variables are currently limited to a single variable ('1')
Related Workflows¶
This workflow is designed to be called by other messaging workflows that need WhatsApp-compatible message formatting.
Setup Instructions¶
- Import Workflow: Import the JSON into your n8n instance
- No Configuration Required: This workflow works out of the box with no additional setup
- Template Updates: If you need to add new button combinations, update the
TEMPLATE_MAPobject in theformatMessagecode node - Integration: Call this workflow from other workflows using the Execute Workflow node, passing the required input parameters
- Testing: Test by executing with sample input parameters to verify message formatting works as expected
The workflow is ready to use immediately after import and requires no external credentials or environment configuration.