# fb-assistant-ts

> a facebook puppeteer manipulate library

Latest version **1.1.2** (published 2025-03-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install fb-assistant-ts
pnpm add fb-assistant-ts
yarn add fb-assistant-ts
bun add fb-assistant-ts
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2025-03-08 |
| First published | 2025-03-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 40.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | toshiodev |
| Maintainers | toshiodev |
| Keywords | facebook, puppeteer, typescript, automation, web-scraping |

## Links

- npm: https://www.npmjs.com/package/fb-assistant-ts
- npm.io page: https://npm.io/package/fb-assistant-ts

## Dependencies (4)

- [fs](https://npm.io/package/fs.md) 0.0.1-security
- [axios](https://npm.io/package/axios.md) ^1.8.1
- [puppeteer](https://npm.io/package/puppeteer.md) ^24.3.1
- [@google/generative-ai](https://npm.io/package/@google/generative-ai.md) ^0.23.0

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.1.2 (latest) — 2025-03-08
- 1.1.1 — 2025-03-07
- 1.1.0 — 2025-03-04
- 1.0.9 — 2025-03-04
- 1.0.8 — 2025-03-04
- 1.0.7 — 2025-03-04
- 1.0.6 — 2025-03-04
- 1.0.5 — 2025-03-04
- 1.0.4 — 2025-03-04
- 1.0.3 — 2025-03-04
- 1.0.2 — 2025-03-04
- 1.0.1 — 2025-03-04
- 1.0.0 — 2025-03-04

## README

# fb-assistant-ts

![Facebook Automation](https://img.shields.io/badge/Facebook-Automation-blue)
![TypeScript](https://img.shields.io/badge/TypeScript-4.0+-blue)
![Puppeteer](https://img.shields.io/badge/Puppeteer-10.0+-green)
![Version](https://img.shields.io/badge/Version-1.0.2-brightgreen)
![License](https://img.shields.io/badge/License-ISC-brightgreen)

## Description

`fb-assistant-ts` is a TypeScript library designed to automate interactions with Facebook using Puppeteer. It includes features such as logging in, handling captchas, and more. This library is perfect for developers looking to automate Facebook tasks for testing or scraping purposes.

## Features

- **Facebook Login**: Automate the login process to Facebook.
- **Captcha Handling**: Automatically download and transcribe audio captchas using Google Generative AI.
- **TypeScript Support**: Written in TypeScript for type safety and better development experience.

## Installation

To install the library, use npm, yarn, pnpm, or Bun:

```bash
npm install fb-assistant-ts
```

or

```bash
yarn add fb-assistant-ts
```

or

```bash
pnpm add fb-assistant-ts
```

or

```bash
bun add fb-assistant-ts
```

## Usage

### Facebook Login and Accessing Messenger

Here's an example of how to use the `FacebookLogin` class to log in to Facebook and access the Messenger view:

```typescript
import { FacebookLogin } from 'fb-assistant-ts';

const loginOptions = {
  apiKey: 'YOUR_GOOGLE_GENERATIVE_AI_API_KEY',
  email: 'your-email@example.com',
  password: 'your-password',
  debug: true,
  audioFilePath: 'captcha.mp3'
};

const fbLogin = new FacebookLogin(loginOptions);

(async () => {
  try {
    const page = await fbLogin.login();
    console.log('Logged in successfully!');

    // Navigate to Messenger
    await page.goto('https://www.facebook.com/messages/t/');
    console.log('Navigated to Messenger!');

    // Perform further actions with the Messenger page

    // Navigate to Facebook Marketplace Messenger
    await page.goto('https://www.facebook.com/marketplace/messages/');
    console.log('Navigated to Facebook Marketplace Messenger!');
    
    // Perform further actions with the Marketplace Messenger page
  } catch (error) {
    console.error('Login failed:', error);
  } finally {
    await fbLogin.close();
  }
})();
```

### Marketplace Messenger

Here's an example of how to use the `MarketplaceMessenger` class to interact with Facebook Marketplace Messenger:

```typescript
import { FacebookLogin, MarketplaceMessenger } from 'fb-assistant-ts';

const loginOptions = {
  apiKey: 'YOUR_GOOGLE_GENERATIVE_AI_API_KEY',
  email: 'your-email@example.com',
  password: 'your-password',
  debug: true,
  audioFilePath: 'captcha.mp3'
};

const fbLogin = new FacebookLogin(loginOptions);

(async () => {
  try {
    const page = await fbLogin.login();
    console.log('Logged in successfully!');

    const messenger = new MarketplaceMessenger(page);

    await messenger.navigateToMessages();
    await messenger.skipCodePopup();
    await messenger.doNotRestoreMessages();
    await messenger.openMarketplaceMessagesContainer();
    // await messenger.enterCode('245924');
    // await messenger.openMarketplace();

    // Example usage of the MarketplaceMessenger class
    // await messenger.sendMessage('Recipient Name', 'Hello, this is a test message!');
    // const lastMessage = await messenger.getLastMessage();
    // console.log('Last message:', lastMessage);

    // Close the browser after some time
    /* setTimeout(async () => {
      await fbLogin.close();
    }, 10000); // Close after 10 seconds */
  } catch (error) {
    console.error('Login failed:', error);
  } finally {
    await fbLogin.close();
  }
})();
```

## Contributing

Contributions are welcome! Please open an issue or submit a pull request for any bugs or feature requests. Your contributions help make this project better and more useful for everyone.

## License

This project is licensed under the ISC License.

## Contact

Author: toshiodev

Feel free to reach out for any questions or feedback!

---
_Source: https://npm.io/package/fb-assistant-ts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
