Categories
Python

Writing a chatbot in Python

 

I’ve been experimenting with building a chatbot in Python for the past few weeks, mostly to interact with other hobby project systems of mine that I’ve built over the past few years. It’s a Telegram bot built using python-telegram-bot and I’m pretty happy with my progress.

It started as a way for my girlfriend to be able to add things to our joint shopping list without texting me (and me then forgetting). It does a good job of picking distinct shopping list items out of a message by using data from my personal finance and to-do list systems to compare against a list of around 1,200 items I’ve bought in the past.

It can also interface with my personal finance system to service simple queries:

I maintain separate development and production environments for most of my hobby projects, so the bot can also handle the work of things like deploying changes from one environment to another.

Using some external APIs it can also tell you a joke:

Or give you a (sometimes dubious) recipe: