@zerodot/gmail 0.0.0-stage → 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/LICENSE +661 -0
- package/README.md +56 -2
- package/dist/index.cjs +1539 -0
- package/gmail.svg +1 -0
- package/package.json +49 -3
package/README.md
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @zerodot/gmail
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Send, reply to, and draft emails in Gmail. Read, search, label, trash, and delete messages and threads, with attachments as binary data. A trigger starts a run for each new email that matches a query. Connect with Google sign-in or a service account.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
In zerodot, go to **System > Nodes** and install **Gmail**.
|
|
8
|
+
|
|
9
|
+
Manual: install `@zerodot/gmail` where the web app and the worker run, and add it to `ZERODOT_NODE_PACKAGES`.
|
|
10
|
+
|
|
11
|
+
## Nodes
|
|
12
|
+
|
|
13
|
+
### Gmail (`gmail.api`)
|
|
14
|
+
|
|
15
|
+
- **Message**: send, reply, get, get many (search), mark as read, mark as unread, move to trash, restore from trash, delete, add labels, remove labels
|
|
16
|
+
- **Draft**: create, get, get many, delete
|
|
17
|
+
- **Label**: create, get, get many, delete
|
|
18
|
+
- **Thread**: get, get many, move to trash, restore from trash, delete, add labels, remove labels
|
|
19
|
+
|
|
20
|
+
**Send and draft.** Set `to`, `cc`, `bcc`, and `subject`. Use a comma between addresses. A name works: `Nathan Doe <nate@example.com>`. The format is text, HTML, or both. To attach files, put the names of the binary properties of the input in **Attachments**, with commas between. The name of a property is also the content ID of the file. To show an image in the body, use `<img src="cid:image_1">`. **From** must be an alias of the mailbox.
|
|
21
|
+
|
|
22
|
+
**Reply.** The node reads the message, then sends the answer in the same thread. It sets `Re:` in the subject, and the `In-Reply-To` and `References` headers. The answer goes to the `Reply-To` address of the message, or to the sender. **Reply to All** also sends the answer to the other recipients, but not to the mailbox itself.
|
|
23
|
+
|
|
24
|
+
**Get and get many.** **Search** uses the Gmail search syntax, for example `from:ann@example.com has:attachment`. **Labels** limits the search to items with all the labels. **Simplify** gives these fields: `id`, `threadId`, `labelIds`, `snippet`, `internalDate`, `messageId`, `subject`, `from`, `to`, `cc`, `bcc`, `replyTo`, `date`, `text`, `html`, and `attachments` (the file name, type, and size of each file). When Simplify is off, the node gives the full answer of Gmail. **Download Attachments** adds the files to `binary` as `attachment_0`, `attachment_1`, and so on. This works with Simplify only. The size limit of a node output applies to the files.
|
|
25
|
+
|
|
26
|
+
**Labels.** In **Labels**, write label names or IDs with commas between. The node finds the ID of a name without regard to case. System labels, for example `INBOX`, `STARRED`, and `UNREAD`, work as they are. **Mark as read** removes `UNREAD`. **Mark as unread** adds it.
|
|
27
|
+
|
|
28
|
+
**Delete.** **Delete** removes a message, a thread, or a draft for good. Use **Move to Trash** if you want to keep a way back. Gmail removes items from the trash after 30 days.
|
|
29
|
+
|
|
30
|
+
**Get many threads** gives the ID of each thread. Use **Get** with a thread ID to read its messages.
|
|
31
|
+
|
|
32
|
+
### On new email (Gmail) (`gmail.trigger`)
|
|
33
|
+
|
|
34
|
+
A polling trigger. It checks the mailbox on a timer (**Check Every**, 60 seconds by default). It starts one run for each new email. The first check starts no runs. It only sets the start time.
|
|
35
|
+
|
|
36
|
+
- **Search**, **Labels**, **Sender**, and **Read Status** (unread by default) limit the mails.
|
|
37
|
+
- **Include Spam and Trash** adds these folders.
|
|
38
|
+
- **Simplify** and **Download Attachments** work as in the Gmail node.
|
|
39
|
+
- **Action**: **Mark as read** removes `UNREAD` from each mail after the run starts.
|
|
40
|
+
- **Most Mails per Check** limits one check. The next check gets the others.
|
|
41
|
+
|
|
42
|
+
The input of the run is the email. Each mail starts one run only, also when the mail stays unread.
|
|
43
|
+
|
|
44
|
+
## Credentials
|
|
45
|
+
|
|
46
|
+
Scope: `https://mail.google.com/`. Gmail needs this scope to delete messages for good.
|
|
47
|
+
|
|
48
|
+
- **Gmail OAuth2** (`gmail.oauth2`): `clientId` and `clientSecret` of a Google Cloud OAuth client. Sign in with a Google account. zerodot refreshes the token. The client secret and the tokens are secret.
|
|
49
|
+
- **Gmail service account** (`gmail.service_account`): the JSON key file of a service account, as text, and `impersonatedUser`, the email address of the user that the service account acts as. The key is secret. A service account has no mailbox of its own, so you must turn on domain-wide delegation:
|
|
50
|
+
1. In Google Cloud, turn on domain-wide delegation for the service account. Copy its client ID.
|
|
51
|
+
2. In the Google Workspace admin console, go to **Security > API controls > Domain-wide delegation**. Add the client ID with the scope `https://mail.google.com/`.
|
|
52
|
+
|
|
53
|
+
Turn on the Gmail API in the Google Cloud project.
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
AGPL-3.0-only
|