Tutorial: Quiz Bot
Build an interactive quiz that tracks scores and shows results.
What We're Building
A fun quiz bot that:
- Asks multiple-choice questions
- Tracks correct answers
- Shows the final score
- Saves high scores
Step 1: Start the Quiz
-
Add a Command Trigger for
/quiz -
Add a Set Variable to initialize score:
flow.score=0
-
Add a Send Message:
🎯 Welcome to the Quiz!
You'll get 3 questions. Let's see how you do!
Ready?
[▶️ Start Quiz]
Step 2: Question 1
- Add a Send Message with inline buttons:
❓ Question 1/3
What is the capital of France?
[🇬🇧 London] [🇫🇷 Paris] [🇩🇪 Berlin]
Callback data: q1_london, q1_paris, q1_berlin
-
Add a Message Trigger for callbacks starting with
q1_ -
Add a Condition:
- Expression:
ctx.Input == "q1_paris"
- Expression:
-
If True:
- Add 1 to score:
flow.score + 1 - Send:
✅ Correct! Paris is the capital of France.
- Add 1 to score:
-
If False:
- Send:
❌ Not quite! The answer was Paris.
- Send:
Step 3: Questions 2 & 3
Repeat the pattern:
Question 2
❓ Question 2/3
What is 7 × 8?
[54] [56] [64]
Correct: 56
Question 3
❓ Question 3/3
Which planet is known as the Red Planet?
[Venus] [Mars] [Jupiter]
Correct: Mars
Step 4: Show Results
After all questions:
Results Message:
🎉 Quiz Complete!
Your score: {{flow.score}}/3
{{flow.score == 3 ? "🏆 Perfect score! You're a genius!" :
flow.score >= 2 ? "👍 Great job!" : "📚 Keep practicing!"}}
Play again? [🔄 Restart]
Step 5: Save High Score
- Add a Condition:
flow.score > var.high_score - If True:
- Set
var.high_score={{flow.score}} - Add message:
🌟 New high score!
- Set
The Complete Flow
Enhancements
Randomize Questions
Store questions in a list and use Random to pick:
[
{"q": "Capital of France?", "a": "Paris", "options": ["London", "Paris", "Berlin"]},
{"q": "7 × 8?", "a": "56", "options": ["54", "56", "64"]}
]
Time Limits
Add urgency with a timer message:
⏱️ You have 10 seconds!
Leaderboard
Track top scores in shared variables:
🏆 Leaderboard:
1. @alice - 10 points
2. @bob - 8 points
3. @charlie - 7 points
Your rank: #5
Categories
Let users choose quiz topics:
Choose a category:
[🌍 Geography] [🔢 Math] [🎬 Movies] [🎵 Music]
Tips
Make It Fun
Use emojis, celebrate correct answers, and keep a playful tone!
Progressive Difficulty
Start easy, get harder — keeps users engaged.
Share Feature
Let users share their scores on Telegram.
Next Steps
- Referral System → — Grow your bot
- Weather Bot → — API integration