This is a webhook which can be used to get replies from an AI model, more specifically gpt-3.5-turbo
The webhook is tailored for integration with Twilio to recieve messages on Whatsapp but can be easily used for something else. In my current implementation it also stores 1 previous message pair in a MongoDB database for better response generation.
Anyways, here is how you get it on your Whatsapp!
- Clone the repo to local
git clone https://github.com/AbhigyanBafna/whatTheGPT.git
3.1) Get your SID and Auth Token from Twilio (3.1 is an optional step)
TWILIO_ACCOUNT_SID
TWILIO_AUTH_TOKEN
3.2) OPENAI_API_KEY from openAI
3.3) MONGO_URI from mongoDB
Note - You need to create a cluster, a database and a collection to get your URI. After getting everything insert them into an dotenv file at the root of your repository.
The database and collection names that I've used are gptStore and conversations
Never SHARE your API KEYS
- Install the dpendancies, run it locally and check the /api/message route.
npm install
npm run dev
- Host the project. I used vercel. (Its a good idea to get an idea if you've never done this before --> docs )
npm i -g vercel
vercel --version
vercel build
vercel deploy --prebuilt
The webhook is live!
- Head over to the Twilio Console and set up Messaging --> Try it out --> Send a Whatsapp Message.
- After setting your sandbox. Go to webhooks and input the api endpoint of your url. It would be something like
your-url/api/message
Remember to keep your hosted webhook SAFE and PRIVATE as they can easily be misused to exhaust your Twilio or OpenAI usage.
Hope you enjoyed it and have an AI model in your DMs now!
~Abhi out :)