Automation: Building a Reservation/Waiting List Text-Bot For My Weekly Poker Games


Every week, I host a poker game at my apartment. I usually have anywhere between 5 to 8 players at my table. The issue? People often decide to come, or cancel last minute and I am constantly texting people back and forth the day of the game to make sure I have a full table.

I decided to build a bot that could handle inviting my friends to my apartment, notify me of who is coming, and place extra players on waiting lists in case people cancel last minute. In the event that there is a cancellation, the bot will take the first person off the waiting list and re-invite them.

Furthermore: I made use of the Iphone’s automation features to send commands to the bot such as adding and removing people from the guest list, and requesting a list of attendees from the bot.

Technologies Used:

  • Python
  • Twilio: Messaging service that allows you to send texts via python
  • Flask: web server framework for receiving text messages and handling responses.
  • Iphone: I used the new shortcuts feature in my iphone to trigger commands on the Twilio server

Setting Up Twilio:

The first task is to go to and create an account. You’ll have to request a number from the website. Once you have completed those steps navigate to the console and copy your Account SID and ‘Auth Token’.

Your next step will be to install the Twilio helper package in python. This can be done by simply navigating to your terminal or command prompt and typing ‘python’ and then


Sending A Message Via Python:

Before we get our hands too dirty, let’s make sure we’re able to send a message using Twilio.

Note: you’ll have to confirm your number in Twilio before it will allow you to send a message.

Intercepting A Message and Handling Responses:

Now that we have the capability to send a message, let’s try intercepting one.

Adding this code will allow you to receive messages. Note: you will have to write your own “handleMsg(body,number)” function which will handle the control flow of how your bot will respond. This is what mine looks like:

The first few conditions are commands that can only be processed if a text is sent from my number. This allows me to initiate the bot to send invites to my guest-list, or notify me of relevant information. The ‘Admin’ variable is a global variable with my number stored.

Below is the code to all my helper functions included in the handleMsg function:

Maintaining The Contact List:

For my guest list, I decided to port my contacts to a csv. I then wrote a function that reads the csv and adds every contact to a dictionary containing their number and name.

I then used the following function to send out invites:

Handling Waiting List and Confirmations:

Below are the functions used for the following operations

  • Handling a cancellation
  • Handling a confirmation

Notice that in the handleCancellation(number) function, another invite is sent to the first person to be taken of the waiting list. Also: it is worth mentioning that I had to define the function “removegrepl(number, list)” which removes any number containing the supplied number as a substring.

This is a key feature as there will often be discrepancies with regards to how the flask server is reading an atendees number and how I recorded it into a spreadsheet.

Triggering Scripts With Iphone:

Now for the fun part. I made use of the Shortcuts app included in the new IOS update to send an automated trigger to my flask server. This way, I can press a button on my iphone and it will automatically send the desired commands to my bot.

The possibilities are virtually endless as you can add any number of control commands to your server.

Wrapping It Up:

Using Python, Twilio, and Flask, we created an end to end application that allows for both user access as well as server administration through text-based keyword commands. The specific use-case has automated the entire process of having to invite people to my poker game, deal with re-inviting others when certain players cancel, and notifying extra players of how many people are ahead of them on the waiting list. Additionally, my server is able to notify me of my guest list and gives me the ability to modify the guest list itself all from my phone.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store