← Back to PlayBook
Examples
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
- Import your
n8n-moderator.jsonworkflow into n8n. - Configure credentials and headers for:
- Trugen AI API (
x-api-keyin HTTP Request nodes) - n8n webhook endpoint for inbound speech events
- Trugen AI API (
Before you run it: replace hardcoded values
- In
Trugen Speak - Send WarningandTrugen Delete - End Conversation, replace the samplex-api-keywith 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 Speechaccepts incomingPUTevents.Parse & Validate Inputextracts:conversation_iduser_text
- The parser supports both event payloads (
utterance_committed) and manual test payloads.
Step 3: Moderation and Enforcement
Offensive Content Detectorflags text using keyword matching.Is Offensive?routes flow:- Clean path -> build clean response
- Offensive path -> increment warning and send moderation message
Increment Warning & Build Messagestores warning counts with workflow static data perconversation_id.- On third warning,
Trugen Delete - End Conversationends 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_offensiveboolean.
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 detectedwarned: offensive content detected, warning issuedterminated: 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