# WhatsApp Python Bot

On [GitHub](https://github.com/stars/Whapi-Cloud/lists/python-bot-samples-scripts) you can find an implementation of a simple WhatsApp chatbot that demonstrates the basic functionality of sending and receiving messages of different types and working with groups.&#x20;

{% hint style="info" %}
Using this source code will allow you to customize the bot to your needs or take it as a basis for creating any other integration.&#x20;
{% endhint %}

## Bot's source code <a href="#bots-source-code" id="bots-source-code"></a>

**Choose Your Bot Script**

We offer two options for bot scripts:

1. **Basic Version (for Beginners)**&#x20;

This version is ideal if you're just starting with bot development. The bot responds to commands with text messages and image sharing, allowing you to focus on the core functionality without being overwhelmed by unnecessary features.

{% embed url="<https://github.com/Whapi-Cloud/whatsapp-simple-bot-python>" %}

{% embed url="<https://youtu.be/GhsRJBXztoc>" %}

2. **Advanced Version (for Experienced Users)**&#x20;

This script comes with more capabilities, such as sending not just text messages but also videos, files, creating groups, and more. The code is more optimized and efficient, but it may not be as straightforward for beginners.

{% embed url="<https://github.com/Whapi-Cloud/python-whatsapp-chatbot>" %}

Here's what this bot does:

* Respond to an unfamiliar command, this could be an instruction or your welcome message;
* Send regular message;
* Send image;
* Send file;
* Send video;
* Send contact (vCard);
* Send product;
* Create new group, send an invitation and send message to the group;
* Receive and reading incoming messages;
* Webhook Setup;

{% hint style="info" %}
**Multi-device Supported API**: It's NOT necessary for the phone to be turned on or online for the bot to work. You can use the app as before.
{% endhint %}

### 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:

1. Open the command line or terminal.
2. Navigate to your project directory.
3. Run the command:

```
pip install -r requirements.txt
```

This installs all libraries specified in the requirements.txt file.

#### Step 3: Configure the Project

Configure your project settings: Open the `.env` file in your IDE. Set up configurations such as your API token and webhook URL

#### Step 4: Run the Bot

Launch your bot using Python:

1. Ensure you are in the project directory in your terminal.
2. Execute the command:

```
python index.py
```

Learn more about how to configure the webhook to work locally here: <https://support.whapi.cloud/help-desk/receiving/webhooks/how-to-check-the-webhook#how-to-test-webhook-locally>

***

If you need help, just message us in the support chat on any page of the site. We can help you with bot installation or customization.
