A Node.js package for Interacting with Poe Chatbots using Reverse Engineering
npm install poe-npm
const { setAuth, loadChatId, clearContext, sendMessage, getMessage} = require('poe-npm');
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:
- Log in to https://quora.com/.
- Open the browser console.
- Paste the following code to get the value of
Quora-Formkey
:window.ansFrontendGlobals.earlySettings['formkey'];
- Go to the Application tab.
- Navigate to Cookies > quora.com.
- Look for the '
m-b
' cookie and use its value asCookie
. - IMPORTANT: Use the same email address to log in to https://poe.com/ or else you will get an error.
const formkey = 'YOUR_FORMKEY';
const cookie = 'M_B_COOKIE_VALUE';
setAuth('Quora-Formkey', formkey);
setAuth('Cookie', `m-b=${cookie}`);
Select the bot you want to interact with by specifying its username:
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 |
Load the chat ID associated with the selected bot.
const chatId = await loadChatId(bot);
Clear the context of the chat associated with the provided chat ID.
await clearContext(chatId);
Send a message (text
) to the selected bot using the associated chat ID.
const text = 'Hello, Poe!';
sendMessage(bot, chatId, text);
Get the response message from the selected bot.
const response = await getMessage(bot, chatId);
Step 1. Install package
npm install poe-npm readline-sync
Step 2. Create a file named index.js
and paste the following code:
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:
node index.js
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.
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License.