Opening Problem Statement
Meet Anna, a dedicated learner eager to master Chinese vocabulary. Every day, she struggles with traditional flashcards and scattered vocabulary lists, feeling lost about where to begin and how to get immediate feedback. Manually creating quizzes takes her hours weekly, cuts into her study time, and she often repeats mistakes without clear corrections. Anna wishes to practice efficiently anytime using her favorite messaging app, Telegram, but lacks a tool that combines vocabulary data, interactive questioning, and instant feedback.
This problem perfectly fits the solution offered by this unique n8n workflow, which automates Chinese vocabulary practice via a Telegram chatbot powered by AI, integrating vocabulary stored in Google Sheets.
What This Automation Does
This specialized n8n workflow creates a personalized language tutor experience that operates entirely within Telegram, fueled by dynamic vocabulary data from Google Sheets and advanced AI.
- Instant Quiz Generation: When Anna sends a message on Telegram, the workflow triggers an AI agent to generate a new multiple-choice question (MCQ) based on a curated list of Chinese vocabulary from Google Sheets.
- Interactive Learning: The AI evaluates Anna’s answer in real-time, providing encouraging feedback for correct responses or corrective guidance if she makes a mistake.
- Personalized Conversation Memory: The workflow leverages a memory buffer node to maintain context across the session, ensuring continuity and personalized interaction.
- Google Sheets as Vocabulary Backend: Vocabulary words and their English translations are maintained in Google Sheets, allowing easy updates and extensions without modifying the automation itself.
- Telegram Integration: The entire learning experience happens in Telegram, making practice accessible anywhere, anytime, without switching apps.
- Automated Feedback Loop: After each answer evaluation, the AI instantly generates the next question, maintaining an engaging learning flow without requiring additional user prompts.
By automating quiz interactions and feedback, this workflow saves learners several hours weekly otherwise spent creating practice materials and provides immediate correction—critical for effective language acquisition.
Prerequisites ⚙️
- n8n Account: Access to n8n for workflow creation and execution.
- Telegram Bot & Credentials 📧: A Telegram bot configured to interact with users via messages.
- Google Sheets API Access 📊: Permission and credentials to read from a Google Sheet containing the Chinese vocabulary and English translations.
- OpenAI API Key 🔑: To use the GPT-powered chat model to generate and evaluate quiz questions.
Optional: If you prefer self-hosting n8n for privacy or cost reasons, check Hostinger’s guide to self-hosting n8n.
Step-by-Step Guide to Build This Workflow
Step 1: Set Up Telegram Trigger Node
Navigate to Nodes → Create Node → Telegram Trigger. Configure your Telegram bot credentials by adding the API token. In parameters, select “Updates” → “message” because the workflow activates on new user messages.
You should see a webhook URL generated, which Telegram uses to send updates.
Common mistake: Not setting the bot’s webhook properly in Telegram BotFather, resulting in no message triggers.
Step 2: Retrieve Vocabulary from Google Sheets
Add a Google Sheets node named “Retrieve Vocabulary.” Connect it to the Telegram Trigger node’s output.
Configure it with your Google Sheets API credentials, select the spreadsheet containing your Chinese vocabulary, and choose the correct sheet index or name.
Example: Sheet 0 might contain columns “initialText” (English) and “translatedText” (Chinese).
Expected result: The node outputs all vocabulary entries each time a message is received.
Common mistake: Forgetting to authorize the Google Sheets node, leading to authentication errors.
Step 3: Aggregate Vocabulary Lists
Add an Aggregate node named “Aggregate Vocabulary Lists.” Connect it to the Google Sheets node.
In parameters, configure to aggregate two fields: “initialText” renamed as “initialLanguage” and “translatedText” renamed as “targetLanguage.”
This restructures the data into two consolidated lists for use by the AI.
Expected output: Two arrays – one for English words and one for Chinese terms.
Common mistake: Missing or misspelling field names causes the aggregation to fail.
Step 4: Add Simple Memory for Session Context
Add the Simple Memory node from the LangChain package.
Configure the sessionKey as this expression: {{ $('Telegram Trigger').item.json.message.chat.id }} to uniquely track each conversation.
This node saves conversation history for the AI agent.
Expected result: Context-aware responses personalized per user.
Common mistake: Using incorrect session key format breaks session tracking.
Step 5: Configure OpenAI Chat Model
Add the OpenAI Chat Model node, choosing the GPT model labeled “gpt-4o-mini.”
Enter your OpenAI API key credential.
This model will generate language prompts for the AI agent Node.
Expected result: Smooth AI generation of questions and answer evaluations.
Common mistake: Not providing valid OpenAI credentials causes authentication failures.
Step 6: Set Up AI Agent Node
Add the LangChain AI Agent node.
Configure it with the combined vocabulary lists aggregated earlier and the incoming user message text using the expression:={{ $('Telegram Trigger').item.json.message.text }}
Enter the detailed systemMessage to guide the AI’s behavior:
- Explain the roles: generating MCQs and evaluating user answers.
- Set the MCQ format with one correct and three incorrect options from vocabulary.
- Define response and feedback behavior.
Expected output: An AI-generated quiz question or feedback based on user input.
Common mistake: Incorrect prompt syntax or missing required vocabulary fields causes poor questions.
Step 7: Respond to the User via Telegram Node
Add a Telegram node named “Answer to the User.”
Configure it to send messages back using:
– Text: Set to ={{ $json.output }} from the AI Agent’s output.
– Chat ID: Use ={{ $('Telegram Trigger').item.json.message.chat.id }}.
Expected result: The user receives clear, well-formatted quiz questions or feedback instantly.
Common mistake: Using wrong chat id expression leads to messages not reaching the user.
Customizations ✏️
- Add More Vocabulary Columns: In the Google Sheets node, include audio file URLs or example sentences as additional columns; then extend the aggregate step to pass them for richer AI questions.
- Adjust AI Prompt for Difficulty: Modify the
systemMessagein the AI Agent node to include difficulty tags or change the number of answer choices. - Add User Performance Tracking: Insert a database or Google Sheets node to log correct/wrong answers per user for progress analysis.
- Switch AI Model: Change the OpenAI Chat Model node to use other models like GPT-4 or GPT-3.5 for different performance or cost balance.
- Enable Multi-language Support: In the prompt, dynamically switch the target vocabulary list from Google Sheets for different languages besides Chinese.
Troubleshooting 🔧
Problem: “Telegram messages trigger but no quiz question is sent back.”
Cause: Incorrect chat ID in the Telegram reply node.
Solution: Verify the chatId parameter is set exactly to {{ $('Telegram Trigger').item.json.message.chat.id }}. Test by sending messages from Telegram and check debug.
Problem: “Google Sheets node authentication fails.”
Cause: Token expired or permissions not granted.
Solution: Re-authenticate the Google Sheets credentials with correct scopes; confirm sharing settings on the spreadsheet.
Problem: “AI agent generates unrelated questions.”
Cause: Incorrect or incomplete vocabulary data passed.
Solution: Verify aggregation fields; ensure vocabulary list has correct fields and is sent fully to the AI agent node.
Pre-Production Checklist ✅
- Test Telegram Trigger with messages to confirm workflow initiates.
- Ensure Google Sheets node outputs expected vocabulary arrays.
- Check aggregation node produces properly named field arrays.
- Verify AI agent node correctly processes input prompt and generates output.
- Send test Telegram responses and verify answer formatting.
- Backup Google Sheet vocabulary data.
Deployment Guide
Activate the workflow in n8n by clicking “Active.” Ensure all credentials are valid and the Telegram bot webhook is set.
Keep an eye on the execution logs for errors. Due to conversational interaction, monitor user feedback periodically to tweak the AI prompt if needed.
Auto-regulated AI memory assures personalized sessions for each user without manual state management.
Conclusion
By following this detailed guide, you’ve built a powerful Telegram-based Chinese vocabulary tutor that dynamically generates interactive quizzes and real-time feedback using Google Sheets and AI within n8n. This automation saves users like Anna countless hours manually preparing flashcards and quizzes, improves learning effectiveness with immediate personalized interaction, and makes practicing language simple and accessible anytime.
Next steps could include adding progress tracking and analytics or expanding support for other languages in your Google Sheets database. With this foundation, you can continue evolving your automated language tutor to be smarter and more user-friendly.
Enjoy your streamlined, AI-powered study sessions on Telegram! ✏️🔑