TugayArslan / whatsgpt

WhatsApp Bot for ChatGPT with multiple user support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Notice:

OpenAI's ChatGPT is experiencing heavy traffic and at the moment obtaining a session is difficult. You may get these messages while attempting to run the bot. If this happens, try again. Once you get a session, it seems to last quite a while (although it will eventually timeout.)

The ChatGPT NPM module will eventually move to use the official OpenAI API, and I will update this message when that happens.

Also - feel free to contribute via pull requests etc. :)

Screenshot 2022-12-13 at 8 52 47 AM

Screenshot 2022-12-13 at 8 51 56 AM

WhatsGPT?

WhatsGPT is a wrapper for ChatGPT for personal or family use, that runs inside your own WhatsApp bot.

  • Can keep track of multiple separate conversations
  • Can be added to groups, and will respond to messages starting with @[its number or name]

My family and I find ChatGPT very useful want we want to use it on the go and I was bored on a Saturday morning, so here we are.

It's experimental and relies on the preview release of OpenAI's ChatGPT.

Thanks to

Requirements

  • A phone number that can receive text messages/voice calls, linked to its own WhatsApp instance.
  • I use a Google Voice number, and run a 2nd instance of WhatsApp on my phone by using the WhatsApp for Business app (it's free!])
  • Node JS >= 18
  • A computer that can run Chrome (headless is now broken as OpenAI is using CloudFlare)

Installation

Get the files

Clone the repository:

git clone https://github.com/pascalroget/whatsgpt.git

Install dependencies:

npm install

Find your local path to Chrome

Configure it

Create a .env file with the following variables. In this example, we are using Chrome on OSX.

CHROME_PATH=/Applications/Google Chrome.app/Contents/MacOS/Google Chrome
EMAIL=[Your email used to register with OpenAI]
PASSWORD=[Your password used to register with OpenAI]

Run it

npm start

Scan the barcode with your WhatsApp app:

Done :)

Issues

Authentication with ChatGPT is a fluid situation. As of this writing, the chatgpt npm package now tries to login with a headfull browser to obtain and then refresh cookies.

Use it

Open a chat with the WhatsApp account linked to the number you just linked to this bot. ChatGPT will answer. This works for several users at the same time and each conversation is separate. Additionally, you can reset an ongoing conversation by sending this message:

reset

About

WhatsApp Bot for ChatGPT with multiple user support

License:MIT License


Languages

Language:JavaScript 89.6%Language:Shell 10.4%