Showcase > Customer Service

AI-Powered Student Support Agent

21-node n8n workflow using Mistral, Anthropic, Jina AI, Redis, and Google Sheets for automated Udemy student message triage and response.

ShowcaseAdvanced6 min read

A 21-node multi-model AI agent that automatically triages and responds to Udemy student messages, escalating complex cases to the instructor with full audit trail. This workflow polls the Udemy Instructor API for unreplied messages, routes each through a structured AI agent with live web research capability, and either posts an auto-response or sends an email notification to the instructor. Every interaction is logged to Google Sheets for review and accountability.

Nodes Category Complexity Key Integrations
21 Customer Service / AI Advanced Mistral, Anthropic, OpenAI, Jina AI, Redis, Google Sheets, Gmail, Udemy API

Prerequisites

  • Udemy Instructor API credentials (bearer token from your instructor account)
  • Mistral API key (primary language model)
  • Anthropic API key (fallback language model)
  • OpenAI API key (GPT-4.1 Mini for structured output parsing)
  • Jina AI API key for web research tool
  • Redis instance (cloud or self-hosted) for chat memory
  • Google Sheets OAuth2 credentials for audit trail logging
  • Gmail OAuth2 credentials for escalation notifications
  • Knowledge level: Advanced -- requires understanding of multi-model AI architecture, API authentication, and structured output parsing

Estimated Setup Time

45-60 minutes including API credential setup, Redis configuration, and escalation rule customization.

What It Does

The workflow monitors a Udemy instructor account for unreplied student messages on a recurring schedule. It fetches all pending message threads via the Udemy Instructor API, retrieves the full conversation history for each thread, and logs every message to a Google Sheets tracking sheet for audit purposes.

Each message is then passed to an AI Agent powered by a dual-model architecture: Mistral Large as the primary language model with Anthropic Claude as the fallback. The agent has access to Jina AI as a research tool for answering technical questions with current, verified information. A Structured Output Parser enforces a strict response schema, ensuring the AI produces a structured decision: respond automatically or escalate to the instructor, along with a confidence level and the response itself.

Based on the escalation decision, the workflow splits into two paths. For messages the AI handles confidently, the response is posted directly back to Udemy via the API. For messages requiring human judgment -- sales opportunities, personal questions, coaching requests, complaints -- the workflow updates the tracking sheet and sends an email notification to the instructor with a direct link to the message thread.

Workflow Diagram

Workflow Diagram

Node Breakdown

Triggers

  • Schedule Trigger
  • Manual Trigger

AI & Processing

  • AI Agent
  • Mistral Large
  • Anthropic Claude (fallback)
  • Redis Chat Memory
  • Jina AI Research Tool
  • Structured Output Parser
  • OpenAI GPT-4.1 Mini

Data & Integration

  • HTTP Request x3
  • Google Sheets x3
  • Gmail
  • Split Out
  • Loop Over Items
  • Code
  • IF

Step-by-Step Flow

  1. Trigger -- The workflow runs on a recurring schedule (configurable interval) or via manual trigger. Both paths lead to a Global Constants node that loads instructor-specific configuration.

  2. Fetch Unreplied Threads -- An HTTP Request node calls the Udemy Instructor API to retrieve all message threads with status=unreplied. The Split Out node unpacks the results array into individual items, and the Loop Over Items node processes them one at a time.

  3. Retrieve Thread History -- For each unreplied thread, a second HTTP Request node fetches the full message history. This provides the AI agent with conversation context, not just the latest message.

  4. Log to Google Sheets -- The message details -- sender, date, content, and aggregated previous interactions -- are appended to a tracking sheet. This creates an audit trail before AI processing begins. Every message is logged regardless of whether the AI responds or escalates.

  5. Generate Session Key -- A Code node generates a random 48-character session key for Redis Chat Memory. This ensures each message thread gets an isolated memory context, preventing cross-contamination between unrelated conversations.

  6. AI Agent Processing -- The AI Agent receives the latest message and conversation context. It runs on a dual-model architecture: Mistral Large as the primary language model with Anthropic Claude as the fallback. The agent's system prompt defines detailed escalation rules (sales opportunities, personal questions, coaching requests, complaints, payment issues) and auto-response guidelines (technical questions, greetings, how-to questions). When the agent needs current technical information, it uses the Jina AI research tool to search the web.

  7. Structured Output Enforcement -- The Structured Output Parser (powered by OpenAI GPT-4.1 Mini) validates the agent's response against a strict JSON schema. The output includes: escalate_to_instructor (boolean), escalation_reason (enum), response (string), confidence (high/medium/low), and tools_used (array). Malformed output is caught before it reaches the routing logic.

  8. Escalation Routing -- The IF node checks the escalate_to_instructor flag. True routes to the escalation path; false routes to the auto-response path.

  9. Escalation Path (True) -- The tracking sheet row is updated with an "escalated" status, and a Gmail notification is sent to the instructor containing the student's message and a direct link to the Udemy message thread.

  10. Auto-Response Path (False) -- The tracking sheet row is updated with the AI's response, confidence level, and a "responded" status. A third HTTP Request node then posts the AI-generated response directly back to the Udemy message thread via the Instructor API.

What Sets It Apart

Multi-model architecture with structured output. Three different language models serve distinct roles: Mistral Large handles the creative work of understanding context and drafting responses, Anthropic Claude provides a fallback for reliability, and OpenAI GPT-4.1 Mini powers the Structured Output Parser that enforces the decision schema. This separation of concerns means each model is used where it excels.

Intelligent escalation logic. The system prompt encodes detailed escalation rules that go beyond simple keyword matching. Sales opportunities are flagged with highest priority because they represent revenue. Personal questions, coaching requests, and complaints are escalated because they require human empathy. Vague conversation openers are handled by the AI with a friendly prompt for more details, not needlessly escalated as ambiguous.

Full audit trail. Every message is logged to Google Sheets before AI processing begins. The sheet tracks message ID, sender, date, content, previous interactions, AI response, confidence level, and escalation status. This creates a complete record for review and refinement.

Live research capability. Jina AI gives the agent access to current web information for technical questions. Instead of relying on the LLM's training data, the agent can verify technical details, look up documentation, and provide accurate answers backed by real sources.

Cost Considerations

  • Mistral Large: ~$2-4 per 1M input tokens; cost depends on message volume and conversation length
  • Anthropic Claude (fallback): Only incurs cost when Mistral fails; ~$3-15 per 1M tokens depending on model tier
  • OpenAI GPT-4.1 Mini: ~$0.40 per 1M input tokens for structured output parsing (very low per-message cost)
  • Jina AI: Free tier available (limited requests); paid plans start around $10/month
  • Redis: Free tier on Redis Cloud (30MB); self-hosted is free
  • Google Sheets & Gmail: Free with Google Workspace or personal account

Ideal For

  • Online course instructors managing high message volumes on Udemy or similar platforms
  • Support teams needing to triage incoming messages with AI assistance while keeping humans in the loop for sensitive cases
  • Anyone with an API-accessible inbox who wants intelligent auto-response with configurable escalation rules
  • Developers looking for a reference implementation of multi-model AI agent architecture with structured outputs

Tip: Key Techniques

Dual-Model Architecture -- Use different models for different roles. A capable model (Mistral Large) handles the nuanced work of understanding context and generating responses. A fast, cost-effective model (GPT-4.1 Mini) powers the Structured Output Parser where the task is formatting, not reasoning. A fallback model (Anthropic Claude) provides resilience if the primary model fails.

Structured Output as Routing Signal -- The Structured Output Parser does not just format the response -- it produces the routing decision. The escalate_to_instructor boolean directly drives the IF node. This means your routing logic is embedded in the AI's decision-making rather than hard-coded in n8n conditional rules.

Log Before Processing -- Always write incoming data to your tracking sheet before passing it to the AI agent. If the agent fails, the data is not lost. This is especially important for customer-facing workflows where losing a message means losing trust.

Download

The workflow.json file in this folder can be imported directly into your n8n instance via Settings > Import Workflow.

Want this running in your stack?

I build production n8n and Cloudflare automation for teams — the same engineering behind HarperFlow. Fixed-price, escrow-protected, US-based.