File size: 4,053 Bytes
4327358
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# WAHA (WhatsApp HTTP API) Python examples

## Installation

We assume that you have installed software:

1. Python 3
2. Docker

### Download and start image

First of all, you must run WhatsApp HTTP API locally (which under the hood it
runs real WhatsApp Web instance and expose HTTP API for interaction).

Here are the steps from
[Quick Start](https://waha.devlike.pro/docs/overview/quick-start/):

Download and start WhatsApp HTTP API docker container

```bash
# Download the image
docker pull devlikeapro/waha
# Run the docker container
docker run -it --rm --network=host -e WHATSAPP_HOOK_URL=http://localhost:5000/bot -e "WHATSAPP_HOOK_EVENTS=*" --name waha devlikeapro/waha

# It prints logs and the last line must be
# WhatsApp HTTP API is running on: http://[::1]:3000
```

#### Download image - ARM

If you're using ARM (like Apple Silicon, Apple M1, etc.) - use following
commands to download the image

![](/images/versions/core.png) For Core version the command is

```bash
# Download the image
docker pull devlikeapro/waha:arm
# Rename it, so you can use devlikeapro/waha image in other place
docker tag devlikeapro/waha:arm devlikeapro/waha
# Run the docker container
docker run -it --rm --network=host -e WHATSAPP_HOOK_URL=http://localhost:5000/bot -e "WHATSAPP_HOOK_EVENTS=*" --name waha devlikeapro/waha

# It prints logs and the last line must be
# WhatsApp HTTP API is running on: http://[::1]:3000
```

### Start session and scan QR

2. Open Swagger API in the browser http://localhost:3000/
3. Start session and scan QR code in swagger
   1. Find `POST /api/sessions/` request press **Try it out** and **Execute** it
      with `default` session name
   2. Find `GET /api/screenshot` and execute it - it must show QR code
   3. Scan QR code on your mobile WhatsApp application (that installed on your
      phone)
   4. Execute `GET /api/screenshot` once again - it must show the screenshot
      from WhatsApp Web.
4. Send test text message - find `POST /api/sendText` and execute it with
   payload (change `12132132130` in the `chatId` to phone number that is
   registered in WhatsApp).

```json
{
  "chatId": "12132132130@c.us",
  "text": "Hi there!",
  "session": "default"
}
```

If you see **Hi there!** message then you're ready to run bots!

## WhatsApp Echo Bot

The WhatsApp Echo Bot is a sample flask webhook server application that echoes
back to you whatever you send it. It can serve as a basic reference for how to
set up webhooks and reply to incoming messages.

```bash
# Clone the git repository with example
git clone https://github.com/devlikeapro/waha.git
# Open python example folder
cd waha/examples/python
# Install requirements
python -mpip install -r requirements.txt
# Run the bot
FLASK_APP=whatsapp_echo_bot.py flask run
```

Open http://127.0.0.1:5000/bot - if you see **WhatsApp Echo Bot is ready!** then
the bot is ready to receive message!

Send message to the WhatsApp (that you used to scan QR code) and it'll echo text
back to you!

## WhatsApp Download Files Bot

The WhatsApp Download Image Bot downloads all files people send to your WhatsApp
and log the path for the file.

**The bot works only with WAHA Plus version** available with donations. Visit
[read more about difference between Core and Plus versions](https://waha.devlike.pro/docs/how-to/plus-version/).

Download **WAHA Plus** version:

```bash
# Download the image
docker pull devlikeapro/waha-plus
# Run the docker container
docker run -it --rm --network=host -e WHATSAPP_HOOK_URL=http://localhost:5000/bot -e "WHATSAPP_HOOK_EVENTS=*" --name waha devlikeapro/waha-plus
```

Run the WhatsApp Download Files bot:

```bash
# Clone the git repository with example
git clone https://github.com/devlikeapro/waha.git
# Open python example folder
cd waha/examples/python
# Install requirements
python -mpip install -r requirements.txt
# Run the bot
FLASK_APP=whatsapp_download_files_bot.py flask run
```

Open http://127.0.0.1:5000/bot - if you see **WhatsApp Download Files Bot!**
then the bot is ready to receive message with files!