File size: 9,749 Bytes
51d1d83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
{
  "nodes": [
    {
      "id": "678e86bc-2755-4c79-97d6-fa4da1ed9ff9",
      "name": "Postgres Trigger",
      "type": "n8n-nodes-base.postgresTrigger",
      "disabled": true,
      "position": [
        500,
        480
      ],
      "parameters": {
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "computed",
          "cachedResultName": "computed"
        },
        "firesOn": "UPDATE",
        "tableName": {
          "__rl": true,
          "mode": "list",
          "value": "users",
          "cachedResultName": "users"
        },
        "additionalFields": {}
      },
      "credentials": {
        "postgres": {
          "id": "8",
          "name": "Postgres Product Analytics"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "accecdfc-283c-4119-9b23-4cf44bc5e68c",
      "name": "Filter",
      "type": "n8n-nodes-base.filter",
      "notes": "Filter out @n8n.io emails",
      "position": [
        980,
        540
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.email }}",
              "value2": "n8n.io",
              "operation": "notContains"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "d16d7ae7-0c60-48f0-97fe-c7618cab73d3",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        380
      ],
      "parameters": {
        "width": 424,
        "height": 559,
        "content": "## 👋 How to use this template\nThis template shows how to sync data from one service to another. In this example we're saving a new qualified lead to a Google Sheets file. Here's how you can test the template:\n\n1. Duplicate our [Google Sheets](https://docs.google.com/spreadsheets/d/1gVfyernVtgYXD-oPboxOSJYQ-HEfAguEryZ7gTtK0V8/edit?usp=sharing) file\n2. Double click the `Google Sheets` node and create a credential by signing in.\n3. Select the correct Google Sheets document and sheet.\n4. Click the `Execute Workflow` button and double click the nodes to see the input and output data\n\n### To customize it to you needs, just do the following:\n1. Enable or exchange the `Postgres trigger` with any service that fits your use case.\n2. Change the `Filter` to fit your needs\n3. Adjust the Google Sheets node as described above\n4. Disable or remove the `On clicking \"Execute Node\"` and `Code` node\n"
      },
      "typeVersion": 1
    },
    {
      "id": "8bc7439e-d814-4960-8b75-fc77805f74c7",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        460,
        380
      ],
      "parameters": {
        "width": 344,
        "height": 562,
        "content": "### 1. Trigger step listens for new events\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "63b2bc4c-8e33-4432-af4b-4595b2012ce1",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        840,
        460
      ],
      "parameters": {
        "width": 462,
        "height": 407,
        "content": "### 2. Filter and transform your data\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nIn this case, we only want to save qualified users that don't have `@n8n.io` in their email address.\n\nTo edit the filter, simply drag and drop input data into the fields or change the values directly. **Besides filters, n8n has other powerful transformation nodes like [Set](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.set/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.set), [ItemList](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.itemlists/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.itemLists), [Code](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.code/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.code) and many more.**"
      },
      "typeVersion": 1
    },
    {
      "id": "448e2c49-aa75-405b-ba51-3acbce0fb758",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1340,
        460
      ],
      "parameters": {
        "width": 342.52886836027733,
        "height": 407.43618112665195,
        "content": "### 3. Save the user in a Google Sheet\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nFor simplicity, we're saving our qualified user in a Google Sheet.\n\n**You can replace this node with any service like [Excel](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.microsoftexcel/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.microsoftExcel), [HubSpot](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.hubspot/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.hubspot), [Pipedrive](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.pipedrive/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.pipedrive), [Zendesk](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.zendesk/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.zendesk) etc.**"
      },
      "typeVersion": 1
    },
    {
      "id": "c0ee182d-4c31-488b-a547-5f2d2ba8786e",
      "name": "On clicking \"Execute Node\"",
      "type": "n8n-nodes-base.manualTrigger",
      "notes": "For testing the workflow",
      "position": [
        500,
        680
      ],
      "parameters": {},
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "87f2a11e-f704-4c9e-ac8b-ee1f057cd347",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "notes": "Mock Data",
      "position": [
        680,
        680
      ],
      "parameters": {
        "jsCode": "return [\n  {\n    \"id\": 1,\n    \"username\": \"max_mustermann\",\n    \"email\": \"max_mustermann@acme.com\",\n    \"company_size\": \"500-999\",\n    \"role\": \"Sales\",\n    \"users\": 50\n  }\n]"
      },
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "0992077f-b6d3-47d2-94d2-c612dfbf5062",
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "notes": "Add to \"Users to contact\"",
      "position": [
        1400,
        540
      ],
      "parameters": {
        "columns": {
          "value": {
            "id": "={{ $json.id }}",
            "email": "={{ $json.email }}",
            "username": "={{ $json.username }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "username",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "username",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "contacted",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "contacted",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "id"
          ]
        },
        "options": {
          "cellFormat": "USER_ENTERED"
        },
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1gVfyernVtgYXD-oPboxOSJYQ-HEfAguEryZ7gTtK0V8/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1gVfyernVtgYXD-oPboxOSJYQ-HEfAguEryZ7gTtK0V8",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1gVfyernVtgYXD-oPboxOSJYQ-HEfAguEryZ7gTtK0V8/edit?usp=drivesdk",
          "cachedResultName": "Qualified leads to contact"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "9",
          "name": "Google Sheets account"
        }
      },
      "notesInFlow": true,
      "typeVersion": 4
    }
  ],
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Trigger": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On clicking \"Execute Node\"": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}