Skip to content

Repository files navigation

🤖 facebookChatBot

Next-Gen Modular AI Messenger Chatbot & Safe FCA Architecture

Node.jsJavaScriptExpress.jsSQLiteLicense: MIT

A high-performance, modular, and human-like Facebook Messenger Chatbot built on Node.js and GoatBot v2 architecture. Powered by a custom anti-ban FCA engine, SQLite conversation memory, group moderation tools, and a real-time web control panel.

Key FeaturesQuick StartCommand SuiteDeveloper GuideWeb DashboardDeveloper Info


📌 Table of Contents


✨ Key Features

  • 🛡️ Rebuilt Safe FCA Engine (fcaEngine.js): Internal message queue with humanized 1.2s–3.0s jitter delays to bypass spam triggers.
  • ⌨️ Typing Emulation: Simulates human typing indicators (sendTypingIndicator) before dispatching message responses.
  • 🧠 SQLite Conversation Memory (memory.js): Long-term message logging enabling natural AI conversations with thread context.
  • 🤖 Human-Like AI Chatbot (!ai): Answers command queries and passively responds when tagged or replied to in group chats.
  • 👑 Group Moderation Tools (!group, !warn, !antiout): Admin commands for member removal, member warning system with auto-kick, and antiout protection.
  • 🌐 Glassmorphic Web Dashboard: Real-time Express UI displaying system metrics, live terminal logs, loaded commands, SQLite memory, and author info.
  • Hot-Reloadable Command Framework: Dynamic module loader supporting onStart, onChat, onReply, and onEvent execution hooks.
  • 🔐 Session Persistence: Automatic cookie refresh and auto-saving back to appState.json.

👨‍💻 Developer & Author Info

{
"developer": "Gtajisan",
"aliases": ["Gtajisan", "frnAlt"],
"location": "Chattogram, Bangladesh",
"role": "Backend Developer & Cybersecurity Enthusiast",
"expertise": [
"API Architecture & Microservices",
"Server-Side Logic & Node.js",
"Database Optimization",
"Cybersecurity & Wireless Pentesting"
],
"philosophy": "Code should solve problems, not create them."
}

🌐 Connect & Follow


🛠️ Tech Stack & Architecture

LayerTechnologyPurpose
RuntimeNode.js (v18+)Core asynchronous server execution
API EngineCustom FCA WrapperFacebook Chat API layer with anti-ban jitter queues
DatabaseSQLite (better-sqlite3)Long-term memory, chat history & user context
DashboardExpress.js + Vanilla CSSGlassmorphic Web UI & REST API status endpoint
AI IntegrationPollinations / SimSimi APINatural conversational intelligence engine
facebookChatBot/
├── index.js # Main bot launcher & event dispatcher
├── config.json # Prefix, admin UIDs, and bot settings
├── appState.json # Facebook session cookies file
├── package.json # Project metadata & dependencies
├── README.md # Project documentation
├── system/
│ ├── fcaEngine.js # Rebuilt FCA Engine with anti-ban queues & jitter
│ ├── memory.js # SQLite long-term conversation memory layer
│ ├── logger.js # Formatted console logger
│ ├── database.js # Thread & user JSON state database
│ └── webServer.js # Express Web Dashboard & API server
├── scripts/
│ ├── cmds/ # 28 Command modules
│ └── events/ # 3 Event modules (welcome, leave, antiout)
└── public/ # Control panel frontend
├── index.html # Tabbed dashboard HTML UI
└── style.css # Glassmorphic dark theme stylesheet

🚀 Quick Start & Installation

1. Clone & Install

git clone https://github.com/frnAlt/facebookChatBot.git
cd facebookChatBot
npm install

2. Configure config.json

Set your bot prefix and Admin UIDs:

{
"botName": "GoatBot v2",
"prefix": "!",
"adminUIDs": [
"100000000000000"
],
"port": 3000
}

3. Launch Bot

npm start

For automatic development reloading:

npm run dev

🔐 Session Cookie Setup (appState.json)

  1. Log into your bot's Facebook account on a browser.
  2. Use a cookie exporter extension (such as c_user & xs exporter) to extract JSON session cookies.
  3. Save your cookies inside appState.json:
[
{
"key": "c_user",
"value": "YOUR_FACEBOOK_USER_ID",
"domain": "facebook.com",
"path": "/",
"hostOnly": false,
"creation": "2026-01-01T00:00:00.000Z",
"lastAccessed": "2026-01-01T00:00:00.000Z"
},
{
"key": "xs",
"value": "YOUR_XS_COOKIE_VALUE",
"domain": "facebook.com",
"path": "/",
"hostOnly": false,
"creation": "2026-01-01T00:00:00.000Z",
"lastAccessed": "2026-01-01T00:00:00.000Z"
}
]

🛠️ Developer Module Creation Guide

How to Create a Custom Command (/scripts/cmds/mycommand.js)

module.exports={config: {name: "mycommand",version: "1.0.0",author: "Farhan Muh Tasim",countDown: 3,role: 0,// 0 = Public, 1 = Group Admin, 2 = Bot AdminshortDescription: "Custom command example",longDescription: "Demonstrates GoatBot v2 lifecycle hooks.",category: "Custom",guide: "{pn}"},// 1. Direct Command Invocation (!mycommand)onStart: asyncfunction({ api, event, args, message, db, memory, fcaEngine }){returnmessage.reply("Hello from custom GoatBot v2 command!");},// 2. Passive Message Listener (Runs on every message in chat)onChat: asyncfunction({ api, event, message, memory }){if(event.body&&event.body.toLowerCase().includes("hello bot")){message.reply("Hello there friend! 👋");}},// 3. Callback Handler for Message RepliesonReply: asyncfunction({ api, event, message, replyData }){message.reply(`You replied to message: ${replyData.commandName}`);}};

How to Create a Custom Event Handler (/scripts/events/myevent.js)

module.exports={config: {name: "myevent",version: "1.0.0",author: "Farhan Muh Tasim",category: "Events"},onEvent: asyncfunction({ api, event, logger }){if(event.logMessageType==="log:subscribe"){logger.event(`New participant added to thread ${event.threadID}`);}}};

⚙️ Command Suite & Event Modules

CommandCategoryDescriptionAccess Level
!ai <prompt>AINatural conversational AI with SQLite memoryEveryone
!group [kick/info/name]AdminGroup moderation & title managementGroup / Bot Admin
!admin [add/remove/list]AdminBot Admin authorization managementBot Admin Only
!kick @mentionAdminQuick member removal wrapperGroup Admin
!warn [@mention/reset]AdminMember warning system with auto-kick at 3 warnsGroup Admin
!antiout [on/off]AdminToggle auto re-add antiout protectionGroup Admin
!eval <code>AdminDynamic JavaScript code evaluatorBot Admin Only
!shell <cmd>AdminExecutive terminal shell on host serverBot Admin Only
!restartAdminReboots the bot process and reloads modulesBot Admin Only
!out [threadID]AdminMake bot leave specified threadBot Admin Only
!nickname [@tag] <nick>FCA UtilityChange thread member nicknameGroup Admin
!emoji <emoji>FCA UtilityChange thread default reaction emojiGroup Admin
!userinfo [@tag]FCA UtilityFetch Facebook user profile detailsEveryone
!thread [info/leave]FCA UtilityView thread info or make bot leave groupGroup Admin
!tagall <message>UtilityMention all members in group threadGroup Admin
!checkUtilityCheck member chat activity and message statsEveryone
!say <text>MediaText-to-speech voice note generatorEveryone
!sing <song>MediaSearch and stream music audio previewEveryone
!avatar [@tag]UtilityFetch HD Facebook profile pictureEveryone
!weather <city>UtilityLive weather report & temperatureEveryone
!quoteFunRandom inspirational motivational quotesEveryone
!catFunRandom cute cat photo generatorEveryone
!dailyEconomyClaim daily virtual economy coin rewardsEveryone
!rankEconomyCheck XP level, rank card, and wallet coinsEveryone
!slot <bet>EconomyCasino slot machine minigameEveryone
!setprefix <prefix>SystemChange custom thread prefixGroup Admin
!help [command]SystemInteractive command directory & guidesEveryone
!pingSystemBot latency and server response timeEveryone
!uptimeSystemServer uptime, Node version, and RAM specsEveryone
!prefix [newPrefix]SystemCheck or change thread-specific prefixEveryone
!uid [@tag]UtilityLookup Facebook User IDEveryone
!tidUtilityGet current chat Thread IDEveryone
!unsendUtilityUnsend bot messages via replyEveryone

🛡️ Anti-Ban & Security Safeguards

To maintain account safety and prevent automated restriction flags:

  1. Never Login with Password: Always use appState.json cookies to avoid triggering login challenges.
  2. Jitter Delay Queue: All outgoing messages pass through an internal queue (messageQueue) with randomized 1.2s–3.0s delays.
  3. Typing Status: Simulates sendTypingIndicator() prior to sending messages.
  4. Git Protection: appState.json is listed in .gitignore to prevent committing sensitive session tokens to public repositories.

🌐 Web Dashboard & 24/7 Hosting

facebookChatBot includes an Express web server providing a control panel UI at http://localhost:3000.

24/7 Uptime Keep-Alive

When deploying on Render, Replit, Koyeb, or VPS, point a ping service (such as UptimeRobot) to: https://your-app-domain.com/api/status


🐙 GitHub Push Guide

To push updates to your GitHub repository:

git add .
git commit -m "docs: enhance README with developer module creation guide & system methods"
git push origin main

📜 License & Support

This project is open-source under the MIT License.

Built with ❤️ by Gtajisan (@Gtajisan / @frnAlt)

About

A high-performance, modular, and human-like Facebook Messenger Chatbot built on Node.js and GoatBot v2 architecture. Powered by a custom anti-ban FCA engine, SQLite conversation memory, group moderation tools, and a real-time web control panel.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages