TL;DR
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.
To get the experience in javascript,es6, and MongoDB, I chose to build this bot with Javascript.
I found this awesome article on Hackernoon on
How to Build a Facebook Bot App Using Node.js
The post will be very big if I start to explain the code line by. So I will quickly tell how the bot works.
How bot works in general
- 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 jobs
in 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.
Technology Stack
Major Node Packages Used.
- Bootbot - JavaScript Framework to build Facebook Messenger's Chat bots.
- cheerio - Html Parser
- winston - Logger
- node-schedule - To run cron job
- request - Make API call
Demo
Currently the bot is in development mode and is not available for everyone.
Suggestions are welcome
If you have suggestions to improve the bot please do comment.
Need Help
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.
Conclusion
This is a simple bot and I hope It will be helpful to the IT job seekers in Goa.
Top comments (4)
That's really awesome. Are you only going to keep it for Goa, or you have plans to extend it nation wide.
As of now, I have not thought of extending it nationwide. Since the bot depends on startupgoa to fetch jobs in Goa. In case I find some API to retrieve Latest Jobs Nationwide, I will surely try to extend it Nationwide.
Can you create a seperate section in this post for the technology stack you are using?
I have updated the post with technology stack used to develop the bot.