Description
Overview
This toxic language detection workflow provides an automated monitoring solution for Telegram messages, leveraging an event-driven analysis pipeline to identify offensive content. Designed for community moderators and bot developers, it addresses the core problem of real-time detection and mitigation of toxic language by integrating Telegram message triggers with language toxicity scoring.
Key Benefits
- Detects profanity in Telegram messages using a threshold-based automation workflow.
- Provides immediate, deterministic responses to high profanity scores above 0.7.
- Integrates seamlessly with Telegram updates including new and edited messages.
- Utilizes Google Perspective API for multi-attribute toxicity evaluation in English.
Product Overview
This Telegram toxic language detection workflow initiates with a Telegram Trigger node configured to listen for multiple update types: message, edited message, channel post, and edited channel post. Upon receiving an update, it extracts the message text and forwards it to the Google Perspective node, which requests three specific toxicity attributes: identity attack, threat, and profanity, focused on English language content. The workflow then evaluates the profanity score with an IF node, using a deterministic threshold of 0.7. If the score exceeds this value, the Telegram node posts a fixed warning reply directly to the originating chat and message. If the threshold is not met, a NoOp node terminates the flow without action. Authentication for Telegram interaction is managed via API credentials, while OAuth2 credentials secure access to the Google Perspective API. The workflow operates synchronously in response to each Telegram event, ensuring timely moderation feedback. No explicit error handling or persistence mechanisms are implemented beyond platform defaults.
Features and Outcomes
Core Automation
This event-driven analysis pipeline inputs Telegram message text and applies a threshold-based decision via the IF node to detect profanity. The deterministic branch either triggers a response or halts the workflow without side effects.
- Single-pass evaluation of text toxicity attributes from Google Perspective.
- Deterministic routing based on profanity score threshold set at 0.7.
- Immediate synchronous response to Telegram messages flagged as profane.
Integrations and Intake
The orchestration pipeline connects Telegram and Google Perspective APIs using secure credentials. It listens to multiple Telegram update types and sends extracted message text for toxicity analysis.
- Telegram API integration for real-time message and post updates intake.
- Google Perspective API with OAuth2 authentication for text toxicity scoring.
- Supports English language text inputs with requests for identity attack, threat, and profanity attributes.
Outputs and Consumption
The workflow outputs a fixed warning reply message within the Telegram chat if a profanity threshold is exceeded. If no action is triggered, the workflow terminates silently.
- Response messages sent directly to the originating Telegram chat and message.
- Synchronous processing model ensuring immediate reply upon detection.
- Outputs include standard Telegram message metadata and Google Perspective attribute scores.
Workflow — End-to-End Execution
Step 1: Trigger
The workflow begins with a Telegram Trigger node capturing incoming Telegram updates. It listens for new messages, edited messages, channel posts, and edited channel posts, extracting message text and metadata such as chat and message IDs.
Step 2: Processing
The message text is extracted and passed to the Google Perspective node. Basic presence checks ensure the “text” field is forwarded correctly. No additional schema validation is applied beyond this extraction.
Step 3: Analysis
Google Perspective evaluates the text for three toxicity attributes: identity attack, threat, and profanity, focusing on English language content. The IF node then compares the profanity score to a fixed threshold of 0.7 to determine workflow branching.
Step 4: Delivery
If the profanity score exceeds 0.7, the Telegram node sends a fixed reply message to the original chat and message, warning against toxic language. Otherwise, the workflow terminates at the NoOp node without further action. Responses are synchronous and immediate.
Use Cases
Scenario 1
Community moderators need automated monitoring to maintain respectful conversations. This workflow detects profane language in Telegram channels and replies instantly with a warning, reducing manual oversight and promoting healthier communication.
Scenario 2
Developers building Telegram bots require integrated toxicity analysis. By connecting message intake with Google Perspective scoring, this workflow automates profanity detection and response, enabling bots to enforce chat guidelines deterministically.
Scenario 3
Organizations managing public Telegram groups seek scalable moderation tools. This orchestration pipeline processes multiple update types in real time, providing consistent enforcement of language policies without manual intervention.
How to use
To deploy this toxic language detection automation, import the workflow into n8n and configure Telegram API credentials with bot access. Set up Google Perspective OAuth2 credentials with required API scopes. Activate the workflow to start listening for Telegram updates. On each message event, the workflow evaluates text toxicity and replies to profane messages automatically. Monitor logs to verify responses and adjust the profanity threshold in the IF node if necessary. The workflow runs continuously, providing real-time moderation feedback within Telegram chats.
Comparison — Manual Process vs. Automation Workflow
| Attribute | Manual/Alternative | This Workflow |
|---|---|---|
| Steps required | Multiple manual reviews and message replies | Automated single-pass detection and reply |
| Consistency | Varies by moderator judgment and workload | Deterministic threshold-based response |
| Scalability | Limited by human capacity | Scales with Telegram and API throughput |
| Maintenance | Requires ongoing moderator training and monitoring | Minimal maintenance beyond credential updates |
Technical Specifications
| Environment | n8n workflow automation platform |
|---|---|
| Tools / APIs | Telegram API, Google Perspective API |
| Execution Model | Event-driven synchronous processing |
| Input Formats | Telegram message JSON payload |
| Output Formats | Telegram chat messages |
| Data Handling | Transient message text processing, no persistence |
| Known Constraints | Relies on external API availability and network connectivity |
| Credentials | Telegram API key, Google Perspective OAuth2 token |
Implementation Requirements
- Valid Telegram bot API credentials with access to message updates.
- Google Perspective API OAuth2 credentials with permission for text analysis.
- Stable network connection to n8n server for continuous webhook reception and API calls.
Configuration & Validation
- Ensure Telegram Trigger node correctly receives and parses message updates.
- Verify Google Perspective node returns attribute scores for injected text inputs.
- Confirm IF node branches correctly by testing messages above and below profanity threshold.
Data Provenance
- Telegram Trigger node captures incoming message updates for analysis.
- Google Perspective node performs toxicity attribute scoring on extracted text.
- IF node evaluates profanity score to determine subsequent Telegram reply or no action.
FAQ
How is the toxic language detection automation workflow triggered?
The workflow triggers on Telegram message updates including new messages, edited messages, channel posts, and edited channel posts via the Telegram Trigger node.
Which tools or models does the orchestration pipeline use?
It uses the Google Perspective API to evaluate text for identity attacks, threats, and profanity, authenticated via OAuth2 credentials.
What does the response look like for client consumption?
For messages exceeding the profanity threshold, a fixed reply is sent in the same Telegram chat, directly responding to the offending message.
Is any data persisted by the workflow?
No data is persisted; all message text processing is transient and handled within the workflow execution context.
How are errors handled in this integration flow?
The workflow relies on n8n platform defaults for error handling; no custom retry or backoff mechanisms are implemented.
Conclusion
This toxic language detection workflow automates the identification and moderation of profane Telegram messages with a deterministic threshold-based approach. It provides consistent, real-time detection using Google Perspective’s toxicity scoring integrated directly with Telegram messaging events. While the workflow depends on external API availability and network connectivity, it requires minimal maintenance once configured. This solution offers a dependable foundation for automated chat moderation, reducing manual intervention and supporting safer communication environments.








Reviews
There are no reviews yet.