Happy Curry'?in with Epicurean. (Or how chat-bots solve practical problems.)

Happy Curry'in with Epicurean. (Or how chat-bots solve practical problems.)

We like to eat healthy by cooking at home. Picking up fresh ingredients on the daily commute is a time-saver and avoids waste. But we are often guessing what's in the pantry at home and what we need to get to plan the day's meal. What if we had a robot do the due-diligence and make a recommendation, wouldn't that be great?!

No alt text provided for this image

Mobility is key. But building an app for the mobile app-store involves software development effort beyond a weekend project. A better approach is to use an existing platform and fit it out to the requirement. Sounds like a job for a chat-bot!

Bots are just special accounts that subscribers can interact with. Any subscriber can create a bot. A bot can respond to text messages and commands. However, a bot can never initiate conversations with users. (Otherwise the Universe would be awash with spam.)

No alt text provided for this image

I picked Telegram to implement a chat-bot. As an app, Telegram is an instant messaging software like WhatsApp. Unlike WhatsApp, Telegram has an awesome API. And unlike WhatsApp, the platform actively encourages bots. And unlike WhatsApp, it isn't owned by Facebook. ;-)

The python-telegram-bot project offers the means to program a bot in Python. Aside from support for the base API that a developer would expect to find, the telegram.ext sub-module offers cool features in modern programming style for automation with queues, filters and handlers. It is a fantastic way to program in the DRY style advocated in The Practical Programmer and a natural choice for my Epicurean bot.

The Spoonacular API with ontology for effective querying of a comprehensive database of recipes.

For querying recipes, I selected the Spoonacular Food API. The free account works on a points system with a fixed daily quota. Points are deducted per query made depending on the API end-point used. The Spoonacular API offers access to a comprehensive database of world-wide cuisines with smart querying based on Natural Language Processing (NLP).

So after a weekend of programming in the COVID-19 curfew, here is what the product looks like. If you have Telegram on your phone, strike up a chat with Epicurean a.k.a. @epicurryin_bot. Type /start in the message box and follow instructions. You don't even have to say hello!

Here is a snap-shot showing Epicurean's recommendations in Telegram chat based on what's in my fridge today.

Snapshot of the Epicurean bot showing recipe cards.

My bot will build a recipe for you based on the ingredients you provide and tastefully present it as a recipe card. Here is a sample recipe card I got for dal (Indian lentils), onions and carrots. It is pretty impressive how effortlessly the Spoonacular API uses NLP to bridge-over different languages and culinary idioms.

A recipe card for lentil soup showing NLP capabilities of Spoonacular API.

And it even tells a dirty joke or two! Send a /joke command to get a random joke when the kids are not around.

A snapshot of Epicurean bot showing a random joke.

So what's next? I plan to enhance the bot to make the engagement style more conversational. A little further down the road, I want to merge this project with another side-project I have going on to identify food items in the refrigerator using computer vision on a Raspberry Pi with a Picamera. Then, our fridge will chat with us about our meal plan. Tasty!

Happy curry'in with Epicurean!

References:

  1. Take a look at my code posted in this Github repo with a Jupyter notebook that has step-step instructions to build your own bot.
  2. The Spooncular API has excellent docs.
  3. A vibrant community has developed around Telegram in Python to help each other and share examples and code snippets.
  4. RapidAPI presents a browser-based interface to test API end-points - a great way to become familiar with APIs and their usage. You can search their collection of food-related APIs or try your hand at Spoonacular APIs.
  5. The Telegram bots overview has general information about bots and to find out what they are capable of.
  6. The Pragmatic Programmer by Andrew Hunt and David Thomas is one of the most influential computer programming books of all time.

要查看或添加评论,请登录

社区洞察

其他会员也浏览了