FoodCoach-bot, the chatbot that helps you keep track of your food intake

A chatbot developed with Dialogflow, Chatbotstrap, and the official Swiss food composition database

qathom
Empathic Labs
4 min readSep 30, 2020

--

FoodCoach-Bot

Nowadays databases are everywhere in our business environment. Not only are they fed by many different professional software but also more and more by external data sources. Enterprise challenges push to an increasing data consumption in many application fields so, it’s starting to be interesting to find a reason to develop self-services chatbots frameworks in order to empower citizen developers across corporations. These low code solutions inspire to reduce hard coding and focus on added value development such as training phrases, logic flow, human interactions, bot’s answers and reactions.

For this purpose, a chatbot was developed in the HES-SO Master in Switzerland in order to help nutritionists to compose a healthy menu. This first version was developed in 2 working weeks and aims to reduce calculation time spent by nutritionists in their job to evaluate nutritive values per dish.

It’s based on valeursnutritives.ch datasets and was developed through Dialogflow and improved by end-user feedbacks with Chatbotstrap. Finally, this prototype is deployed in AWS services (by using the serverless framework).

Enriching data for our chatbot

We have downloaded the data sets (available in English, French, German and Italian) in Excel format from valeursnutritives.ch. The columns available are food name, category, nutrient values, etc.

Tokenization: We have defined a list of tokens associated with each food item to expect good returned results.

Data structure: We moved from Excel input data, generated the tokens and exported the data in JSON format to improve read speed.

Search: We used a library called lunr.js to perform approximate term matching (fuzzy searches).

Using Dialogflow

Dialogflow is a powerful tool to create conversational interfaces. If you don’t already know it, you can read more here.

In summary, Dialogflow provides a simple and user-friendly interface for creating 2 main concepts: entities and intents.

  • Entities are extracted when the user sends an expression or message. This allows for example to identify a first name in a sentence or the name of a city. The webhook query contains these entities as parameters.
  • As for the intents, they are used to define the user’s intentions. An intention A can result in another intention B. In this case, they are combined to create a more advanced conversation.

Overall architecture

Our website includes the Dialogflow’s widget. This plugin is used to generate the user interface for end users to interact with our agent. Dialogflow can be seen as a middleware between the website (visible to the user) and the webhook. In fact, Dialogflow organizes the user message, the detected intent and other information and sends this payload to the webhook. Then, the webhook is sending back the data fulfillment or expected bot’s reply.

Architecture of the chatbot

Agent intents and examples

The user defines a daily target, searches for meals and drinks, adds items by typing them and receives the final result with KCAL details.

Below we can see several intents with positive and negative responses from the chatbot. Colors were used to represent negative responses in red and positive responses in green.

Welcome message and example of interactions when the user wants to set a KCAL target.
Example of interactions when the chatbot returns search results.
Example of interactions when the chatbot tries to process items.
Example of returned response when the user asks for the summary

Conclusion

In this article, we have presented the main steps of our project to obtain the final result of our conversational agent. The focus has been on entity extraction, intent recognition and natural language processing by using Dialogflow and a custom webhook.

This chatbot prototype was developed by Anthony Meizoso and Thomas Blanc. Thanks for reading! You can test the demo of the bot (in French or English) here:

To know more about NLU for chatbots, don’t hesitate to read another article of Empathic Labs about this exact topic here below:

--

--

qathom
Empathic Labs

Enthusiastic full-stack professional with a passion for designing user experiences.