Build a comprehensive Telegram quiz bot using this robust n8n workflow. Automate question delivery, store results in PostgreSQL, and manage user progress with this advanced n8n template.
Download this n8n workflow template and start using it instantly.
Educators and Trainers: Who need to administer automated quizzes or assessments.
Developers: Seeking advanced examples of database state management within an n8n workflow.
Automation Specialists: Looking for a complex n8n template combining messaging bots and persistent storage.
Marketing Teams: Deploying interactive content campaigns via Telegram.
This sophisticated n8n workflow solves the challenge of running interactive, stateful quizzes within a stateless environment like a messaging application. By leveraging PostgreSQL, this n8n automation tracks user progress, randomizes questions, accepts answers, and calculates final scores accurately.
The core value provided by this n8n template is transforming a simple Telegram bot into a complex quiz engine. Every action, from starting the test to submitting an answer, is managed by a specific n8n node, ensuring data integrity. This approach guarantees that even if a user pauses the quiz, their progress is maintained within the database, ready to be resumed when the n8n trigger fires again.
This n8n workflow initiates when the Telegram Trigger n8n node receives an incoming message (a command or button click).
Telegram Trigger activates, followed by Variables TG and Initialization Set nodes, which extract critical data like Chat ID and message content.Is Start? If node checks for a welcome command. If not starting, the flow routes through the main Switch node to distinguish between textual commands (like requesting a list of tests) and inline button presses (like selecting an answer).Get Tests (a PostgreSQL n8n node) retrieves the available modules. Data manipulation nodes (Union Number with Question, Union list) format this list before the List tests Telegram n8n node presents it to the user.For Tests Switch, then Get Test (PostgreSQL), and sends a confirmation using a Telegram n8n node.Get Questions AND Answers fetches the quiz content. The Randomize questions Sort node shuffles the order, enhancing the testing experience. The Variables and Code nodes prepare the item structure.Upsert pred Answer PostgreSQL n8n node records the question state. The Question Telegram n8n node sends the question and awaits a response. The Wait n8n node pauses the execution until the user replies.Update Answer PostgreSQL n8n node. Get Non-Answered Questions checks for remaining items. The Any questions? If node decides the next step: if true, the n8n workflow loops back to send the next question; if false, the quiz is complete.Calculate answers uses PostgreSQL logic to score the quiz, and the Result Test Telegram n8n node delivers the final results to the user.To deploy this comprehensive n8n workflow, follow these steps:
Telegram Trigger n8n trigger and all Telegram output n8n node instances (Test, Question, List tests, etc.).Telegram Trigger to function, ensure your n8n instance is accessible externally and the Telegram bot is configured to send updates to the generated webhook URL.This advanced n8n workflow utilizes dozens of nodes to manage complex state:
Telegram Trigger (n8n trigger): The entry point. Listens for user input (messages, commands, button clicks) from the configured Telegram bot.
PostgreSQL Node (Get Tests, Update Answer, Calculate answers, etc.): The backbone of this n8n template. Used for persistent storage, retrieving quiz questions, saving user responses, and calculating final scores using database-side logic. Essential for maintaining the state throughout the multi-step quiz.
Switch Node (Commands, Buttons, For Tests): Core flow control n8n node used extensively to route incoming Telegram data based on whether it is a user command, an inline button click, or a specific test action.
Set Node (Variables TG, Initialization): Used to define and normalize key variables, such as user IDs and message metadata, at the start of the n8n workflow.
If Node (Is Start?, Any questions?): Determines the execution path. For instance, Any questions? checks if the quiz is finished before sending the final results.
Sort Node (Randomize questions): Ensures that questions retrieved from the database are presented in a randomized order before being sent by the Telegram n8n node.
Question Telegram n8n node to pause the n8n workflow execution until the required user response is received, enabling synchronous interaction within the asynchronous chat environment.Use this advanced n8n workflow to automate Telegram customer support, transitioning users seamlessly from a GPT-powered AI agent to a human operator via email approvals and dynamic topic creation.

Use this efficient n8n workflow to automatically parse incoming Telegram messages, separating text, captions, and file attachments for streamlined data processing. Perfect for custom bots.

Deploy a sophisticated n8n workflow for Telegram bot management, allowing admins to add/delete channels and automatically cross-post content using PostgreSQL for state and channel data storage.

Schedule and publish TikTok videos automatically using data defined in Google Sheets and stored in Google Drive. This powerful n8n workflow integrates with Blotato for seamless social media automation.

Use this powerful n8n workflow to automatically generate, clean, and log TikTok video transcripts into Google Sheets using RapidAPI, skipping already processed videos. This n8n template saves significant content creation time.

Implement advanced time tracking rules in Awork using this powerful n8n workflow. Enforce minimum time, clean up entries to match billing intervals, and prevent un-tracked task closures. Get started with n8n templates today.


Analyst-Developer







































