Lawra Chatbot

This project was made in the summer of 2018. The goal was to improve the user experience for people with legal questions. Whenever someone needs help with legal issues it is quite hard to get an answer in human language. Lawra got the idea to create a chatbot so people can just talk to their Google Assistant and get the help they need. On top of this they wanted a website which had the same purpose as the Google Assistant. To find out how this bilingual chatbot works exactly, please read on. You can also test the web version yourself, by clicking the button below. Please be aware this is an ongoing project and bugs may still be present.
Client: LawraDate: Summer 2018Technologies: CSS, Dialogflow, Flask, HTML, JavaScript, Python
The first part of the project was to create a Dutch Google Assistant chatbot which calculated notice periods for the user. So whenever someone was fired or resigned they could ask their Google Assistant how long they were bound to their firm. After some research I found out the best way to build a Google Assistant chatbot was to use Dialogflow since it is owned by Google. I made some test bots in Node.js to get the hang of it and understand how everything works. Because of the complexity of the flow and the need calculations, I switched to my favourite language. Python has a lot of interesting libraries and makes date calculations a breeze. Lawra provided an Excel file with all the rules that needed to be transformed into code. The notice period calculator alone counts more than 3000 lines of code, written and tested in just three weeks. To connect the calculator with the Dialogflow Agent I also wrote an API in Flask. Because of my previous experience with Flask in other projects (be sure to check them all out on this website) this wasn't too hard. But then I hadn't started on the second part of the project yet..
The other part was to make a web chatbot. Dialogflow offers the possibility to embed a chatbot on a website but this looks very basic and has no customisation options. This of course was no option so I did what most programmers do best: Google it. Unfortunately the documentation to make a web chat bot in Flask is very scarce. That's when I decided to make my own documentation for later reference so other people could easily expand the bots I built. To make use of the same Dialogflow Agent I had to research their API and understand OAuth 2.0. Fortunately Google has a nice library to make OAuth 2.0 easier. Aside from making the back-end work, I also took care of the front-end. Lawra sent me a beautiful template and I tried my best to recreate it with responsiveness and all. The whole website runs on Pythonanywhere, which is a useful tool I found during my research. When the basics were done I also added an extension so people could get a summary of their conversation via email, if they so wish. I have also translated the whole bot to English so later on people from whichever background could expand the chatbot without any problems.