Skip to content

Latest commit

 

History

History
68 lines (51 loc) · 2.53 KB

File metadata and controls

68 lines (51 loc) · 2.53 KB

Python Whatsapp ChatBot

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.

Features

  • 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

whatsapp-bot-example

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

Getting Started

Step 1: Install Python and pip

  1. Download and install Python from the official website: https://python.org
  2. Verify that pip is installed along with Python.

Step 2: Install Dependencies

Install the necessary libraries listed in requirements.txt:

pip install -r requirements.txt

Step 3: Configure the Project

Edit the .env file in your project directory. Set up the following configurations:

  • TOKEN — Your Whapi.Cloud API token
  • API_URL — Your Whapi.Cloud API URL
  • BOT_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

Step 4: Run the Bot

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

How to Use the AI Chat Feature

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.

How to Connect to Whapi.Cloud and Get API Token

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.

License

This project is provided for educational and demonstration purposes. Please review the terms of use for Whapi.Cloud and OpenAI before deploying in production.