You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Ukko](https://en.wikipedia.org/wiki/Ukko) is a code name for a [google script](https://developers.google.com/apps-script) tool accessing gmail inbox threads, looping over them and assigning labels based on the email metadata. It's intended be setup via google drive and have time driven trigger.
[Ukko](https://en.wikipedia.org/wiki/Ukko) is a code name for a [google apps script](https://developers.google.com/apps-script) runs on google servers. It can get emails in your inbox or use search, looping over email threads and assigning labels based on the email metadata. It's intended be setup via google drive and have time driven trigger.
7
20
8
21
# Using on google drive
9
22
1. Access your [google drive](https://en.wikipedia.org/wiki/Ukko), click **New** and select ["Google Apps Script"](https://script.google.com/create).
10
-
2. Name the project "Ukko" and paste the contents of ukko.js, exclude `import` and `export` statements those are used for testing Ukko locally.
23
+
2. Name the project "Ukko" and paste the contents of [modules/ukko.js](https://github.com/T0MASD/ukko/blob/main/modules/ukko.js), exclude `import` and `export` statements those are used for testing Ukko locally.
11
24
3. Click "Run" icon at the top of the editor, you will be prompted to grant access to your gmail.
12
25
4. If there are any messages in your inbox that have header "List-Id" it will create and assign labels.
13
26
@@ -21,12 +34,12 @@
21
34
- "lists/my-list/company"
22
35
- Labelled threads are shown at all nesting levels.
23
36
24
-
**NOTE**: To automatically "archive" the thread after labels are applied, uncomment following line in ukko.js:
25
-
```
37
+
**NOTE**: To automatically "archive" the thread after labels are applied, uncomment following line in [modules/ukko.js](https://github.com/T0MASD/ukko/blob/main/modules/ukko.js):
38
+
```javascript
26
39
if (labels.length) { inboxThread.moveToArchive() }
27
40
```
28
-
Expect similar output:
29
-
```
41
+
Expect similar output when executing the script in google apps script "execution log":
3. Make sure "runUkko" is selected along with "Interval" at which Ukko runs.
39
52
4. Click save and enjoy!
40
53
41
-
# Testing locally
42
-
To try locally you will need [nodejs](https://nodejs.org/en/) and [npm](https://www.npmjs.com/) installed on your machine.
43
-
## Install dependencies
44
-
Pull dependencies (see package.json) locally to `node_modules` dir (feel free to delete it and run `npm install` any time):
45
-
```
54
+
# Developing and testing locally
55
+
To try [ukko](https://github.com/T0MASD/ukko)locally you will need [nodejs](https://nodejs.org/en/) and [npm](https://www.npmjs.com/) installed on your machine.
56
+
## Install javascript dependencies
57
+
To pull javascirpt dependencies (see package.json) locally run `npm install`:
Mocha is used for testing, if you have installed [mocha](https://www.npmjs.com/package/mocha) globally you can call it directly with `mocha`, *OR* via `npm test`:
✓ output list of processed emails with labels applied
76
104
77
105
78
-
3 passing (17ms)
106
+
14 passing (20ms)
79
107
```
80
108
81
109
## Run lint
82
110
Eslint is used for linting all js code, if you have installed [eslint](https://eslint.org/) globally you can call it directly with `eslint .`*OR* via `npm lint`:
Modify `getLabels` function of `modules/ukko.js` to add your own logic for setting up labels.
131
+
Modify `getLabels` function of [modules/ukko.js](https://github.com/T0MASD/ukko/blob/main/modules/ukko.js) to add your own logic for setting up labels. Few example rules are included with ukko, feel free to change to suit your needs.
104
132
105
133
Create "catch all" filters for given domain:
106
-
```
134
+
```javascript
107
135
// process @github.com
108
-
if (message.getFrom().includes('@github.com')) {
136
+
if (messageFrom.includes('@github.com')) {
109
137
labels.push('github')
110
138
}
111
139
```
112
140
Here's an sample to extract GitLab project name from header named `X-GitLab-Project` and assign label `gitlab/projectname`:
0 commit comments