├── Clientes.xlsx
├── README.md
└── sender.ipynb
/Clientes.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandreke/WhatsApp-Bulk-and-Customized-Messages-Without-Saving-Contacts/HEAD/Clientes.xlsx
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WhatsApp-Bulk-and-Customized-Messages-Without-Saving-Contacts
2 | Automate bulk and customized [WhatsApp](https://www.whatsapp.com/) messages to unsaved numbers using [Python](https://www.python.org/) 🐍
3 |
4 | #### 🎥 Watch the [demo video](https://www.instagram.com/p/Cmb38gXBpeB/) to understand how it works
5 |
6 | #### 📝 Read the step-by-step guide in this [Medium post](https://sandroagama.medium.com/enviar-mensajes-masivos-y-personalizados-por-whatsapp-con-python-35d4bca85a67)
7 |
--------------------------------------------------------------------------------
/sender.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {},
7 | "outputs": [],
8 | "source": [
9 | "!pip install pandas\n",
10 | "!pip install openpyxl\n",
11 | "!pip install webbrowser\n",
12 | "!pip install pyautogui"
13 | ]
14 | },
15 | {
16 | "cell_type": "code",
17 | "execution_count": 2,
18 | "metadata": {},
19 | "outputs": [],
20 | "source": [
21 | "import pandas as pd\n",
22 | "import webbrowser as web\n",
23 | "import pyautogui as pg\n",
24 | "import time"
25 | ]
26 | },
27 | {
28 | "cell_type": "code",
29 | "execution_count": 3,
30 | "metadata": {},
31 | "outputs": [
32 | {
33 | "data": {
34 | "text/html": [
35 | "
\n",
36 | "\n",
49 | "
\n",
50 | " \n",
51 | " \n",
52 | " | \n",
53 | " Cliente | \n",
54 | " Nombre | \n",
55 | " Celular | \n",
56 | " Producto | \n",
57 | "
\n",
58 | " \n",
59 | " \n",
60 | " \n",
61 | " | 0 | \n",
62 | " Tame Impala | \n",
63 | " Tame | \n",
64 | " 51966561101 | \n",
65 | " ABC | \n",
66 | "
\n",
67 | " \n",
68 | " | 1 | \n",
69 | " Bad Bunny | \n",
70 | " Benito | \n",
71 | " 51954616042 | \n",
72 | " DEF | \n",
73 | "
\n",
74 | " \n",
75 | " | 2 | \n",
76 | " Claire Cottrill | \n",
77 | " Clairo | \n",
78 | " 51948769082 | \n",
79 | " GHI | \n",
80 | "
\n",
81 | " \n",
82 | "
\n",
83 | "
"
84 | ],
85 | "text/plain": [
86 | " Cliente Nombre Celular Producto\n",
87 | "0 Tame Impala Tame 51966561101 ABC\n",
88 | "1 Bad Bunny Benito 51954616042 DEF\n",
89 | "2 Claire Cottrill Clairo 51948769082 GHI"
90 | ]
91 | },
92 | "execution_count": 3,
93 | "metadata": {},
94 | "output_type": "execute_result"
95 | }
96 | ],
97 | "source": [
98 | "data = pd.read_excel(\"Clientes.xlsx\", sheet_name='Ventas')\n",
99 | "data.head(3)"
100 | ]
101 | },
102 | {
103 | "cell_type": "code",
104 | "execution_count": 4,
105 | "metadata": {},
106 | "outputs": [],
107 | "source": [
108 | "for i in range(len(data)):\n",
109 | " celular = data.loc[i,'Celular'].astype(str) # Convertir a string para que se añada al mensaje\n",
110 | " nombre = data.loc[i,'Nombre']\n",
111 | " producto = data.loc[i,'Producto']\n",
112 | " \n",
113 | " # Crear mensaje personalizado\n",
114 | " mensaje = \"Hola, \" + nombre + \"! Gracias por comprar \" + producto + \" con nosotros 🙌\"\n",
115 | " \n",
116 | " # Abrir una nueva pestaña para entrar a WhatsApp Web\n",
117 | " # Opción 1: Si te abre WhastApp Web directamente en Google Chrome\n",
118 | "# web.open(\"https://web.whatsapp.com/send?phone=\" + celular + \"&text=\" + mensaje)\n",
119 | " \n",
120 | " # Opción 2: Si te abre WhastApp Web en Microsoft Edge, especificar que lo abra en Chrome\n",
121 | " chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'\n",
122 | " web.get(chrome_path).open(\"https://web.whatsapp.com/send?phone=\" + celular + \"&text=\" + mensaje)\n",
123 | " \n",
124 | " time.sleep(8) # Esperar 8 segundos a que cargue\n",
125 | " pg.click(1230,964) # Hacer click en la caja de texto\n",
126 | " time.sleep(2) # Esperar 2 segundos \n",
127 | " pg.press('enter') # Enviar mensaje \n",
128 | " time.sleep(3) # Esperar 3 segundos a que se envíe el mensaje\n",
129 | " pg.hotkey('ctrl', 'w') # Cerrar la pestaña\n",
130 | " time.sleep(2)"
131 | ]
132 | }
133 | ],
134 | "metadata": {
135 | "kernelspec": {
136 | "display_name": "Python 3",
137 | "language": "python",
138 | "name": "python3"
139 | },
140 | "language_info": {
141 | "codemirror_mode": {
142 | "name": "ipython",
143 | "version": 3
144 | },
145 | "file_extension": ".py",
146 | "mimetype": "text/x-python",
147 | "name": "python",
148 | "nbconvert_exporter": "python",
149 | "pygments_lexer": "ipython3",
150 | "version": "3.7.4"
151 | }
152 | },
153 | "nbformat": 4,
154 | "nbformat_minor": 2
155 | }
156 |
--------------------------------------------------------------------------------