This is a fork of the original fca-unofficial repository. This version includes new features and updates that are bundled faster than the main repository. However, be aware that new features may also come with some bugs.
This API allows you to automate Facebook chat functionalities by emulating the browser's GET/POST requests. It does not work with an auth token and requires a Facebook account's AppState (session information), which is obtained via third-party tools.
Due to recent changes, the ability to log in using credentials (i.e., email and password) directly through the API has been disabled. As a result, you cannot use the old login method with your email and password anymore.
To use the API, you need to provide an AppState (session information) from a previously authenticated session. You can use api.getAppState()
to retrieve and even update your AppState after login.
- Kiwi Browser & c3c-ufc-utility Extension: Extract the AppState using the Kiwi Browser along with the c3c-ufc-utility extension to obtain session cookies after logging into Facebook manually.
Once you have the AppState, you can load it into the API to authenticate. Additionally, api.getAppState()
can now be used to update the AppState during the session.
We strongly recommend being responsible when using this API to avoid issues like account bans. Avoid spamming messages, sending large amounts of requests, or using excessive automation.
This feature is designed to bypass certain behavior detection mechanisms from Facebook, which may otherwise flag your actions as automated. By enabling this, your bot's activity will appear more like human interaction, helping reduce the risk of account limitations.
-
Configuration: Can be toggled on or off in the
NextGen-FCA.json
configuration file.
This feature automatically refreshes the fb_dtsg token, which is used for secure communication with Facebook. Since fb_dtsg tokens expire periodically, this feature ensures your session stays active by refreshing the token automatically without requiring a manual login.
-
Configuration: Can be toggled on or off in the
NextGen-FCA.json
configuration file.
-
Kiwi Browser & c3c-ufc-utility Extension
- Install Kiwi Browser and the c3c-ufc-utility extension.
- Use the extension to extract your AppState (session cookies) from your Facebook login.
- Save the AppState as a
appstate.json
file and load it for logging in.
For more details, check the official c3c-ufc-utility GitHub release.
To install nextgen-fca, use the following npm command:
npm install nextgen-fca
To install the bleeding-edge version directly from GitHub:
npm install nextgen-fca
Here’s how to log in using AppState:
const fs = require('fs');
const login = require('nextgen-fca');
// Load your appState from the saved file
const appState = JSON.parse(fs.readFileSync('appstate.json', 'utf8'));
// Use the appState for login
login({ appState: appState }, (err, api) => {
if (err) return console.error('Login failed:', err);
console.log('Successfully logged in!');
// Example of listening for new messages
api.listen((err, message) => {
if (err) return console.error(err);
// Respond to the received message
api.sendMessage(message.body, message.threadID);
});
// Get and update AppState if needed
const updatedAppState = api.getAppState();
fs.writeFileSync('appstate.json', JSON.stringify(updatedAppState));
});
The following options can be configured in your NextGen-FCA.json
file:
{
"BypassAutomationBehavior": true, // Set to false to disable this feature
"AutoRefreshFbDtsg": true // Set to false to disable this feature
}
- BypassAutomationBehavior: Enables or disables the feature to bypass Facebook's automated behavior detection.
- AutoRefreshFbDtsg: Enables or disables automatic refreshing of the fb_dtsg token to keep your session active.
-
Sending Messages:
- Regular Text Messages
- Sticker Messages
- Image/File Attachments
- URLs
- Emojis
-
Listening to Messages:
- Listen to messages in real-time
- Option to listen to events like user joining or leaving a chat
-
How can I log in without credentials?
- After logging in through a browser, extract your AppState using the c3c-ufc-utility extension. This is now the only way to authenticate.
-
Can I listen to messages from the bot?
- Yes, by default, the bot listens to incoming messages and can respond automatically. You can configure it to respond with specific actions based on the message content.
-
Is there a way to send media like images or files?
- Yes, you can send files or images by passing them as attachments. The example provided demonstrates how to send an image along with a text message.
-
How do I keep my session alive?
- You do not need to log in repeatedly once you have your AppState saved. Simply load the appState.json each time you initialize the API.
-
Can I send messages as a Facebook Page?
- Yes, you can configure the login to use a Facebook Page ID for sending messages as a Page. This is done during the login step.
- c3c - A customizable bot with Facebook and Discord support.
- Messenger-CLI - Command-line interface for Facebook Messenger.
This project is licensed under the MIT License - see the LICENSE file for details.
If you have a problem with this FCA, you can contact us by clicking here:
Join our group ChatBot Community:
Note: This project is an unofficial Facebook chat API. Use it responsibly and follow Facebook’s terms of service.