Add README
Browse files
README.md
CHANGED
|
@@ -1,10 +1,71 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: green
|
| 5 |
-
colorTo:
|
| 6 |
sdk: docker
|
|
|
|
| 7 |
pinned: false
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: WhatsApp Bot
|
| 3 |
+
emoji: π¬
|
| 4 |
colorFrom: green
|
| 5 |
+
colorTo: blue
|
| 6 |
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
pinned: false
|
| 9 |
---
|
| 10 |
|
| 11 |
+
# π¬ WhatsApp Bot on Hugging Face
|
| 12 |
+
|
| 13 |
+
A WhatsApp chatbot powered by AI, deployed as a Docker Space on Hugging Face.
|
| 14 |
+
|
| 15 |
+
## Architecture
|
| 16 |
+
|
| 17 |
+
```
|
| 18 |
+
WhatsApp Cloud API (Meta)
|
| 19 |
+
β
|
| 20 |
+
βΌ HTTPS webhooks
|
| 21 |
+
https://miftahulkhairim-whatsapp-bot.hf.space/webhook
|
| 22 |
+
β
|
| 23 |
+
βΌ
|
| 24 |
+
HF Docker Space (FastAPI, port 7860)
|
| 25 |
+
βββ GET /webhook β Meta webhook verification
|
| 26 |
+
βββ POST /webhook β Receive message β AI reply β Send via WhatsApp API
|
| 27 |
+
βββ GET / β Dashboard UI
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
## Setup Guide
|
| 31 |
+
|
| 32 |
+
### 1. Meta Developer Portal Setup
|
| 33 |
+
|
| 34 |
+
1. Go to [developers.facebook.com](https://developers.facebook.com) β **Create App** β Choose **Business** type
|
| 35 |
+
2. Add the **WhatsApp** product to your app
|
| 36 |
+
3. In WhatsApp β Getting Started, note your:
|
| 37 |
+
- **Phone Number ID**
|
| 38 |
+
- **WhatsApp Business Account ID**
|
| 39 |
+
- **Temporary Access Token** (for testing)
|
| 40 |
+
4. Go to WhatsApp β Configuration β Webhook:
|
| 41 |
+
- **Callback URL**: `https://miftahulkhairim-whatsapp-bot.hf.space/webhook`
|
| 42 |
+
- **Verify Token**: Choose any secret string (e.g., `my_verify_token_2024`)
|
| 43 |
+
- Subscribe to: `messages`
|
| 44 |
+
|
| 45 |
+
### 2. HF Space Secrets
|
| 46 |
+
|
| 47 |
+
Go to Space Settings β **Repository Secrets** and add:
|
| 48 |
+
|
| 49 |
+
| Secret Name | Value |
|
| 50 |
+
|---|---|
|
| 51 |
+
| `WHATSAPP_VERIFY_TOKEN` | Your chosen verify token string |
|
| 52 |
+
| `WHATSAPP_TOKEN` | Meta access token (from Developer Portal) |
|
| 53 |
+
| `PHONE_NUMBER_ID` | Your WhatsApp Phone Number ID |
|
| 54 |
+
| `HF_TOKEN` | Your HF token (for AI inference) |
|
| 55 |
+
|
| 56 |
+
### 3. Deploy
|
| 57 |
+
|
| 58 |
+
The Space auto-builds and deploys when you push changes.
|
| 59 |
+
|
| 60 |
+
## Features
|
| 61 |
+
|
| 62 |
+
- π€ AI-powered responses using Hugging Face Inference API
|
| 63 |
+
- π¬ Handles text messages from WhatsApp
|
| 64 |
+
- π Web dashboard showing bot status and recent messages
|
| 65 |
+
- π Secure webhook verification
|
| 66 |
+
- β‘ Async message processing for fast responses
|
| 67 |
+
|
| 68 |
+
## Notes
|
| 69 |
+
|
| 70 |
+
- Free Spaces sleep after ~15 min of inactivity. Consider upgrading to paid hardware for always-on availability.
|
| 71 |
+
- Access tokens from Meta expire. Use a **System User** permanent token for production.
|