What's your new year's resolution? For many, these resolutions involve healthy eating and well-being. One of the most popular ways to approach this resolution is to track calories and create food diaries. Plenty of apps exist to track calories and monitor your food intake, such as MyFitnessPal or LifeSum. However, these apps can take some work, and often they are bloated with ads and articles that often aren't all that useful. It becomes a chore to take charge of your nutrition, and as a result, we often fall off the wagon when it comes to our own health. For that reason, we were inspired to create a simple interface that can simply be called with an "Ok Google" or a Facebook message: NutriBot.
What it does
When you say hello to NutriBot, you activate your own personal calorie-tracking assistant. You can tell it what you had for lunch, and it will respond immediately with a rundown of the calories and macros you just consumed. It will add it to your daily food diary, and help you stay on track. Try it out: tell your NutriBot that you had a peanut butter sandwich on whole wheat bread for a snack, and it'll tell you that you just consumed 257 calories, with 45 calories of protein, 120 calories of carbs, and 92 calories of fat.
How we built it
We built our chatbot using Dialogflow, with backend written in Node.js. With the help of some mentors and some solid teamwork and problem-solving, we were able to learn all about Dialogflow and Firebase API, and connect our chatbot to the database from Edamam for all of the food information that we needed. Dialogflow's API allowed us to seamlessly integrate our chatbot with Facebook Messenger and Google Assistant.
Challenges we ran into
All of our team is very new to developing with Node.js and using different APIs, so it was a pretty steep learning curve when it came to tackling the integration of technologies that were needed for this project. We struggled at first with figuring out how to properly connect our chatbot system with Facebook Messenger. After a lot of trial-and-error, we found that the tutorial we were following was completely off-base; we were trying to connect to a proxy server when we should have been using the callback URL that was provided to us in Dialogflow. Another challenge we faced was in referencing the external API from Edamam from Dialogflow. None of us even knew what webhooks were, let alone how to use one. After following a half dozen different tutorials and recruiting some help from a friend, we were able to deploy a Heroku app and set up an endpoint to connect to our external API from Edamam. Unfortunately, we weren't able to get too much further than that. We struggled with setting up the communication between Dialogflow and Heroku, and we weren't able to get our chatbot up and running as we wanted it to.
What we learned
We learned a lot about working with Node.js, Dialogflow, and Heroku. It was pretty difficult to learn how to set up the back end of the chatbot, especially when connecting to an external API, but we were able to get further than we expected. Most importantly, we learned that getting help from mentors is invaluable when you don't know what you're doing. It was awesome to see how willing people were to help, with just a few messages in the Slack channel, or even just flagging people down as they were walking around. We are extremely grateful for their help, and we learned a lot from our mentors!
What's next for NutriBot
Of course, we ran out of time this time to get our NutriBot fully functioning, so we need to work on that. Otherwise, we would love to be able to integrate NutriBot with more different platforms, such as Twitter, Skype, or Amazon Alexa, and be able to reach more people in the most convenient way possible for them. In addition, with the time that we were given for this hackathon, we weren't able to add in as much functionality as we would have liked, such as being able to have our chatbot understand more complex requests or create more comprehensive food diaries and profiles. We didn't make as much use of the Training and Context features of Dialogflow as we could have, and we're excited to see how far we can take our NutriBot.