{"id":19522667,"url":"https://github.com/lintangwisesa/express-bottender-messenger-mongodb","last_synced_at":"2025-07-14T10:03:53.171Z","repository":{"id":40766657,"uuid":"267996938","full_name":"LintangWisesa/Express-Bottender-Messenger-MongoDB","owner":"LintangWisesa","description":"Facebook Messenger chat-bot on Express.js. Chats \u0026 sessions are saved on MongoDB.","archived":false,"fork":false,"pushed_at":"2023-01-06T07:24:44.000Z","size":3599,"stargazers_count":10,"open_issues_count":18,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-26T09:35:20.138Z","etag":null,"topics":["bottender","chatbot","express","facebook-messenger","mongodb","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LintangWisesa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-30T02:46:20.000Z","updated_at":"2023-06-12T03:48:30.000Z","dependencies_parsed_at":"2023-02-05T15:16:02.280Z","dependency_job_id":null,"html_url":"https://github.com/LintangWisesa/Express-Bottender-Messenger-MongoDB","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LintangWisesa/Express-Bottender-Messenger-MongoDB","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LintangWisesa%2FExpress-Bottender-Messenger-MongoDB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LintangWisesa%2FExpress-Bottender-Messenger-MongoDB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LintangWisesa%2FExpress-Bottender-Messenger-MongoDB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LintangWisesa%2FExpress-Bottender-Messenger-MongoDB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LintangWisesa","download_url":"https://codeload.github.com/LintangWisesa/Express-Bottender-Messenger-MongoDB/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LintangWisesa%2FExpress-Bottender-Messenger-MongoDB/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265276527,"owners_count":23739219,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bottender","chatbot","express","facebook-messenger","mongodb","nodejs"],"created_at":"2024-11-11T00:40:14.203Z","updated_at":"2025-07-14T10:03:53.135Z","avatar_url":"https://github.com/LintangWisesa.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![simplinnovation](https://4.bp.blogspot.com/-f7YxPyqHAzY/WJ6VnkvE0SI/AAAAAAAADTQ/0tDQPTrVrtMAFT-q-1-3ktUQT5Il9FGdQCLcB/s350/simpLINnovation1a.png)\n\n## __Express.js, Bottender.js, Facebook Messenger \u0026 MongoDB__\n\n- Project started: __Saturday 30/05/2020__ at __8.30 AM (GMT+7)__.\n- Project finished: __Sunday 31/05/2020__ at __8.02 AM (GMT+7)__.\n- Created using _Express.js, ngrok, Bottender.js, Moment.js, MongoDB \u0026 Messenger Webhook_.\n\n\n\u003chr\u003e\n\n### __A. Result__\n\n1. __Facebook Messenger Bot__\n\n    The chatbot can handle a simple task. When a user start a conversation \u0026 says _\"Hi\"_ or _\"Hello\"_, it will answer _\"Hello World!\"_. When a users says something randomly, it will ask for user's name, user's birthday \u0026 offer to calculate how many days till user's next birthday.\n\n    \u003cimg src=\"./img/a.png\"\u003e\n\n2. __Data Stored on MongoDB__\n\n    Everything is stored on MongoDB database named ```bottender```, which has 2 collections: ```sessions``` \u0026 ```chats```. Every latest user's sessions is stored on ```sessions``` collection, while every received messages is stored on ```chats``` collection.\n\n    \u003cimg src=\"./img/e.png\"\u003e\n\n3. __REST API__\n\n    It also has REST API that can be used to access all received messages, access single chat by ID (MongoDB ID) \u0026 delete single chat by ID (MongoDB ID).\n\n    - __GET ```/messages```__: show all received messages\n\n        \u003cimg src=\"./img/b.png\"\u003e\n\n    - __GET ```/messages/{id}```__: show single message by MongoDB id\n\n        \u003cimg src=\"./img/c.png\"\u003e\n\n    - __DELETE ```/messages/{id}```__: delete single message by MongoDB id\n\n        \u003cimg src=\"./img/d.png\"\u003e\n\n\u003chr\u003e\n\n### __B. Instructions__\n\n1. __MongoDB Set Up__\n\n    Activate your local MongoDB server then open MongoDB shell or its GUI (MongoDB Compass). I prefer use MongoDB shell. Create a database names ```bottender``` with 2 collections inside: ```sessions``` \u0026 ```chats```. To activate MongoDB server execute:\n\n    ```bash\n    $ cd C:\\Program Files\\MongoDB\\Server\\4.2\\bin\n    $ mongod\n    ```\n\n    MongoDB server has activated. Open new terminal \u0026 execute these command to activate MongoDB work shell, create database, database user \u0026 collections:\n\n    ```bash\n    $ cd C:\\Program Files\\MongoDB\\Server\\4.2\\bin\n    $ mongo\n\n    \u003e use bottender\n    \u003e db.createUser({user:\"YOUR_USERNAME\", pwd:\"YOUR_PASSWORD\", roles:[\"readWrite\",  \"dbAdmin\"]})\n    \u003e db.createCollection('sessions')\n    \u003e db.createCollection('chats')\n    ```\n    \n\u003chr\u003e\n\n2. __Clone \u0026 Set Up Project__\n\n    Simply clone this project from github then install all dependencies needed:\n\n    ```bash\n    $ git clone https://github.com/LintangWisesa/Express-Bottender-Messenger-MongoDB.git\n    $ cd Express-Bottender-Messenger-MongoDB\n    $ npm i\n    ```\n\n\u003chr\u003e\n\n3. __Set Up ```mongo.config.js```__\n\n    On project root, open ```mongo.config.js``` then edit the MongoDB url line with your MongoDB user, password \u0026 database.\n\n    ```javascript\n    module.exports = {\n        url: `mongodb://YOUR_USERNAME:YOUR_PASSWORD@localhost:27017/bottender`,\n    }\n    ```\n    Save it.\n\n\u003chr\u003e\n\n4. __Connect to Facebook Messenger__\n\n    To complete our Messenger connection, we have to find these values:\n    \n    - __Messenger Page ID__\n    - __Messenger Access Token__\n    - __Messenger App ID__\n    - __Messenger App Secret__\n    - __Messenger Verify Token__\n\n    To do that, make sure you have an active Facebook Page then signup/login to [Facebook for Deveopers](https://developers.facebook.com/). Create an application by click __My Apps__ =\u003e __Create App__. Click __Set Up__ button on Messenger \u0026 search for those 5 values (__*Note:*__ you can set __Messenger Verify Token__ to any text or simply insert your application name).\n    \n    After that, back to your project directory \u0026 create an ```.env``` file with these following values:\n    \n    ```bash\n    MESSENGER_PAGE_ID=your_page_id\n    MESSENGER_ACCESS_TOKEN=your_access_token_id\n    MESSENGER_APP_ID=your_app_id\n    MESSENGER_APP_SECRET=your_app_secret\n    MESSENGER_VERIFY_TOKEN=your_app_name\n    ```\n    \n    Save it.\n\n\u003chr\u003e\n\n5. __Run the project__\n\n    You can run your bot on terminal using Bottender Console or activate it on your Express server.\n\n    - __Running on Terminal (Bottender Console)__\n\n        If you want to run this project on console, first open ```package.json``` and set these value:\n\n        ```json\n        \"dev\": \"bottender dev\",\n        \"start\": \"bottender start\",\n        ```\n\n        Save, then execute this command:\n\n        ```bash\n        $ npm run dev -- --console\n        ```\n\n        Now you can chat with your bot on terminal.\n\n    - __Running on Express Server__\n\n        If you want to run this project on Express server, first open ```package.json``` and set these value:\n\n        ```json\n        \"dev\": \"nodemon server.js\",\n        \"start\": \"node server.js\",\n        ```\n\n        Save, then execute this command:\n\n        ```bash\n        $ npm run dev\n        ```\n\n        Now your bot application is run on ```http://localhost:5000```, including its REST API. Try to __GET ```/messages```__ to show all received messages.\n\n\u003chr\u003e\n\n6. __Make Public Server__\n\n    Run your project on Express server, then make it public. You can deploy the project on cloud (for instance: __Heroku__, __AWS__ or __Google Cloud__) or in this case I simply use __ngrok__ to create public URL for my project. Download [__ngrok__ here](https://ngrok.com/) then execute from terminal:\n\n    ```bash\n    $ ngrok.exe http 5000\n    ```\n\n    Then you'll get these information, including your server's public URL. _Note your HTTPS public URL!_\n\n    \u003cimg src=\"./img/f.png\"\u003e \n\n\u003chr\u003e\n\n7. __Set Webhook \u0026 Going Live!__\n\n    Note your HTTPS public URL, then back to your project. In your project, open new terminal then execute this:\n\n    ```bash\n    $ npx bottender messenger webhook set -w https://YOUR_HTTPS_PUBLIC_URL/webhooks/messenger\n    ```\n\n    It will set Messenger webhook, connect your project to Facebook application \u0026 your bot will live on your Facebook Page. Try to send a message!\n\n    Enjoy ~ 😎\n\n\u003chr\u003e\n\n#### Lintang Wisesa :love_letter: _lintangwisesa@ymail.com_\n\n[Facebook](https://www.facebook.com/lintangbagus) | \n[Twitter](https://twitter.com/Lintang_Wisesa) |\n[LinkedIn](https://www.linkedin.com/in/lintangwisesa/) |\n[Youtube](https://www.youtube.com/user/lintangbagus) | \n:octocat: [GitHub](https://github.com/LintangWisesa) |\n[Hackster](https://www.hackster.io/lintangwisesa)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flintangwisesa%2Fexpress-bottender-messenger-mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flintangwisesa%2Fexpress-bottender-messenger-mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flintangwisesa%2Fexpress-bottender-messenger-mongodb/lists"}