@zerodot/brevo 1.0.0 → 1.0.1
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/README.md +77 -0
- package/dist/index.cjs +7 -1
- package/package.json +2 -1
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# @zerodot/brevo
|
|
2
|
+
|
|
3
|
+
<img src="https://raw.githubusercontent.com/zerodot-io/nodes/main/packages/brevo/brevo.svg" alt="Brevo logo" width="48" height="48">
|
|
4
|
+
|
|
5
|
+
Manage contacts and send transactional emails in Brevo. The node creates, gets, lists, updates, and deletes contacts. It also sends a transactional email with the Brevo API. Connect with a Brevo API key.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
In zerodot, go to **System > Nodes** and install **Brevo**.
|
|
10
|
+
|
|
11
|
+
Manual: install `@zerodot/brevo` where the web app and the worker run, and add it to `ZERODOT_NODE_PACKAGES`.
|
|
12
|
+
|
|
13
|
+
## Nodes
|
|
14
|
+
|
|
15
|
+
### Brevo (`brevo.api`)
|
|
16
|
+
|
|
17
|
+
- **Contact**: create, get, get many, update, delete
|
|
18
|
+
- **Transactional Email**: send
|
|
19
|
+
|
|
20
|
+
The node has no trigger.
|
|
21
|
+
|
|
22
|
+
**Create a contact.** Set `email`. It is required. You can also set `attributes` (for example `FIRSTNAME`), `listIds`, `extId`, and `updateEnabled`. When `updateEnabled` is on, Brevo updates an existing contact.
|
|
23
|
+
|
|
24
|
+
**Get, update, and delete a contact.** Set `identifier`. It is required. Set **Identifier Type** (`identifierType`) to match it:
|
|
25
|
+
|
|
26
|
+
- **Email**: the identifier is an email address (default).
|
|
27
|
+
- **External ID**: the identifier is the external ID (`ext_id`).
|
|
28
|
+
- **Contact ID**: the identifier is the numeric contact ID.
|
|
29
|
+
|
|
30
|
+
The identifier is encoded in the URL path.
|
|
31
|
+
|
|
32
|
+
**Update.** Change `attributes`, `listIds` (add the contact to these lists), `unlinkListIds` (remove it from these lists), `emailBlacklisted`, and `smsBlacklisted`. Empty fields are not sent.
|
|
33
|
+
|
|
34
|
+
**Delete.** **Delete** removes the contact for good. The node does not ask for a confirmation.
|
|
35
|
+
|
|
36
|
+
**Get many contacts.** The node calls the contact list of Brevo. It returns an array of contacts. Each item is one contact object.
|
|
37
|
+
|
|
38
|
+
- `filters.sort`: `asc` (Oldest First) or `desc` (Newest First), by creation date.
|
|
39
|
+
- `filters.modifiedSince` and `filters.createdSince`: only contacts changed or created after this date. Use the format `YYYY-MM-DDTHH:mm:ss.SSSZ`.
|
|
40
|
+
- `filters.filter`: a Brevo filter expression, for example `equals(FIRSTNAME,"Ada")`.
|
|
41
|
+
- `returnAll`: off by default. When it is off, `limit` sets the number of contacts (1 to 5000, default 50). When it is on, the node gets all contacts that match, up to 5000.
|
|
42
|
+
|
|
43
|
+
**Pagination.** The node pages through the list with `limit` and `offset`, up to 100 contacts per request. It stops when it has the number of items it needs, or when Brevo has no more items. The output is never more than 5000 items.
|
|
44
|
+
|
|
45
|
+
**Send a transactional email.** Set:
|
|
46
|
+
|
|
47
|
+
- `sender.email`, required. `sender.name` is optional.
|
|
48
|
+
- `to`, required. One or more recipients. Each has an `email` and an optional `name`.
|
|
49
|
+
- Content, required. Set `templateId`, `htmlContent`, or `textContent`. The node checks that at least one is set. With a template, the template provides the content.
|
|
50
|
+
- `subject`, required when `templateId` is not set. The node checks that it is set in that case.
|
|
51
|
+
|
|
52
|
+
Other fields: `replyTo` (an email and an optional name), `params` (template or message parameters), and `tags`.
|
|
53
|
+
|
|
54
|
+
**Output.** A send returns the answer of Brevo, for example `{ "messageId": "..." }`. Get many returns an array. Other operations return the JSON answer of Brevo. Any operation returns `{ "success": true }` when Brevo answers with no body, for example on delete or update. The node does not use binary data.
|
|
55
|
+
|
|
56
|
+
**Destructive operations.** **Delete** removes a contact. It cannot be undone from zerodot.
|
|
57
|
+
|
|
58
|
+
**Requests and limits.** The node sends each request with the `api-key` header. A redirect is an error. **Timeout** (`timeoutMs`) is the limit for each request. The default is 30000 ms. The range is 1 to 300000 ms.
|
|
59
|
+
|
|
60
|
+
**Errors.** An error names the call and the HTTP status. It adds the message and the error code of Brevo, when Brevo sends them. The error never includes the API key. For status 429 the error says that Brevo limits the requests. It adds the number of seconds from the `Retry-After` header, when the header is set. The node does not retry.
|
|
61
|
+
|
|
62
|
+
## Credentials
|
|
63
|
+
|
|
64
|
+
### Brevo API key (`brevo.apiKey`)
|
|
65
|
+
|
|
66
|
+
- **API Key** (`apiKey`), required, secret. The Brevo API key.
|
|
67
|
+
|
|
68
|
+
Setup:
|
|
69
|
+
|
|
70
|
+
1. In Brevo, open **SMTP & API** settings and create an API key.
|
|
71
|
+
2. Copy the key.
|
|
72
|
+
3. In zerodot, create a **Brevo API key** credential. Paste the key into **API Key**.
|
|
73
|
+
4. Test the credential. The test calls the account endpoint of Brevo.
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
AGPL-3.0-only
|
package/dist/index.cjs
CHANGED
|
@@ -291,7 +291,7 @@ const brevoConfig = zod.z.object({
|
|
|
291
291
|
}),
|
|
292
292
|
subject: zod.z.string().optional().meta({
|
|
293
293
|
...on({ transactionalEmail: ["send"] }),
|
|
294
|
-
description: "The subject of the email. Required
|
|
294
|
+
description: "The subject of the email. Required when Template ID is not set"
|
|
295
295
|
}),
|
|
296
296
|
htmlContent: zod.z.string().optional().meta({
|
|
297
297
|
...on({ transactionalEmail: ["send"] }),
|
|
@@ -347,6 +347,11 @@ const brevoConfig = zod.z.object({
|
|
|
347
347
|
path: ["to"],
|
|
348
348
|
message: "transactionalEmail.send needs at least one \"to\" recipient"
|
|
349
349
|
});
|
|
350
|
+
if (!config.templateId && !config.subject?.trim()) context.addIssue({
|
|
351
|
+
code: "custom",
|
|
352
|
+
path: ["subject"],
|
|
353
|
+
message: "transactionalEmail.send needs \"subject\" when there is no \"templateId\""
|
|
354
|
+
});
|
|
350
355
|
if (!config.templateId && !config.htmlContent && !config.textContent) context.addIssue({
|
|
351
356
|
code: "custom",
|
|
352
357
|
path: ["htmlContent"],
|
|
@@ -445,6 +450,7 @@ function buildRequest(c) {
|
|
|
445
450
|
replyTo: recipientOf(c.replyTo),
|
|
446
451
|
tags: c.tags.length > 0 ? c.tags : void 0
|
|
447
452
|
});
|
|
453
|
+
if (!body.templateId && !body.subject) throw new Error(`Brevo ${op} needs "subject" when there is no "templateId"`);
|
|
448
454
|
if (!body.templateId && !body.htmlContent && !body.textContent) throw new Error(`Brevo ${op} needs "templateId", "htmlContent", or "textContent"`);
|
|
449
455
|
return { call: {
|
|
450
456
|
method: "POST",
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerodot/brevo",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Manage contacts and send transactional emails in Brevo.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
|
+
"homepage": "https://github.com/zerodot-io/nodes/tree/main/packages/brevo",
|
|
6
7
|
"repository": {
|
|
7
8
|
"type": "git",
|
|
8
9
|
"url": "git+https://github.com/zerodot-io/nodes.git",
|