Published on

Revolutionizing Book Club Management: How a Telegram Bot Transformed TSBC

Authors
  • avatar
    Name
    Ang Yi Shuan
    Twitter
Telegram bot for The Saturday Book Club

📚🤖 TSBC's Attendance-o-Bot: RSVP hassle-free! Zap details, no more 'I was there!' battles. Join us @thesaturdaybookclub!

Introduction

At The Saturday Book Club (TSBC), our passion for literature is matched only by our dedication to fostering a vibrant community of readers. Founded in 2022, TSBC convenes monthly gatherings where members share insights from the latest non-fiction reads, each session enriched by lively discussions and camaraderie. However, as our club grew, so too did the challenges of managing attendance and book records.

Identifying the Problem

Initially, our attendance and book tracking relied on manual data entry into Airtable, a process riddled with inefficiencies. Each session, facilitators painstakingly collected member names and book titles, only for our designated "data person" to spend hours inputting and cleaning the data. Misspelled names and inconsistent formatting plagued our records, hindering our ability to analyze club trends effectively.

As TSBC expanded, the burdens of manual data management became untenable. With attendance swelling to 20, then 40 participants per session, it was clear we needed a scalable solution to support our growing community.

Enter the Telegram Bot

Recognizing the need for automation, I embarked on developing a Telegram bot, @thesaturdaybookclub_bot, to streamline our club's administrative tasks. Leveraging the python-telegram-bot library and Google Books API, I set out to create a user-friendly platform that would simplify attendance tracking and book cataloging.

Key Features and Functionality

The Telegram bot empowered members to submit attendance and book details effortlessly, reducing the time commitment from hours to mere minutes. By integrating Google Books API, users could retrieve book information quickly, ensuring data accuracy and consistency.

A screenshot of the markup keyboard presented to users of the bot.

Users of the bot are presented with a markup keyboard containing options they can choose from. The options presented will be different depending on the state the user is in.

A screenshot of the user workflow.

A user will typically go through this interaction to submit their attendance.

A screenshot of an admin feature.

An admin user will have additional features shown on their markup keyboard.

A screenshot of the books I have shared in previous TSBC sessions.

I've shared these books in previous TSBC sessions. Have you read any of them?

Challenges and Solutions

Building the bot presented several challenges, from managing user access to optimizing server communication. I implemented a password system to restrict access to TSBC members and employed Levenshtein distance to handle inconsistencies in book data from the Google Books API.

One of the most significant hurdles was optimizing the bot's performance to handle concurrent usage during sessions. To address this, I implemented several optimizations, including setting up a local Bot API Server to reduce latency and switching to webhooks for more efficient updates retrieval from Telegram's servers.

  1. Optimizing Server Communication: In order to enhance the efficiency of server communication for the Telegram bot, I made a significant improvement by setting up my own Bot API Server. Previously, when the bot needed to send or receive messages, it had to go through a server located in the Netherlands, resulting in high latency due to the long distance. By hosting the server locally in Singapore, the messages now stay within the region, reducing the time it takes for data to travel. This optimization greatly improved the responsiveness of the bot, with ping times dropping from 200-300ms to just around 10ms, making the communication process at least 20 times faster.

  2. Implementing Webhooks: As the bot's traffic increased, I realized that the polling method we were using to retrieve updates from Telegram's servers was becoming inefficient. With polling, the bot had to constantly check for new updates by repeatedly querying Telegram's servers, which could lead to delays in response times, especially during periods of high traffic. To overcome this limitation, I decided to switch to using a webhook. Instead of actively querying for updates, a webhook allows Telegram to push updates directly to a specified URL whenever they occur. This approach is akin to having mail delivered directly to your home rather than having to repeatedly check your mailbox. By implementing webhooks, the bot's response times improved significantly, ensuring a more seamless user experience even during peak usage periods.

  3. Proper API Key Integration: Initially, the bot was accessing the Google Books API without proper registration, which meant we were at risk of being rate-limited by Google at any time, as there were no officially published limits for unregistered usage. To ensure consistent access to the API and avoid potential disruptions in service, I obtained an API key and integrated it into the bot's functionality. This API key provides us with defined limits of 100 requests per minute and 1000 requests per day, giving us more control over our usage and ensuring that we can reliably access the Google Books API without running into rate-limiting issues.

Lessons Learned

  1. User-Centric Design: Developing a user-friendly interface was paramount to the success of our Telegram bot. Through iterative testing and feedback, I gained insights into user preferences and pain points, allowing me to refine the bot's features and optimize the user experience. Emphasizing simplicity and intuitiveness ensured widespread adoption among TSBC members, highlighting the importance of prioritizing user needs in software development projects.

  2. Robust Infrastructure: Building a scalable and resilient infrastructure was crucial for supporting the bot's operations, particularly during peak usage periods. The challenges encountered in handling concurrent user traffic underscored the importance of investing in robust server architecture and optimization techniques. By implementing strategies such as local server hosting and webhook integration, I was able to enhance the bot's responsiveness and reliability, demonstrating the significance of infrastructure planning in delivering a seamless user experience.

  3. Adaptability and Problem-Solving: Throughout the development process, I encountered various technical challenges and obstacles that required creative problem-solving and adaptability. From addressing inconsistencies in data retrieved from external APIs to optimizing network traffic for improved performance, each challenge presented an opportunity for learning and growth. By leveraging a combination of technical expertise and resourcefulness, I was able to overcome these hurdles and deliver a robust solution that met TSBC's needs.

  4. Continuous Improvement: The journey of developing the Telegram bot for TSBC highlighted the importance of continuous improvement and iteration. Even after the initial release, ongoing feedback from users and monitoring of system performance informed subsequent updates and optimizations. Embracing a mindset of continuous improvement enabled me to refine the bot's functionality, address emerging issues, and ensure its long-term viability as a valuable tool for the book club.

Conclusion

The implementation of our Telegram bot revolutionized TSBC's administrative workflows, freeing up valuable time and resources to focus on our shared love of reading. As we continue to grow, our bot serves as a testament to the power of technology in fostering community engagement and organizational efficiency.

If you're interested in learning more about our journey or exploring the possibilities of Telegram bot development, feel free to reach out. Together, we can unlock new opportunities for innovation and collaboration in the digital age.