💬 Guide students with an AI tutor chatbot using RAG, intent classification and GPT-4o-mini

⚡ 465 views · 💬 Support Chatbots

Description

Description

Automatically guide students through personalized learning sessions using AI-powered intent classification, book-based knowledge retrieval (RAG), and full session logging — all without writing a single line of code.


What this workflow does

Nathan is an intelligent AI tutor chatbot that detects what the student is trying to do — greeting, asking a question, answering, introducing a topic, or going off-topic — and responds accordingly using the right teaching strategy every time.

Key features:


How it works

Step 1 — User sends a message The public chat trigger receives the student’s input and simultaneously fires two paths: one to the Intent Classifier and one to the Merge node for later combining.

Step 2 — DeepSeek classifies intent The Intent Classifier agent (powered by DeepSeek LLM + sliding-window memory) reads the message and outputs exactly one word: greeting / topic / answer / question / random

Step 3 — Fetch matching system prompt The classified intent is used to look up the correct system prompt from the pmt tab in Google Sheets (filtered by the Output column). Each intent maps to a unique pedagogical strategy.

Step 4 — Merge and aggregate The fetched prompt and original user input are merged and aggregated into a single payload, ready to be passed to the AI teacher.

Step 5 — AI Teacher Agent generates response (RAG) GPT-4o-mini receives the system prompt, full session memory (last 10 turns), and uses the Pinecone book vector store as a retrieval tool (topK=3). It generates a pedagogically appropriate, book-grounded response.

Step 6 — Log and return The session ID, user message, and AI response are appended to the Preservation tab in Google Sheets. The final response is formatted and returned to the student in the chat interface.


Setup requirements

Services you’ll need:

Estimated setup time: 20–30 minutes


Step-by-step setup

1. Add credentials in n8n

Go to Settings → Credentials and add:

2. Set up your Google Sheet

Create a new Google Sheet with two tabs:

Tab 1 — pmt (prompt library):

OutputPrompt
greetingYou are Nathan, a friendly tutor…
topicThe student wants to learn about…
answerThe student has just answered…
questionThe student is asking a question…
randomGently redirect the conversation…

Tab 2 — Preservation (Q&A log):

SessionUser MsgAI Response
(auto-filled)(auto-filled)(auto-filled)

3. Replace placeholder Sheet IDs

In the workflow, find all nodes that contain YOUR_GOOGLE_SHEET_ID and replace with your actual Google Sheets document ID (found in the URL: docs.google.com/spreadsheets/d/YOUR_ID_HERE).

Also replace YOUR_PRESERVATION_SHEET_GID with the gid value of your Preservation tab.

4. Set up Pinecone vector store

5. Activate and test

Enable the workflow, open the public chat URL, and send a test message like: “Hi, I want to learn about Newton’s laws”

You should see:


Customization options

Swap the classifier model Replace DeepSeek with any chat LLM (GPT-4o-mini, Gemini, Claude) in the Intent Classifier node — the prompt is model-agnostic.

Add new intent categories Add a new row to the pmt tab with your intent keyword and system prompt. Then extend the classifier’s system message to recognize the new category.

Adjust retrieval depth Change topK in the Pinecone node from 3 to 5 or 10 to retrieve more book chunks per query — useful for complex or detailed topics.

Change memory length The Classifier Memory and Teacher Session Memory both use a context window of 10 turns. Lower this for faster responses, increase it for longer multi-turn sessions.

Embed multiple books Upload chapters from different books into the same Pinecone index. The agent automatically retrieves the most relevant chunks regardless of source.


Troubleshooting

Intent classifier returns unexpected output Make sure the DeepSeek system prompt ends with the exact instruction: “Respond with only one word from this list.” Any extra text in the response will break the Google Sheets lookup.

Google Sheets lookup returns no results Verify that the Output column in the pmt tab contains lowercase values matching exactly what DeepSeek outputs (e.g., greeting not Greeting).

Pinecone returns empty results Confirm your index name matches the one in the node, your documents are embedded using the same OpenAI Embeddings model, and the index is not empty.

Session memory not persisting across turns The session key is pulled from $('Chat Trigger').item.json.sessionId. Ensure you are using the same browser session (do not open in incognito) and the chat trigger is set to public mode.

Preservation sheet not updating Check that the Preservation tab GID is correct and that your Google Sheets OAuth credentials have edit access to the document.


Support

Need help setting this up or want a custom version for your school or platform?

📧 Email: info@isawow.com 🌐 Website: https://isawow.com/

🔗 Nodes Used

Google Sheets, AI Agent, Embeddings OpenAI, OpenAI Chat Model, Simple Memory, Pinecone Vector Store

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup