This is a messenger chatbot made for BUTEX(Bangladesh University of Textiles) to deliver study materials 24x7
Moreover, this bot has casual talking abilities and other functionalities
- Javascipt
- NodeJS(express)
- Messenger Platform
-
The bot structure was based on the official documentation provided on facebook messenger platform. Official Documentation
-
The
chatbotController.js
located insrc/controllers/
is the heart of this bot. this file alone handles all the messages and replies accordingly -
Keywords are located in the
src/controllers/keywords
-
Flows are located in the
src/controllers/flows
-
The bot matches keywords and sends specific flows
1. Word Detection: I've made two function to match keyword -
1. wordIncludes(arrayToMatch, received_message) : finds just match
2. wordIs(arrayToMatch, received_message) : finds exact match
2. Randomizer : randomPicker(arrayToRandomize)
3. Magic Function 😂 : magicFunc(sender_psid, flowToSend)
This function was a technical breakthrough
4. Block genrators: Facebook's graphql has specific format to send objects, you can't make error here, the text messages, images, buttons etc whatever the bot sends is an object, so I made generators to genarate block of objects for texts, image, button etc. Few examples -
1. textBlockGen("Pass texts here")
2. imgBlockGen("Image URL")
3. groupedBtnBlockGen(headerText, BtnObjArr)
- Web URL Buttons: webBtnBlockGen(title, url)
- Flow Buttons: webBtnBlockGen(title, payload)
Feel free to clone this repo for your own projects or contribute to this project 😃