🔓 Unlock all 10,000+ workflows & prompts free Join Newsletter →
✅ Full access unlocked — explore all 10,000 AI workflow and prompt templates Browse Templates →
Home n8n Workflow
January 22, 2026

Telegram + Postgres quizzes with scoring and rankings

Lisa Granqvist Partner Workflow Automation Expert

Running a quiz in chat sounds simple until you’re copying answers into spreadsheets, chasing missing replies, and arguing with yourself about what “counts” as correct. Then someone asks for rankings. Or a clean report. And the whole thing turns into admin work.

HR managers feel it when training compliance is due. An educator running weekly tests runs into the same wall. So does a team lead onboarding new hires. This Telegram quiz scoring automation keeps the quiz in Telegram and puts the data where it belongs, in a database, scored and ready.

Below you’ll see how the workflow runs, what it automates end-to-end, and what you can tweak to match your scoring style and tone.

How This Automation Works

The full n8n workflow, from trigger to final output:

n8n Workflow Template: Telegram + Postgres quizzes with scoring and rankings

The Problem: Quizzes in chat get messy fast

Collecting answers in Telegram (or any chat) is easy. Managing them is the painful part. You end up scrolling through threads to find who answered what, then retyping it somewhere “official” so you can score it. Miss one message and the results are wrong. Add a second quiz, a second cohort, or a second reviewer, and you’re suddenly dealing with inconsistent scoring, duplicated attempts, and reports that don’t match what participants saw in the chat.

The friction compounds. It’s not one big failure, it’s dozens of small ones that steal your attention.

  • Answers live in Telegram history, which means reporting starts with searching and guessing.
  • Manual scoring invites inconsistency, especially when multiple people run the same test.
  • Participants ask “how did I do?” and you spend another hour compiling rankings.
  • When you want trends over time, the data is too messy to trust.

The Solution: Telegram quizzes logged, scored, and ranked in Postgres

This n8n workflow turns Telegram into the front door for quizzes, then uses Postgres as the system of record. A participant starts in the Telegram bot, the workflow checks where they are in the process, and it routes them to the right place (menu, test list, or the next unanswered question). Questions and answers are pulled from Postgres, the workflow shuffles the order, and then delivers each question in chat. Each response gets recorded back into Postgres immediately, so you’re not depending on someone to “save it later.” At the end, results are computed in the database and the participant gets their outcome plus a ranking view, right inside Telegram.

The workflow starts with a Telegram message to your bot. It then fetches the test content from Postgres, sends questions one-by-one, and logs every answer as it comes in. Finally, it calculates the score and shares the participant’s ranking so there’s no extra follow-up.

What You Get: Automation vs. Results

Example: What This Looks Like

Say you run a 10-question onboarding quiz for 20 new hires each month. Manually, you might spend about 5 minutes per person just to find answers in chat and enter them somewhere useful, which is roughly 2 hours before you even start scoring and ranking. With this workflow, the “admin” part is basically zero: the participant starts the bot, answers in Telegram, and Postgres stores every response automatically. You’ll still spend time reviewing outcomes, but the copy-paste and cleanup disappear.

What You’ll Need

  • n8n instance (try n8n Cloud free)
  • Self-hosting option if you prefer (Hostinger works well)
  • Telegram for the quiz bot and participant chat.
  • Postgres to store tests, answers, and scores.
  • Postgres schema/tables (create them using the provided SQL script).

Skill level: Intermediate. You’ll connect Telegram and Postgres, then run a SQL script and map a few fields in n8n.

Don’t want to set this up yourself? Talk to an automation expert (free 15-minute consultation).

How It Works

A participant messages your Telegram bot. The Telegram trigger starts the workflow and sets variables for the session, like which menu state the user is in and which test they’re taking.

The workflow routes them to the right place. Using simple checks and switches, n8n decides if it should show a greeting, display the test list, start a new attempt, or continue unanswered questions.

Questions are pulled from Postgres and delivered in chat. The workflow fetches the Q&A items, shuffles them, assigns the current index, and sends the next question. There’s also a short wait and message cleanup so the chat stays readable.

Responses get recorded, then results are computed. Each answer is written to Postgres, the workflow checks what’s left, and when the quiz is complete it calculates the score and sends results plus ranking back to Telegram.

You can easily modify the scoring logic to accept partial credit or different answer formats based on your needs. See the full implementation guide below for customization options.

Step-by-Step Implementation Guide

Step 1: Configure the Telegram Trigger

This workflow starts when a Telegram message arrives, then initializes variables and bootstraps the session before routing the user.

  1. Add and open Telegram Intake Trigger and connect it to Telegram Variable Setup.
  2. Open Telegram Variable Setup and define the user/session fields you need for downstream routing.
  3. Open Bootstrap Setup and set any default variables required for the quiz state.
  4. Verify the execution path Telegram Intake TriggerTelegram Variable SetupBootstrap SetupStart Checkpoint.

Credential Required: Connect your Telegram credentials (required for Telegram Intake Trigger and all Telegram nodes).

Step 2: Configure Initial Routing and Greeting

After the bootstrap, the workflow determines whether to greet the user and how to route commands versus button actions.

  1. Open Start Checkpoint and configure the IF conditions that control whether users receive the greeting and route selector.
  2. Configure Greeting Notice with your welcome message to the user.
  3. Open Route Selector and define switch rules to pass Telegram input to either Button Branching or Command Routing.
  4. In Button Branching, add routes for interactive button actions to Primary Menu and Test Mode Router.
  5. In Command Routing, define command-based paths to Retrieve Test List and the fallback to Error Notification.

Credential Required: Connect your Telegram credentials (required for Greeting Notice, Primary Menu, and Error Notification).

Step 3: Connect Database Operations (Postgres)

The workflow relies on Postgres for quiz lists, individual tests, answer recording, and results computation. Configure credentials for all database nodes.

  1. Open Set Bot Status and configure the SQL needed to record or update the bot’s session state.
  2. Open Retrieve Test List and set your query to return available quizzes for the user.
  3. Configure Fetch Single Test and Fetch Q&A Items queries to fetch the chosen quiz and its questions.
  4. Open Upsert Predicted Answer and Record Answer to store predicted/actual answers as needed.
  5. Configure Load Unanswered Items and Compute Results to load remaining questions and calculate the final score.

Credential Required: Connect your Postgres credentials (required for all Postgres nodes such as Retrieve Test List, Fetch Q&A Items, Compute Results, and others).

Step 4: Build the Test List and Entry Flow

Once a list is retrieved, the workflow formats and displays it, then allows users to enter a selected test.

  1. Open Attach Question Index to map indices for the list of tests returned by Retrieve Test List.
  2. Configure Summarize List to build a condensed output list from the indexed data.
  3. Open Display Test List and format the output message sent to Telegram.
  4. Ensure the path Fetch Single TestRun Test EntryFetch Q&A Items is connected for starting a chosen test.

Credential Required: Connect your Telegram credentials for Display Test List and Run Test Entry.

Step 5: Configure Question Processing and Parallel Branching

Questions are randomized, processed, and merged before storing predicted answers. This step uses a parallel branch after shuffling.

  1. Open Shuffle Questions and configure the sort/shuffle logic for question order.
  2. Shuffle Questions outputs to both Custom Script and Assign Variables in parallel.
  3. In Custom Script, add any custom logic for question metadata or filtering.
  4. In Assign Variables, map question data into consistent fields for downstream nodes.
  5. Confirm both branches merge in Combine Streams before storing with Upsert Predicted Answer.

Step 6: Deliver Questions, Wait, and Clean Up Messages

This section sends each question to Telegram, waits, and removes prior messages to keep the chat clean.

  1. Open Send Question and format the question payload sent to the user.
  2. Configure Delay Step to define the wait time before cleanup.
  3. Open Remove Message to delete or hide previous messages after the delay.

Credential Required: Connect your Telegram credentials for Send Question and Remove Message.

Step 7: Record Answers and Decide Whether to Continue

Answers are stored and the workflow checks for remaining questions, either looping back or computing results.

  1. Open Record Answer to store the user’s response in your database.
  2. Configure Load Unanswered Items to retrieve the next unanswered question set.
  3. In Remaining Questions?, set the IF logic to route to Shuffle Questions when questions remain or to Compute Results when finished.

Credential Required: Connect your Postgres credentials for Record Answer and Load Unanswered Items.

Step 8: Send Results to the User

When the quiz ends, results are calculated and sent via Telegram.

  1. Open Compute Results and ensure the SQL returns the score and summary fields you want to display.
  2. Configure Send Results to format the final response message for the user.

Credential Required: Connect your Telegram credentials for Send Results.

Step 9: Test & Activate Your Workflow

Run a full test to validate Telegram input, quiz flow, database writes, and final result output.

  1. Click Execute Workflow and send a message to your Telegram bot to trigger Telegram Intake Trigger.
  2. Verify the greeting and routing behavior flows through Greeting Notice, Route Selector, and Primary Menu.
  3. Select a test and confirm questions are sent through Send Question with the delay and cleanup running.
  4. Complete the quiz and confirm Send Results posts the final score.
  5. When everything works, toggle the workflow to Active for production use.
🔒

Unlock Full Step-by-Step Guide

Get the complete implementation guide + downloadable template

Common Gotchas

  • Telegram bot credentials can expire or be tied to the wrong bot. If messages stop sending, check your Telegram node credentials in n8n first, then confirm the bot token is still valid in BotFather.
  • If you’re using Wait nodes or relying on chat timing, processing times vary. Bump up the wait duration if downstream nodes fail on empty responses or the user replies slower than expected.
  • Postgres permissions matter more than people expect. If upserts or inserts fail, check the database user rights on your quiz tables and confirm you replaced the default “n8n” schema name in the SQL script.

Frequently Asked Questions

How long does it take to set up this Telegram quiz scoring automation?

About 45 minutes if your Postgres and Telegram bot are ready.

Do I need coding skills to automate Telegram quiz scoring?

No. You’ll mostly connect accounts and paste the provided SQL to create tables.

Is n8n free to use for this Telegram quiz scoring workflow?

Yes. n8n has a free self-hosted option and a free trial on n8n Cloud. Cloud plans start at $20/month for higher volume. You’ll also need to factor in your database hosting costs (Postgres is often included with your existing stack).

Where can I host n8n to run this automation?

Two options: n8n Cloud (managed, easiest setup) or self-hosting on a VPS. For self-hosting, Hostinger VPS is affordable and handles n8n well. Self-hosting gives you unlimited executions but requires basic server management.

Can I customize this Telegram quiz scoring workflow for multiple quizzes and different scoring rules?

Yes, and you’ll probably want to. Most people customize it by editing test content directly in Postgres, then tweaking the messaging in the Telegram “Send Question” and “Send Results” steps so it matches their tone. If you need different evaluation methods (partial credit, negative marking, or multiple correct answers), update the Postgres-side scoring query used in “Compute Results,” and adjust the values the workflow stores in “Record Answer.” You can also change the shuffling behavior by editing the “Shuffle Questions” logic so certain questions always appear first.

Why is my Telegram connection failing in this workflow?

Usually it’s an invalid or rotated bot token, so Telegram nodes can’t send messages anymore. Update the Telegram credentials in n8n, then run a test message from “Greeting Notice” or “Send Question.” If it still fails, check that the bot is allowed to message users (they must start the bot first), and confirm you’re not mixing up environments if you have a test bot and a production bot.

How many quiz attempts can this Telegram quiz scoring automation handle?

On n8n Cloud Starter, you can run a few thousand workflow executions per month, which is enough for many small teams running quizzes weekly. If you self-host, there’s no execution cap, so the limit is mostly your server and Postgres performance. Practically, this workflow is comfortable handling many concurrent users because each answer is just a small database write and a Telegram message. If you expect big spikes, start by increasing wait times and making sure your Postgres has indexes on attempt and user fields.

Is this Telegram quiz scoring automation better than using Zapier or Make?

Often, yes, because this workflow isn’t a simple two-step “send then log” automation. You need branching, state tracking, and repeated question loops, which n8n handles cleanly without forcing you into expensive task counts. Self-hosting is also a big deal if you run quizzes frequently. Zapier or Make can be easier for very small flows, but they get awkward when you’re managing menus, retries, and ranking logic. If you want help choosing, Talk to an automation expert and we’ll map the simplest option for your setup.

Once this is running, quizzes stop being a cleanup project. The workflow handles the repetitive parts so you can focus on what the results actually mean.

Need Help Setting This Up?

Our automation experts can build and customize this workflow for your specific needs. Free 15-minute consultation—no commitment required.

Lisa Granqvist

Workflow Automation Expert

Expert in workflow automation and no-code tools.

×

Use template

Get instant access to this n8n workflow Json file

💬
Get a free quote today!
Get a free quote today!

Tell us what you need and we'll get back to you within one working day.

Get a free quote today!
Get a free quote today!

Tell us what you need and we'll get back to you within one working day.

Launch login modal Launch register modal