This weekend as a side project I created a simple Facebook chatbot, that notifies latest jobs posted on starupgoa.org
Goa is a land of Sea, Sand and Startups and starupgoa.org is one place where most of the IT jobs are posted.
The jobs on starupgoa.org are displayed like below.
After looking in the network tab in chrome, I found the Ajax call that fetches jobs.
The post will be very big if I start to explain the code line by. So I will quickly tell how the bot works.
- Initially, I have fetched the latest 100 jobs from the website and have stored it in the database [used mlab as database].
- When a Facebook user clicks on Get Started button, Bot captures that user's id and store it in the database. It is used to send the push notification.
- When user types
latest jobsin chat, bot fetches the latest five jobs from the database and displays it to the user.
- I Wrote a cron job using node-schedule that runs every day at 1 AM and fetches the latest jobs from the website and stores it in the database.
- If during cron job new jobs are fetched then bot send the push notification to the user with new Job.
- cheerio - Html Parser
- winston - Logger
- node-schedule - To run cron job
- request - Make API call
Currently the bot is in development mode and is not available for everyone.
If you have suggestions to improve the bot please do comment.
I want to write unit tests for this bot, but I am not getting how to start with writing unit tests. If someone can help me with it,I will be really grateful.
This is a simple bot and I hope It will be helpful to the IT job seekers in Goa.