If you don't know what Chatible is, it's a Messenger bot that allows you to chat with someone random. I love its idea, but I don't want to chat with a total stranger. It would be great if we have something in common. Studying at the same school sounds good, so I cloned Chatible for my school, which I call PTNK Chatible (PTNK stands for my school name).
Demo
Currently only Vietnamese is supported. English will be added soon.
Source code
PTNK Chatible
Chatible clone written in TypeScript, based on Node, Express and Mongo
Demo: https://m.me/ptnkchat
Basic instruction
- Deploy to Heroku using the deploy button.
- Create a cluster on MongoDB Atlas. Whitelist IP addresses.
- Create an app on Facebook. Install Webhook. Get app secret and tokens.
- Set Heroku's
Config Vars
. Check here to know which variables you need to set. - Enjoy!
Features
- Admin dashboard (code)
- Pair by gender (e.g. male with female)
- Send cute dog/cat pictures
- Customizable message templates
- Cache database in memory to increase performance
- Developed with performance in mind
Planned features
- Allow editing profile via Messenger Webview
- Limiting rate of requests sent out to avoid being converted to high-MPS page
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Credit
- Nguyen Xuan Son (a.k.a Nui or @ngxson) for Chatbot CHN on which this project was originally based
- Leβ¦
How I built it
PTNK Chatible is written in TypeScript, run on Node.js.
express is used to handle webhook events from Facebook.
phin is used to send messages to Facebook. I have tried many HTTP clients and found that phin suits me best. It's lightweight, fast, and supports async/await.
The database is the most interesting thing. Data is stored in MongoDB Atlas. mongoose is used to interact with MongoDB Atlas. However, MongoDB Atlas is slow. To work around this, I store the entire database in megahash, a super-fast C++ hash table with wrappers for Node.js.
I have plan to switch to a proper cache module. I'm considering node-cache.
For deployment, I use Heroku Hobby Dyno from GitHub Student Pack.
Final Thoughts
I want to express my gratitude to GitHub and Heroku. This project will be much harder to complete without them.
Top comments (0)