Skip to content

WhatsApp Python Bot. Key features include sending and receiving messages, as well as support for images, files, documents, videos, and product. Group functionality is fully supported — you can create new groups and interact with them programmatically. Additionally, the bot can be integrated with ChatGPT to enable AI-powered conversations

Notifications You must be signed in to change notification settings

Whapi-Cloud/python-whatsapp-chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

WhatsApp Python Bot. Key features include sending and receiving messages, as well as support for images, files, documents, videos, and product. Group functionality is fully supported — you can create new groups and interact with them programmatically. Additionally, the bot can be integrated with ChatGPT to enable AI-powered conversations

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages