Know The Way

Hua Lun Chua

Researcher
Software Engineer
Technical Writer
Python
Twilio
WhatsApp

A WhatsApp Bot for Tourist

Watch on YouTube

💡 Inspiration

Covid-19 hit the tourism industry hard, which is especially bad for our local economy which has a relatively high dependency on tourism for revenue generation. Furthermore, with the rise of e-commerce, we see increased delivery services and a lot of travel required. As such, it makes sense to have a way to get the best routes for maximum efficiency.

On the other hand, when we are travelling domestically or internationally, we would have various places to visit. Perhaps we would like to go to 5 attractions in a day. In order to achieve this, we would need to plan a route that takes us to the place of interest quickly and conviniently.

We wanted to use Twilio as it would provide the user with easy access to our chatbot via WhatsApp without needing to download any extra software onto their device. We also feel that using a chatbot rather than a form to collect and parse the information makes it more user friendly and be more like a travel companion they can talk to.

🔍 What it does

Know the Way is your travel companion chatbot. It has two main functions to assist travellers and delivery people.

Firstly, the application provides a quick and easy way for users to plan their travel routes, be it for recreational travel or to optimize their delivery schedule.

The route optimization option allows users to select their mode of travel, as well as up to 20 destinations. The chatbot also asks for the country in which the locations are in, to increase the accuracy of the results produced.

The user is then provided with a list of the locations, starting from the first location listed, in the optimal order to reduce travel time. The user is also provided with the travel distances and times for each leg of the journey and is given the option to receive additional photos.

The Second main function is the destination suggestions function. The user can ask our chatbot for suggested destinations for a given location, and the bot will find and list a few to help get them started with trip planning.

🔧 How we built it

We built the main function of the application around Twilio, creating a WhatsApp chatbot with a Flask backend to handle the data retrieval and processing.

The Flask backend was hosted using a Google Compute Engine instance.

We used Google Directions, Maps Static and RouteXL API to get the optimised route paths and an accompanying map image.

We used Google "Discover More Places" Results API by SerpApi to create a function that returns the best attractions in an area.

Lastly, ngrok was used for the webhook to Twilio and serves as a tunnel from

localhost

.

🏃‍♂️ Challenges we ran into

Figuring out how to integrate a multi-step message into the chatbot logic without losing the information between the function calls.

It was quite challenging to debug and test our chatbot. As we were using the free tier plan for the APIs used, we were given a limited number of requests. As such, we had to be careful and properly check the code before testing.

Trying to get the images from google maps with the marked locations for the different points on the route to give the user a visual summary of the places they were going to visit.

Figuring out how to input login information for the RouteXL API into a Python request.

🏅 Accomplishments that we're proud of

Proud of building a Twilio based chatbot that has multiple different inputs that it can process, and improved invalid message handling compared to our previous attempt.

We are also proud of being able to complete the whole project despite starting the hackathon late.

For Google cloud, we are happy to have figured out how to use their APIs for their location-based services, such as generating snapshot maps which we could then send to our users via the chatbot.

🧠 What we learned

Python is not able to affect variables in the outer scope, so we had to learn a way to work around this limitation when trying to structure our Flask application. This led to us learning how to use JSON files with python to easily store and retrieve data, making our Flask app to be usable for multiple users by storing their data separately.

For our team member that did the coding for the Flask application this round, she previously did not work with the Flask application for Twilio and had to learn that newly for this hackathon.

We also learned how to use some of Twilio's cooler features, namely sending images to provide more context and visual representation of the locations.

We learned to use new APIs from SerpAPI as well to add additional information for our chatbot.

We learned to use various Google APIs to get directions, relevant information and generate a map image for better reference.

We learned about authentication and authorization in APIs and why is it important for security.

⏭️ What's next for Know the Way

We want to add more features to the chatbot to make it more user friendly, and to make it more interactive and engaging beyond information provision.

We also want to provide the user with more information on the destinations suggested for them to visit.

Gallery

Partner With Hua Lun
View Services

More Projects by Hua Lun