May 6, 2026

n8n Conversation Moderator (3-Strike Policy)

TGTruGen AIbeginner

Overview

This guide deploys the n8n Conversation Moderator (3-Strike Policy) workflow for realtime speech moderation in Trugen sessions.

The workflow receives webhook speech events, detects offensive content using keyword logic, issues escalating warnings, and terminates the conversation after 3 violations.


Quick Start: Deployment Flow

This workflow is designed for direct import into n8n.

Step 1: n8n Import & Credentials

  1. Import your n8n-moderator.json workflow into n8n.
  2. Configure credentials and headers for:
    • Trugen AI API (x-api-key in HTTP Request nodes)
    • n8n webhook endpoint for inbound speech events

Before you run it: replace hardcoded values

  • In Trugen Speak - Send Warning and Trugen Delete - End Conversation, replace the sample x-api-key with your own key.
  • Confirm the webhook path in Webhook - Receive User Speech (invigilator-input) matches your expected callback URL.
  • If needed, adjust the keyword list inside Offensive Content Detector.

Step 2: Event Parsing and Validation

  • Webhook - Receive User Speech accepts incoming PUT events.
  • Parse & Validate Input extracts:
    • conversation_id
    • user_text
  • The parser supports both event payloads (utterance_committed) and manual test payloads.

Step 3: Moderation and Enforcement

  • Offensive Content Detector flags text using keyword matching.
  • Is Offensive? routes flow:
    • Clean path -> build clean response
    • Offensive path -> increment warning and send moderation message
  • Increment Warning & Build Message stores warning counts with workflow static data per conversation_id.
  • On third warning, Trugen Delete - End Conversation ends the conversation.

Workflow Architecture

Phase 1: Ingestion

  • Receive callback payload from webhook.
  • Normalize input fields for downstream nodes.

Phase 2: Detection

  • Convert text to lowercase.
  • Match against offensive terms list.
  • Set is_offensive boolean.

Phase 3: Response Policy

  • Offensive event increments warning count.
  • Warning message is sent back to active conversation.
  • Third warning triggers forced termination.
  • Final result is returned via Respond to Webhook.

Requirements

  • n8n instance
  • Trugen AI API access
  • Webhook integration from your speech/call event source

Output States

  • clean: no offensive content detected
  • warned: offensive content detected, warning issued
  • terminated: third warning reached, conversation closed

Result

  • Automatic moderation guardrail for live conversations
  • Deterministic 3-warning escalation policy
  • Immediate enforcement and JSON response for upstream systems