In previous article, we built the WhatsApp bot to fight fake news! If you missed it you can check it out here. In this detailed tutorial we will see how we can build a bot which will give us some book recommendations and tell us information about a book we want.
Let's just jump into this!
We will be building the WhatsApp bot which will give us more information about the book whose name we will be providing as an input and will also recommend us similar books!
-
A Twilio account --- sign up for a free one here
-
A Twilio whatsapp sandbox --- configure one here
-
Set up your Python and Flask developer environment --- Make sure you have Python 3.
-
ngrok so we can expose our local endpoints so that we can receive incoming webhooks
We will be using goodbooks-10k dataset.
This dataset contains six million ratings for ten thousand most popular (with most ratings) books. There are also:
- books marked to read by the users
- book metadata (author, year, etc.)
- tags/shelves/genres
You can download zipped data from here: https://github.com/zygmuntz/goodbooks-10k/releases
FLASK_APP=app:app FLASK_ENV=development flask run
To test this we'll need to open up a tunnel to our server running on our machine. We will be using ngrok for this. Run this once you have installed ngrok:
ngrok http 5000
This will open a tunnel pointing to port 5000 and will provide us a public ngrok URL which will point to our local application. Now, we have to open the WhatsApp Sandbox in our Twilio console and enter that URL plus the path /sms
into the field labelled When a message comes in
.
Let's send our sandbox number a message with book name and let's see results:
- Book Information
- Book Recommendation
This was an basic intro to how you can create an recommendation system using Twilio WhatsApp API or Messaging API. You can use similar approach to enhance customer experience in your business.