A feature-rich WhatsApp bot built with Python and Flask, leveraging the Whapi.Cloud API. This bot supports sending and receiving messages, media, documents, group management, and now includes integration with OpenAI's ChatGPT for AI-powered conversations.
- Responds to unknown commands with a help message
- Send regular text messages
- Send images
- Send files/documents
- Send videos
- Send contacts (vCard)
- Send product information
- Create new groups, invite participants, and send group messages
- Receive and process incoming messages
- Chat with OpenAI ChatGPT using the /AI command
For the bot to work, it is NOT REQUIRED that the phone is turned on or online. Connect your WhatsApp and test the integration comfortably!
For support, visit: https://whapi.cloud/features
- Download and install Python from the official website: https://python.org
- Verify that pip is installed along with Python.
Install the necessary libraries listed in requirements.txt:
pip install -r requirements.txt
Edit the .env file in your project directory. Set up the following configurations:
TOKEN
— Your Whapi.Cloud API tokenAPI_URL
— Your Whapi.Cloud API URLBOT_URL
— Your webhook URL (publicly accessible for production)- (Optional)
OPENAI_API_KEY
— Your OpenAI API key (for ChatGPT integration) - (Optional)
PRODUCT_ID
,GROUP_ID
, etc. as needed
python index.py
Learn more about configuring webhooks for local development here: https://support.whapi.cloud/help-desk/receiving/webhooks/how-to-check-the-webhook#how-to-test-webhook-locally
You can chat with OpenAI's ChatGPT directly from WhatsApp using the special command:
/AI <your message>
Example:
/AI Tell me a joke about Python.
The bot will reply with a response generated by ChatGPT.
Register at: https://panel.whapi.cloud/register After registration, follow the instructions to connect your phone and obtain your API token. This token is required for authenticating API requests.
This project is provided for educational and demonstration purposes. Please review the terms of use for Whapi.Cloud and OpenAI before deploying in production.