Akinator Bot: Play the Ultimate Guessing Game on Telegram

Published on
Arnab Mondal-
5 min read

Overview

What is Akinator ?

Akinator is a computer game and mobile app by French company Elokence. During gameplay, it attempts to determine what fictional or real-life character the player is thinking of by asking a series of questions. It uses an artificial intelligence program that learns the best questions to ask through its experience with players. The app was released on 29 November 2007.

image

Akinator on Telegram

For this project, I created a Telegram bot that replicates the Akinat or experience using Python and the PTB (python-telegram-bot) library, combined with MongoDB Atlas for user data storage.

The bot offers users the ability to:

  • Think of a character and answer a series of questions posed by the bot.
  • Track and store user progress, including correct and incorrect guesses.
  • Switch between child mode and regular mode for appropriate content

You can explore the source code of the project on my GitHub.

Key Features

  • Interactive Gameplay: Users are presented with questions and prompted to respond, just like in the original Akinator game.
  • User Tracking: The bot saves user information, including username, total guesses, correct guesses, and unfinished sessions. This ensures a seamless experience, even after breaks in play.
  • Group Integration: The bot can be used in groups, offering multiplayer capabilities.
  • Language Support: Users can select their preferred language for a customized experience.

Here's how the user data is handled and stored in MongoDB. I leverage the pymongo package to interact with the database.

Commands

The bot supports the following commands:

  • /start: The /start command is the entry point for interacting with a Telegram bot. When users send this command to a bot, it typically triggers the bot to provide a brief description, introductory message, or a set of instructions to guide users on how to use the bot's features and functionality. It serves as a starting point for users to explore and engage with the bot's services.

image

  • /play: The /play command is used to start a game of Akinator with the bot. Akinator is a popular online game where players think of a character, and Akinator tries to guess who that character is by asking a series of questions. The /play command initiates a new game session, and the bot will interact with the user by asking questions and making guesses until it correctly identifies the character or gives up. It's a fun and interactive way to challenge the bot's guessing abilities and entertain yourself

To be noted - When you send the /play command without finishing the last game, the bot deletes the previous game message. This is done to reduce the load on the bot and ensure a cleaner chat experience for users. This feature helps keep the conversation tidy and prevents clutter from multiple ongoing game sessions.

For groups - In group chats, when multiple users are playing the game, they can only interact with their own game sessions, which are created using the /play command initiated by them. Other users in the group cannot interact with or influence someone else's ongoing game session. This ensures that each player's experience remains independent and private within the group, without interference from others.example:

image

  • /me : The /me command provides users with a quick way to access their personalized profile within the bot. It displays essential information about the user's interaction with the bot, including their name, username, user ID, selected language for the game, child mode status, and various game statistics such as the total number of guesses, correct guesses, wrong guesses, unfinished games, and total questions answered. This command allows users to review their Akinator game progress and preferences at a glance

image

  • '/leaderborar' : The /leaderboard command grants users access to the Akinator bot's leaderboard feature. With this command, users can view the top performers in different categories related to the Akinator game. These categories typically include "correct guesses," "total guesses," "wrong guesses," and "total questions answered." The leaderboard offers a competitive aspect to the game, allowing users to see how they compare to others in the community. It's a fun way to challenge oneself and strive for the top spot in various game-related metrics.

image

Conclusion

The Akinator bot on Telegram offers a fun and interactive experience for users who enjoy playing guessing games and testing their knowledge. By leveraging the PTB library and MongoDB Atlas, I was able to create a seamless and engaging gameplay environment that tracks user progress and preferences. The bot's ability to handle multiple game sessions, store user data, and provide personalized experiences makes it a valuable addition to the Telegram platform. Whether you're playing solo or challenging friends in group chats, the Akinator bot is sure to provide hours of entertainment and excitement. Give it a try and see if you can outsmart the bot!