# poe-npm

> A Node.js package for interacting with the Quora Poe chatbots, including custom chatbots. Please note that this package is not official and has been reverse-engineered. Use it at your own discretion.

Latest version **1.1.0** (published 2023-05-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install poe-npm
pnpm add poe-npm
yarn add poe-npm
bun add poe-npm
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2023-05-27 |
| First published | 2023-05-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 11 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | bokaif |
| Maintainers | bokaif |
| Keywords | poe, quora, api, chatbot, chatgpt, claude |

## Links

- npm: https://www.npmjs.com/package/poe-npm
- Repository: https://github.com/bokaif/poe-npm
- Homepage: https://github.com/bokaif/poe-npm#readme
- Issues: https://github.com/bokaif/poe-npm/issues
- npm.io page: https://npm.io/package/poe-npm

## Dependencies (2)

- [node-fetch](https://npm.io/package/node-fetch.md) ^3.3.1
- [readline-sync](https://npm.io/package/readline-sync.md) ^1.4.10

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2023-05-27
- 1.0.9 — 2023-05-27
- 1.0.8 — 2023-05-27
- 1.0.7 — 2023-05-26
- 1.0.6 — 2023-05-26
- 1.0.5 — 2023-05-26
- 1.0.3 — 2023-05-26
- 1.0.1 — 2023-05-26
- 1.0.0 — 2023-05-26

## README

# **Poe-NPM**

[![npm version](https://badge.fury.io/js/poe-npm.svg)](https://badge.fury.io/js/poe-npm)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A Node.js package for Interacting with Poe Chatbots using Reverse Engineering

## **Installation**

```bash
npm install poe-npm
```

## **Usage**

```javascript
const { setAuth, loadChatId, clearContext, sendMessage, getMessage} = require('poe-npm');
```

## **Authentication**

Before using the package, you need to set up the authentication by providing the `Quora-Formkey` and `Cookie` values. Here's how you can obtain them:

### **How to get `Quora-Formkey` and `Cookie`**

1. Log in to https://quora.com/.
2. Open the browser console.
3. Paste the following code to get the value of `Quora-Formkey`:
   ```javascript
   window.ansFrontendGlobals.earlySettings['formkey'];
   ```
4. Go to the Application tab.
5. Navigate to Cookies > quora.com.
6. Look for the '`m-b`' cookie and use its value as `Cookie`.
7. **IMPORTANT:** Use the same email address to log in to https://poe.com/ or else you will get an error.

### **Setting the Authentication**

```javascript
const formkey = 'YOUR_FORMKEY';
const cookie = 'M_B_COOKIE_VALUE';

setAuth('Quora-Formkey', formkey);
setAuth('Cookie', `m-b=${cookie}`);
```

## **Selecting a Bot**

Select the bot you want to interact with by specifying its username:

```javascript
const bot = 'capybara'; // Example: 'Sage' bot
```

Refer to the table below to find the appropriate username for the desired bot.

| Bot       | Username        |
| --------- | --------------- |
| Sage      | capybara        |
| GPT-4     | beaver          |
| Claude+   | a2_2            |
| Claude    | a2              |
| ChatGPT   | chinchilla      |
| Dragonfly | nutria          |
| Other     | USERNAME_OF_BOT |

## **Functions**

### `loadChatId(bot)`

Load the chat ID associated with the selected bot.

```javascript
const chatId = await loadChatId(bot);
```

### `clearContext(chatId)`

Clear the context of the chat associated with the provided chat ID.

```javascript
await clearContext(chatId);
```

### `sendMessage(bot, chatId, text)`

Send a message (`text`) to the selected bot using the associated chat ID.

```javascript
const text = 'Hello, Poe!';
sendMessage(bot, chatId, text);
```

### `getMessage(bot, chatId)`

Get the response message from the selected bot.

```javascript
const response = await getMessage(bot, chatId);
```

## **Example: Using CLI**

Step 1. Install package

```bash
npm install poe-npm readline-sync
```

Step 2. Create a file named `index.js` and paste the following code:

```javascript
const { setAuth, loadChatId, clearContext, sendMessage, getMessage } = require('poe-npm');
const readlineSync = require('readline-sync');

const formkey = 'YOUR_FORMKEY';
const cookie = 'M_B_COOKIE_VALUE';

setAuth('Quora-Formkey', formkey);
setAuth('Cookie', `m-b=${cookie}`);

const bot = readlineSync.question('Enter Bot\'s Username: ');
console.log('The selected bot is: ', bot);

async function runPoeBot() {
  let chatId = await loadChatId(bot);
  await clearContext(chatId); // clearing context initially

  while (true) {
    const text = readlineSync.question('You: ');

    if (text === 'clear context') {
      await clearContext(chatId);
      console.log('Context cleared');
    }

    await sendMessage(bot, chatId, text);
    const response = await getMessage(bot, chatId);
    console.log(`${bot}: ${response}`);
  }
}

runPoeBot();
```

Step 3. Run the file using the following command:

```bash
node index.js
```

## **Disclaimer**

Please note that this is not an official package. Use it at your own discretion and adhere to Quora's terms of service and policies.

## **Contributing**

Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request.

## **License**

This project is licensed under the [MIT License](https://opensource.org/licenses/MIT).

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