WaBotAI is an AI-based WhatsApp Bot that leverages Twilio and OpenAI services to deliver intelligent responses.
Description: WaBotAI is designed to enhance your WhatsApp messaging experience by incorporating artificial intelligence for intelligent and context-aware responses.
Get started by registering for a free Twilio account at Twilio. Obtain your Account SID
and Auth Token
from the Twilio Console.
-
Account SID and Auth Token Configuration: Open the file
app/api/message/get_message.py
in your code editor. Locate the variablesaccount_sid
andauth_token
and replace'YOUR_ACCOUNT_SID'
and'YOUR_AUTH_TOKEN'
with your Twilio account SID and auth token.from app.api.message.create_message import CreateMessage from twilio.rest import Client import time import json account_sid = 'YOUR_ACCOUNT_SID' auth_token = 'YOUR_AUTH_TOKEN' client = Client(account_sid, auth_token) class GetMessage:
If you don't have an OpenAI account, register at OpenAI Platform. Obtain your API Key
from the API Keys section.
-
API Key Configuration: Open the file
app/api/gpt/gpt.py
in your code editor. Locate the variableapi_key
and replace'YOUR_API_KEY'
with your OpenAI API key.import os from openai import OpenAI api_key = "YOUR_API_KEY" client = OpenAI(api_key=api_key) def gpt(message):
If you want to use another server, skip this step.
It will be used to capture messages thrown from Twilio.
-
Installation:
- Install Ngrok via Apt:
$ curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | sudo tee /etc/apt/sources.list.d/ngrok.list && sudo apt update && sudo apt install ngrok
- Install Ngrok via Snap:
$ snap install ngrok
-
Auth Token:
$ ngrok config add-authtoken <token>
If you don't have an auth token, sign up here and obtain the token from Ngrok Dashboard.
-
Installing Requirements: Run:
pip install -r requirements.txt
-
Setting up Twilio Webhook: Use the server address that will be used to capture messages from Twilio.
Use your own server address if you don't use ngrok.Obtain the Ngrok domain from Ngrok Dashboard. Update the Twilio sandbox settings to use the Ngrok domain.
e.g :https://your-server.com/api/wa
Don't forget to add
/api/wa
. -
Running Ngrok:
-
Skip this step if you're using your own server.
ngrok http --domain=your-domain.ngrok-free.app 8000
-
Running the Application:
python main.py
Contributions to WaBotAI are welcome! Feel free to open issues, submit pull requests, or improve the documentation. Together, we can make WaBotAI even better.
This project is licensed under the MIT License - see the LICENSE file for details.