π¬ Moderate toxic text, redact PII, and audit with a Gemini HTTP API
β‘ 24 views Β· π¬ Document Extraction & Analysis
Description
Quick Overview
This workflow exposes a POST webhook that sends user text (and optional context) to Google Gemini for moderation, returning an allow/flag/block decision, toxicity level, matched categories, detected PII types, a short reason, and a cleaned version with slurs masked and PII redacted.
How it works
- Receives a POST request on a webhook endpoint with a JSON body containing
textand optionalcontext. - Sends the input to Google Gemini with instructions to classify safety (allow/flag/block), rate toxicity, identify categories, detect PII, and produce a redacted/masked
cleaned_text. - Parses Geminiβs response into a structured JSON object with the required moderation fields.
- Returns the moderation result to the caller as the webhook response.
- If Gemini fails to classify the text, returns a fail-safe JSON response that flags the content for human review.
Setup
- Add a Google Gemini (PaLM) API credential for the Google Gemini Chat Model node.
- Activate the workflow and copy the production webhook URL from the webhook trigger.
- Configure your client/app to POST JSON (for example
{ "text": "...", "context": "..." }) to the/moderateendpoint and handle the JSON response.
π Nodes Used
Google Sheets, Slack, Webhook, Basic LLM Chain, Structured Output Parser, Google Gemini Chat Model
π₯ Import
Download workflow.json and import into n8n:
Workflow menu β Import from File