Automation · 10
Kaz AI Tutor Gateway
The n8n gateway behind Kaz, the AI tutor on my Automation Engineering Playground site. It can read a learner's n8n workflow and latest run, strips credentials and secrets, and asks Gemini for an answer at the help level the lesson allows, so hints are specific without exposing anything sensitive.
- Stack
- n8n
- Gemini
- n8n API
- Webhooks
Overview
The problem. A tutor can only give useful hints if it sees what the learner actually built, but sending a raw workflow to an AI model would expose credentials and keys. Answers also need to stay within the help level the lesson allows.
What I built. I built the gateway in n8n. It caps the incoming request, finds the learner's workflow through the n8n API and fetches its latest execution only when the question needs it. A sanitizing step drops credentials and replaces secret-like values before a prompt is built from the lesson, progress and help level, and Gemini's answer is formatted and returned to the site.
Why it helps. Learners get hints about their own workflow, and nothing secret is sent to the model.
System flow
- The AEP site sends a learner's question; the request is read and capped. Nodes: Webhook (Receive Kaz Request); Code (Read Request). Next: Inspect n8n?.
- Only questions about the learner's own workflow look at n8n. Nodes: IF (Inspect n8n?). Next: Find the workflow, Sanitize context.
- Lists workflows through the n8n API and finds the learner's. Nodes: HTTP Request · n8n API (List Workflows); Code (Find Learner Workflow). Next: Need the run?.
- Fetches the latest run only when the question needs it. Nodes: IF (Need the run?). Next: Latest execution, Sanitize context.
- Gets the most recent execution through the n8n API. Nodes: HTTP Request · n8n API (Latest Execution). Next: Sanitize context.
- Credentials are dropped and secret-like values replaced. Nodes: Code (Sanitize Context). Next: Gemini answer.
- Builds the prompt at the help level AEP chose and formats Gemini's answer. Nodes: Code ×2 (Build Kaz Prompt, Format Answer); Basic LLM Chain (Kaz Model); Google Gemini Chat Model (Gemini). Next: Respond to AEP.
- The answer goes back to the site. Nodes: Respond to Webhook (Respond to AEP). End of flow.
