Skip to content

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

  1. Receives Input: Another workflow triggers this one, passing message data including the output text, output type, and any interactive options
  2. Formats Message: The workflow checks if the message type is "interactive" and if options are provided
  3. Adds Numbering: For interactive messages, it automatically numbers the options (1, 2, 3, etc.) and appends them to the original message
  4. 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": "Your message text here",
  "outputType": "interactive", // or "plain"
  "outputOptions": ["Option 1", "Option 2", "Option 3"]
}

Output Data Returned

1
2
3
{
  "formattedMessage": "Your message text here\n\n1. Option 1\n2. Option 2\n3. Option 3"
}

Processing Logic

  • If outputType is "interactive" and outputOptions contains items, the workflow numbers each option and appends them to the original message
  • If outputType is "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

This workflow is designed to be called by other workflows but no specific relationships are documented in the provided context.

Setup Instructions

  1. Import Workflow: Import the JSON into your n8n instance
  2. Activate Workflow: Change the workflow status from archived to active
  3. 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"]
    }
    
  4. Verify Output: Ensure the response includes properly numbered options
  5. 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