A Talkative Bot for Managing a Choir

"I feel extraordinarily enchanted to speak with you again." - Imagine a Telegram bot that not only eases administrative tasks, but also delights with its whimsical personality. As our choir grew, questions about absent members, upcoming performances, and keeping track of the rotation of requested songs became increasingly cumbersome, so I set out to create a Telegram bot that would help us with these tasks. Anticipating the typical robotic behavior of similar chatbots, I wanted to make every interaction feel fresh and engaging by dynamically generating each and every message the bot sends.

The foundation of the bot was built using the python-telegram-bot package, which gave the bot access to our choir's group chat, from which it also tracked and updated the membership list. Using this package, the bot offered commands to register an absence, enter a reminder, schedule a gig, or start the Wish Song iterator - a round-robin alphabetical rotation in which each choir member took turns choosing a song at the end of rehearsal.

Central to the bot's character, however, was a context-free grammar of message structures, synonyms, and phrases that the bot used to generate its messages. I decided to give the bot an overwhelmingly friendly, sometimes even verbose personality, and certainly had a lot of fun writing the grammar file. To parse the grammar file and generate messages, I used and extended a context-free grammar sentence generator from another GitHub repository. Below is a translated snippet of the bot's originally German grammar:

meeting-a-member: greeting get-to-know
;

greeting: a-greeting " " name " " exclamation-ending
;

a-greeting: "Hello" | "Hi" | "Hey" | "Hey there" | "Hey hey" | "Hi there"
;

get-to-know: "I " an-act-of-joy " to-get-to-know-you."
| "It's " positive-description " that " happens-during-greeting "."
| "How " positive-adjective " that " happens-during-greeting "."
| capitalize positive-description " that " happens-during-greeting "."
;

an-act-of-joy: "am glad " intensity-particle " "
| "find it " positive-description " "
| "am " intensity-particle positive-feeling " "
| "feel " intensity-particle positive-feeling " "
;

positive-description: intensity-particle " " positive-adjective
| positive-adjective
;

positive-adjective: "super" | "top" | "terrific" | "beautiful" | "wonderful" | "great" | "cool" | "rad"
;

In addition to these core functions, the bot also had a number of less serious functions. For example, the bot would extract random, cheesy friendship sayings from a website and then post them as a greeting in the group chat whenever a new member joined. Similarly, when a member left the group, the bot would bid them farewell with a randomly selected message from the same website. Finally, the bot handled quirky edge cases with finesse, privately admonishing absent members who missed their turn to wish for a song during rehearsal, or even playfully expressing "illness" to the group on rare occasions.

The choir members responded positively to the bot. I remember one incident when a bug in the website parsing caused the bot to send incomplete greetings to new members. The choir members, demonstrating their connection to the character of the bot, eagerly completed the messages themselves.

Regarding the project's architectural decisions, I chose Python's pickle as a simple solution for database persistence, underestimating the complexity the project would develop. In retrospect, a more robust database solution such as SQLite would have been preferable. The source code of the bot is available for exploration, although the grammar itself is currently only written in German.