Spaces:
Building
Building
File size: 4,660 Bytes
ba5c923 |
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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
<div align="center">
<h1>
<img src="https://github.com/Zain-ul-din/whatsapp-ai-bot/assets/78583049/d31339cf-b4ae-450e-95b9-53d21e4641a0" width="35" height="35"/>
WhatsApp Ping π</h1>
</div>
Catching messages on Gmail from clients always has me running late, and checking it over and over can be a real drag. That's why I created `whatsapp ping`! It lets me ping myself on WhatsApp using a webhook.
https://github.com/user-attachments/assets/f46a909d-a0c8-4cd1-9fcb-56dce1e3d40b

### Use Cases
few use cases of this project generated by gpt.
- π Instant Notifications: Get WhatsApp alerts for important client emails.
- π¬ Stay Connected: Easily send quick messages to your team or clients.
- π
Task Reminders: Schedule pings to remind yourself of upcoming tasks.
- π Timely Notification: Wish your friend a happy birthday right on time.
- π¨βπ» Programmatic Use: Thanks to webhooks, integrate notifications into any app or service.
### Usage
clone or fork the repo and install all dependencies using your favorite package manager. In my case, i'm using `pnpm`.
```bash
pnpm i
```
**Prepare environment variables:**
you need two env variables to make this work
```env
API_KEY=YOUR_API_KEY
MONGO_URL=your_url
# optional
SELF_HOSTED=boolean -> set to true if running in self-hosted environment
LOCAL=boolean -> for development purposes
NEXT_MSG_DELAY=number > delays between next message
```
We use `api-key` for authentication you can use any key you like to use but we recommend using strong key that is not vulnerable to `brute-force` attack.
```bash
openssl rand -base64 256
```
To run this bot in a serverless environment, we use MongoDB to manage the authentication state.
You can Get the MongoDB URL for free from their [website](https://www.mongodb.com/).
```js
mongodb+srv://<user_name>:<password>@cluster0.usggwa4.mongodb.net/?retryWrites=true&w=majority
```
**start the server using the following command:**
```bash
pnpm dev # start development server
OR
pnpm start # start server in production
```
After starting the server, it will print QR code in the terminal scan it using your phone to connect whatsapp.
### β Web Hook Usage
Next use web hook as following to send a message,
```c
curl -X POST localhost:8080/ping \
-H "Authorization: Bearer $YOUR_API_KEY"
-d '{
"message": "hello world",
"numbers": ["123456789012"]
}'
```
using js,
```js
fetch("http://localhost:8080/ping", {
headers: {
Authorization: "Bearer YOUR_KEY",
"Content-Type": "application/json"
},
method: "POST",
body: JSON.stringify({
message: "hey",
image: "optional BASE64 image",
numbers: ["<country_code_without_plus><...number>"]
})
})
.then((res) => res.text())
.then((res) => console.log(res));
```
### Caveats
```diff
- If you plan to deploy this project, it currently works only on VPS and not in a serverless environment. This means you will not be able to deploy it to the Vercel or other serverless providers.
+ We just added support for serverless deployment https://github.com/Zain-ul-din/whatsapp-ping/issues/2
```
<br>
## π» Sponsors
A big thank you to these people for supporting this project.
<table>
<thead>
<tr>
<th>
<img src="https://avatars.githubusercontent.com/u/97310455?v=4" width="150" height="150" />
</th>
<th>
<img src="https://avatars.githubusercontent.com/u/0?v=4" width="150" height="150"/>
</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">
<a target="_blank" href="https://github.com/levitco">Ahtisham Abbas Qureshi</a>
</td>
<td align="center">
<a target="_blank" href="https://www.buymeacoffee.com/zainuldin">YOU?</a>
</td>
</tr>
</tbody>
</table>
#### Thanks to These Awesome Projects:
- [@whiskeysockets/baileys](https://www.npmjs.com/package/@whiskeysockets/baileys)
- [mongo-baileys](https://www.npmjs.com/package/mongo-baileys)
---
<div align="center">
<h4 font-weight="bold">This repository is maintained by <a href="https://github.com/Zain-ul-din">Zain-Ul-Din</a></h4>
<p> Show some β€οΈ by starring this awesome repository! </p>
</div>
<div align="center">
<a href="https://www.buymeacoffee.com/zainuldin" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>
</div>
|