Moderate toxic text, redact PII, and audit with a Gemini HTTP API

Go to Workflow
1 views
Built by Oka Hironobu Oka Hironobu
Created on July 27, 2026

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 text and optional context.
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 /moderate endpoint and handle the JSON response.

Nodes Used (6)

Basic LLM Chain
@n8n/n8n-nodes-langchain.chainLlm
Code
n8n-nodes-base.code
Google Gemini Chat Model
@n8n/n8n-nodes-langchain.lmChatGoogleGemini
Google Sheets
n8n-nodes-base.googleSheets
Slack
n8n-nodes-base.slack
Structured Output Parser
@n8n/n8n-nodes-langchain.outputParserStructured