Skip to content

V4 - MessageInterceptor - Warenga

This workflow serves as a message formatting service for the Warenga platform, transforming raw message content into properly formatted outputs with appropriate Twilio Content SIDs for different message types including interactive buttons, forms, and plain text messages.

Purpose

No business context provided yet — add a context.md to enrich this documentation.

How It Works

  1. Receives Input: The workflow is triggered by another workflow with message data including output text, options, output type, and channel information
  2. Formats Message: A JavaScript function processes the input to determine the appropriate message format based on the output type
  3. Maps Templates: For interactive messages, it maps option combinations to predefined Twilio Content SIDs from a template library
  4. Handles Forms: Processes different form types (business behavior, financial forms) with specific Content SIDs and variable mappings
  5. Outputs Results: Returns formatted message content along with Twilio-specific parameters for message 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 within the n8n ecosystem. It accepts four input parameters: - output - The message content to be formatted - outputOptions - Array of interactive options (for buttons/menus) - outputType - Type of message format (plain, interactive, form variants) - 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 (JavaScript) formatMessage Processes message content and maps to appropriate Twilio templates
Set setOutput Structures the final output data for the calling workflow

External Services & Credentials Required

Twilio Content Templates: This workflow references predefined Twilio Content SIDs for message templates. While no direct Twilio API calls are made in this workflow, the output is designed for use with Twilio's messaging services.

No credentials are required for this workflow itself, but the calling workflows will need appropriate Twilio credentials to use the generated Content SIDs.

Environment Variables

No environment variables are required for this workflow.

Data Flow

Input Parameters: - output (string) - Raw message text - outputOptions (array) - Interactive button/menu options - outputType (string) - Message format type - channel (string) - Communication channel

Output Data: - formattedMessage - Processed message text ready for delivery - contentSid - Twilio Content Template ID (if applicable) - contentVariables - JSON string of template variables - outputType - Original output type passed through - outputOptions - Serialized options array - output - Original output text passed through

Error Handling

This workflow does not implement explicit error handling. It relies on n8n's default error propagation to the calling workflow. Invalid input types or missing parameters may result in undefined behavior.

Known Limitations

  • Template mapping is hardcoded in the JavaScript function and requires manual updates for new interactive option combinations
  • No validation of input parameters
  • Limited error handling for malformed inputs
  • Content SIDs are environment-specific and may need adjustment for different deployment environments

This is a utility workflow designed to be called by other messaging workflows in the Warenga platform. It does not directly call other workflows but serves as a dependency for message formatting operations.

Setup Instructions

  1. Import Workflow: Import the workflow JSON into your n8n instance
  2. Verify Template IDs: Review the TEMPLATE_MAP object in the formatMessage node to ensure Content SIDs match your Twilio account
  3. Update Form Templates: Modify the form-specific Content SIDs in the formatMessage node if using different Twilio templates
  4. Test Integration: Create a test workflow that calls this workflow with sample parameters to verify proper formatting
  5. Activate Workflow: Enable the workflow to make it available for execution by other workflows

Configuration Notes: - The workflow expects specific input parameter names - ensure calling workflows use the correct parameter structure - Content SIDs should be validated against your Twilio account before deployment - Consider implementing input validation if this workflow will be used extensively across your platform