|
| 1 | +# 💬 Dart WhatsApp Bot with Vonage Function |
| 2 | + |
| 3 | +Simple bot to answer WhatsApp messages. |
| 4 | + |
| 5 | +## 🧰 Usage |
| 6 | + |
| 7 | +### GET / |
| 8 | + |
| 9 | +HTML form for interacting with the function. |
| 10 | + |
| 11 | +### POST / |
| 12 | + |
| 13 | +Receives a message, validates its signature, and sends a response back to the sender. |
| 14 | + |
| 15 | +**Parameters** |
| 16 | + |
| 17 | +| Name | Description | Location | Type | Sample Value | |
| 18 | +| ------------- | ---------------------------------- | -------- | ------------------- | -------------------- | |
| 19 | +| Content-Type | Content type of the request | Header | `application/json ` | N/A | |
| 20 | +| Authorization | Webhook signature for verification | Header | String | `Bearer <signature>` | |
| 21 | +| from | Sender's identifier. | Body | String | `12345` | |
| 22 | +| text | Text content of the message. | Body | String | `Hello!` | |
| 23 | + |
| 24 | +> All parameters are coming from Vonage webhook. Exact documentation can be found in [Vonage API Docs](https://developer.vonage.com/en/api/messages-olympus#inbound-message). |
| 25 | +
|
| 26 | +**Response** |
| 27 | + |
| 28 | +Sample `200` Response: |
| 29 | + |
| 30 | +```json |
| 31 | +{ |
| 32 | + "ok": true |
| 33 | +} |
| 34 | +``` |
| 35 | + |
| 36 | +Sample `400` Response: |
| 37 | + |
| 38 | +```json |
| 39 | +{ |
| 40 | + "ok": false, |
| 41 | + "error": "Missing required parameter: from" |
| 42 | +} |
| 43 | +``` |
| 44 | + |
| 45 | +Sample `401` Response: |
| 46 | + |
| 47 | +```json |
| 48 | +{ |
| 49 | + "ok": false, |
| 50 | + "error": "Payload hash mismatch." |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +## ⚙️ Configuration |
| 55 | + |
| 56 | +| Setting | Value | |
| 57 | +| ----------------- | ------------- | |
| 58 | +| Runtime | Dart (3.1) | |
| 59 | +| Entrypoint | `lib/main.dart` | |
| 60 | +| Build Commands | `pub get` | |
| 61 | +| Permissions | `any` | |
| 62 | +| Timeout (Seconds) | 15 | |
| 63 | + |
| 64 | +## 🔒 Environment Variables |
| 65 | + |
| 66 | +### VONAGE_API_KEY |
| 67 | + |
| 68 | +API Key to use the Vonage API. |
| 69 | + |
| 70 | +| Question | Answer | |
| 71 | +| ------------- | ------------------------------------------------------------------------------------------------------------------------ | |
| 72 | +| Required | Yes | |
| 73 | +| Sample Value | `62...97` | |
| 74 | +| Documentation | [Vonage: Q&A](https://api.support.vonage.com/hc/en-us/articles/204014493-How-do-I-find-my-Voice-API-key-and-API-secret-) | |
| 75 | + |
| 76 | +### VONAGE_API_SECRET |
| 77 | + |
| 78 | +Secret to use the Vonage API. |
| 79 | + |
| 80 | +| Question | Answer | |
| 81 | +| ------------- | ------------------------------------------------------------------------------------------------------------------------ | |
| 82 | +| Required | Yes | |
| 83 | +| Sample Value | `Zjc...5PH` | |
| 84 | +| Documentation | [Vonage: Q&A](https://api.support.vonage.com/hc/en-us/articles/204014493-How-do-I-find-my-Voice-API-key-and-API-secret-) | |
| 85 | + |
| 86 | +### VONAGE_API_SIGNATURE_SECRET |
| 87 | + |
| 88 | +Secret to verify the webhooks sent by Vonage. |
| 89 | + |
| 90 | +| Question | Answer | |
| 91 | +| ------------- | -------------------------------------------------------------------------------------------------------------- | |
| 92 | +| Required | Yes | |
| 93 | +| Sample Value | `NXOi3...IBHDa` | |
| 94 | +| Documentation | [Vonage: Webhooks](https://developer.vonage.com/en/getting-started/concepts/webhooks#decoding-signed-webhooks) | |
| 95 | + |
| 96 | +### VONAGE_WHATSAPP_NUMBER |
| 97 | + |
| 98 | +Vonage WhatsApp number to send messages from. |
| 99 | + |
| 100 | +| Question | Answer | |
| 101 | +| ------------- | ----------------------------------------------------------------------------------------------------------------------------- | |
| 102 | +| Required | Yes | |
| 103 | +| Sample Value | `+14000000102` | |
| 104 | +| Documentation | [Vonage: Q&A](https://api.support.vonage.com/hc/en-us/articles/4431993282580-Where-do-I-find-my-WhatsApp-Number-Certificate-) | |
0 commit comments