Following are the main contents to follow, you can jump to any section:
WhatsApp Chatbot with OpenAI Integration is a sophisticated messaging bot that can be deployed to interact with users on WhatsApp. Leveraging the Twilio API for WhatsApp messaging and the ChatGPT by OpenAI for natural language processing, this bot can understand and respond to user queries in a conversational manner. It goes beyond basic chatbots by utilizing custom tools to access the internet, ensuring that it can provide up-to-date information and perform a wide range of tasks.
1- Seamless WhatsApp Integration: Users can interact with the chatbot just like they would with any other contact on WhatsApp, making it a user-friendly and familiar experience.
2- Natural Language Processing: The chatbot uses OpenAI's advanced language models to understand and generate human-like responses, making interactions feel more natural and engaging.
3- Custom Tools: Custom-built tools enhance the bot's capabilities, allowing it to access the internet for real-time information retrieval and perform a variety of tasks.
4- Internet Access: The bot can browse the internet to fetch the latest information, news, weather updates, and more, ensuring users receive up-to-date answers.
5- Customizable: Developers can easily customize the bot's responses, actions, and integration with other services to meet specific project requirements.
6- DevOps Practices: This project adheres to industry-standard DevOps practices for deployment, ensuring reliability, scalability, and ease of maintenance.
1. Python 2. Generative AI 3. Docker 4. RESTful API(Flask) 5. Chatbot 6. Cloud Computing 7. SMTP Server
1. DockerHub 2. Twilio 3. ChatGPT 4. GitHub 5. Ngrok 6. CircleCI 7. AWS-EC2 as a Self hosted runner
Either you can clone the repo and run the project using source or you can directly run a docker container
-
Ensure you have Python 3.8+ installed.
conda create -n venv python=3.11
conda activate venv
OR
- Create a new Python virtual environment with pip:
virtualenv venv
source venv/Scripts/activate
Install dependencies
pip install -r requirements.txt
Clone the project
git clone https://github.com/Hassi34/whatsapp-ai-chatbot.git
Go to the project directory
cd whatsapp-ai-chatbot
OPENAI_API_KEY=""
SERPAPI_API_KEY=""
OPENWEATHER_API_KEY=""
AWS_ACCESS_KEY_ID=""
AWS_SECRET_ACCESS_KEY=""
AWS_DEFAULT_REGION=""
ENV_FILE_PATH_RUNNER=""
#Email Alerts
EMAIL_PASS=""
SERVER_EMAIL=""
SANITY_CHECK_EMAIL_RECIPIENTS=""
PRODUCTION_DEPLOYMENT_SUCCESS_EMAIL_RECIPIENTS=""
First ensure you have the docker installed on your system and then run following commands: ππ»
In case you have not already pulled the image from the Docker Hub, you can use the following command:
docker pull hassi34/whatsapp-ai-chatbot
Now once you have the docker image from the Docker Hub, you can now run the following commands to test and deploy the container to the web
docker images
Use the following command to run a docker container on your system:
docker run -itd -e OPENAI_API_KEY=$OPENAI_API_KEY -e SERPAPI_API_KEY=$SERPAPI_API_KEY -e OPENWEATHER_API_KEY=$OPENWEATHER_API_KEY -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY -e AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION --name <CONTAINER NAME> -p 8080:8080 hassi34/whatsapp-ai-chatbot
Check if the container is running:
docker ps -a
If the container is running, then the API services will be available at port 8080
Enter the following url to you Twilio Post request:
http://<YOUR IP ADDRESS>:8080/chatgpt_webhook
This project is production ready for similar use cases and comes with the industry standard engineering practices.
MIT Β© Hasanain
Let's connect on LinkedIn