@zerodot/whatsapp 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +52 -2
- package/dist/index.cjs +1082 -0
- package/package.json +46 -3
- package/whatsapp.svg +1 -0
package/README.md
CHANGED
|
@@ -1,3 +1,53 @@
|
|
|
1
|
-
#
|
|
1
|
+
# WhatsApp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Send WhatsApp messages with the **WhatsApp Business Cloud API** of Meta. Upload and manage media. Wait for an answer from a person. Start a workflow on WhatsApp webhook events.
|
|
4
|
+
|
|
5
|
+
The node speaks to the Graph API (`graph.facebook.com`). The version is a field of the node. The default is `v23.0`.
|
|
6
|
+
|
|
7
|
+
## Setup
|
|
8
|
+
|
|
9
|
+
1. Create an app at [developers.facebook.com/apps](https://developers.facebook.com/apps), of type Business. Add the **WhatsApp** product.
|
|
10
|
+
2. Open **WhatsApp > API Setup**. Copy the **Phone number ID** and the **WhatsApp Business Account ID**.
|
|
11
|
+
3. Make a permanent access token with a System User of the business. The token on the API Setup page ends in 24 hours.
|
|
12
|
+
4. Make the credential **WhatsApp API** with the access token and the Business Account ID.
|
|
13
|
+
|
|
14
|
+
For the trigger, make the credential **WhatsApp Trigger API** with the **App ID** and the **App secret** (App Settings > Basic).
|
|
15
|
+
|
|
16
|
+
## Message
|
|
17
|
+
|
|
18
|
+
| Operation | What it does |
|
|
19
|
+
| -------------------------- | ----------------------------------------------------------------------------------------------- |
|
|
20
|
+
| Send | Sends a text, audio, document, image, video, location, or contacts message |
|
|
21
|
+
| Send and Wait for Response | Sends a text message with links. The workflow stops until the user answers, or the time is over |
|
|
22
|
+
| Send Template | Sends a template that Meta approved, with body, header, and button parameters |
|
|
23
|
+
- The phone number of the recipient needs the country code. The characters `+ - ( )` are removed.
|
|
24
|
+
- Give the **Sender Phone Number ID** (`phoneNumberId`) of the business account.
|
|
25
|
+
- A template is `name|language`, for example `hello_world|en_US`.
|
|
26
|
+
- A file can come from a **Link**, a **WhatsApp Media** ID, or the **Binary Data** of the input. WhatsApp downloads a link by itself. Binary data is uploaded first, and then sent.
|
|
27
|
+
- Send and Wait has an approval (one or two links), a free text answer, or a custom form.
|
|
28
|
+
|
|
29
|
+
## Media
|
|
30
|
+
|
|
31
|
+
| Operation | What it does |
|
|
32
|
+
| --------- | ------------------------------------------------------- |
|
|
33
|
+
| Upload | Uploads the binary data of the input and returns its ID |
|
|
34
|
+
| Download | Returns the URL and the details of a media ID |
|
|
35
|
+
| Delete | Deletes a media ID |
|
|
36
|
+
|
|
37
|
+
## Trigger
|
|
38
|
+
|
|
39
|
+
The WhatsApp Trigger subscribes your Meta app to the events that you select, and starts the workflow for each event.
|
|
40
|
+
|
|
41
|
+
- Events: Account Review Update, Account Update, Business Capability Update, Message Template Quality Update, Message Template Status Update, Messages, Phone Number Name Update, Phone Number Quality Update, Security, and Template Category Update.
|
|
42
|
+
- Option **Receive Message Status Updates**: select which statuses (`sent`, `delivered`, `read`, `failed`, `deleted`) start the workflow.
|
|
43
|
+
- Meta allows one webhook subscription for each app. A second trigger on the same app replaces the first.
|
|
44
|
+
- The trigger answers the `hub.challenge` check of Meta. The verify token is the ID of the trigger node.
|
|
45
|
+
- Each event has an `X-Hub-Signature-256` signature. The trigger checks it with the App secret.
|
|
46
|
+
- Each item has the `value` of one change, and its `field`.
|
|
47
|
+
|
|
48
|
+
## Development
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
pnpm test
|
|
52
|
+
pnpm build
|
|
53
|
+
```
|