FreudArthur commited on
Commit
bad1b41
·
1 Parent(s): b06514c

Connecting Database : Migration from sqlite3 to Postgree

Browse files
Files changed (6) hide show
  1. .gitignore +2 -1
  2. backup/config +3 -0
  3. docker-compose.yml +13 -3
  4. dump.sql +0 -0
  5. sample.json +130 -0
  6. worflows.json +474 -0
.gitignore CHANGED
@@ -1,4 +1,5 @@
1
  n8n_volume/
2
  *.sqlite
3
  *.sqlite-wal
4
- *.db
 
 
1
  n8n_volume/
2
  *.sqlite
3
  *.sqlite-wal
4
+ *.db
5
+ .env
backup/config ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "encryptionKey": "lfgRSIr7pCVbJNlhuzXUxxdFrEn/wPUv"
3
+ }
docker-compose.yml CHANGED
@@ -6,14 +6,24 @@ services:
6
  container_name: n8n
7
  restart: always
8
  ports:
9
- - "5678:5678"
10
  environment:
11
- - N8N_HOST=localhost
12
  - N8N_PORT=5678
13
  - N8N_PROTOCOL=http
14
  - NODE_ENV=production
15
  - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
16
  - NODE_FUNCTION_ALLOW_EXTERNAL=python
 
 
 
 
 
 
 
 
 
 
17
  volumes:
18
  - "E:/cours ifri/Programmation et BD/Docker/n8n-automatisation/n8n_volume:/home/node/.n8n"
19
 
@@ -24,4 +34,4 @@ services:
24
  - "8000:8000"
25
 
26
  volumes:
27
- n8n_volume:
 
6
  container_name: n8n
7
  restart: always
8
  ports:
9
+ - "7860:5678"
10
  environment:
11
+ - N8N_HOST=0.0.0.0
12
  - N8N_PORT=5678
13
  - N8N_PROTOCOL=http
14
  - NODE_ENV=production
15
  - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
16
  - NODE_FUNCTION_ALLOW_EXTERNAL=python
17
+ - N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
18
+
19
+ - DB_TYPE=postgresdb
20
+ - DB_POSTGRESDB_HOST=${PGHOST}
21
+ - DB_POSTGRESDB_PORT=${PGPORT}
22
+ - DB_POSTGRESDB_DATABASE=${PGDATABASE}
23
+ - DB_POSTGRESDB_USER=${PGUSER}
24
+ - DB_POSTGRESDB_PASSWORD=${PGPASSWORD}
25
+ - DB_POSTGRESDB_SSL_ENABLED=true
26
+ - DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED=false
27
  volumes:
28
  - "E:/cours ifri/Programmation et BD/Docker/n8n-automatisation/n8n_volume:/home/node/.n8n"
29
 
 
34
  - "8000:8000"
35
 
36
  volumes:
37
+ n8n_volume:
dump.sql ADDED
File without changes
sample.json ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nodes": [
3
+ {
4
+ "parameters": {
5
+ "chatId": "6082428873",
6
+ "text": "=_hello_\nWhat's happens today\n{{ $json.explanation }}\n\n",
7
+ "additionalFields": {
8
+ "appendAttribution": false,
9
+ "parse_mode": "HTML"
10
+ }
11
+ },
12
+ "type": "n8n-nodes-base.telegram",
13
+ "typeVersion": 1.2,
14
+ "position": [
15
+ 304,
16
+ -16
17
+ ],
18
+ "id": "5e060d6a-6430-49c8-ba7e-1c988192c2de",
19
+ "name": "Send a text message",
20
+ "webhookId": "0c1cefb9-feb2-40f1-8d56-fd3efdfd7251",
21
+ "credentials": {
22
+ "telegramApi": {
23
+ "id": "xtyS4FnQD7jP4b6g",
24
+ "name": "Telegram account"
25
+ }
26
+ }
27
+ },
28
+ {
29
+ "parameters": {
30
+ "rule": {
31
+ "interval": [
32
+ {
33
+ "field": "seconds"
34
+ }
35
+ ]
36
+ }
37
+ },
38
+ "type": "n8n-nodes-base.scheduleTrigger",
39
+ "typeVersion": 1.3,
40
+ "position": [
41
+ -176,
42
+ -16
43
+ ],
44
+ "id": "b79d01c3-9f5a-4c72-ac2d-2e96df4b031d",
45
+ "name": "Schedule Trigger"
46
+ },
47
+ {
48
+ "parameters": {
49
+ "operation": "sendPhoto",
50
+ "chatId": "6082428873",
51
+ "file": "={{ $('Get the astronomy picture of the day').item.json.url }}",
52
+ "additionalFields": {}
53
+ },
54
+ "type": "n8n-nodes-base.telegram",
55
+ "typeVersion": 1.2,
56
+ "position": [
57
+ 512,
58
+ -16
59
+ ],
60
+ "id": "1ef30f8b-1d20-4414-b1cc-dd57e62c63ba",
61
+ "name": "Send a photo message",
62
+ "webhookId": "c8d34612-6add-4096-bc20-a55d90625c9a",
63
+ "credentials": {
64
+ "telegramApi": {
65
+ "id": "xtyS4FnQD7jP4b6g",
66
+ "name": "Telegram account"
67
+ }
68
+ }
69
+ },
70
+ {
71
+ "parameters": {
72
+ "additionalFields": {}
73
+ },
74
+ "type": "n8n-nodes-base.nasa",
75
+ "typeVersion": 1,
76
+ "position": [
77
+ 112,
78
+ -16
79
+ ],
80
+ "id": "c9cc9387-ce74-4aab-a3d7-fbc2d505f448",
81
+ "name": "Get the astronomy picture of the day",
82
+ "credentials": {
83
+ "nasaApi": {
84
+ "id": "FnPqtSq3RyHqM6Ay",
85
+ "name": "NASA account"
86
+ }
87
+ }
88
+ }
89
+ ],
90
+ "connections": {
91
+ "Send a text message": {
92
+ "main": [
93
+ [
94
+ {
95
+ "node": "Send a photo message",
96
+ "type": "main",
97
+ "index": 0
98
+ }
99
+ ]
100
+ ]
101
+ },
102
+ "Schedule Trigger": {
103
+ "main": [
104
+ [
105
+ {
106
+ "node": "Get the astronomy picture of the day",
107
+ "type": "main",
108
+ "index": 0
109
+ }
110
+ ]
111
+ ]
112
+ },
113
+ "Get the astronomy picture of the day": {
114
+ "main": [
115
+ [
116
+ {
117
+ "node": "Send a text message",
118
+ "type": "main",
119
+ "index": 0
120
+ }
121
+ ]
122
+ ]
123
+ }
124
+ },
125
+ "pinData": {},
126
+ "meta": {
127
+ "templateCredsSetupCompleted": true,
128
+ "instanceId": "48f9007a4d0e1a91936b441574a682e3216460c6ca816348665f2c35d7390c3f"
129
+ }
130
+ }
worflows.json ADDED
@@ -0,0 +1,474 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nodes": [
3
+ {
4
+ "parameters": {
5
+ "updates": [
6
+ "message"
7
+ ],
8
+ "additionalFields": {}
9
+ },
10
+ "id": "f9970906-4d66-4985-a8fb-46a83253031e",
11
+ "name": "Listen for incoming events",
12
+ "type": "n8n-nodes-base.telegramTrigger",
13
+ "position": [
14
+ -1120,
15
+ 80
16
+ ],
17
+ "webhookId": "0474fc6c-1a7d-4a9d-bc34-54b3257ad414",
18
+ "typeVersion": 1,
19
+ "credentials": {
20
+ "telegramApi": {
21
+ "id": "xtyS4FnQD7jP4b6g",
22
+ "name": "Telegram account"
23
+ }
24
+ }
25
+ },
26
+ {
27
+ "parameters": {
28
+ "assignments": {
29
+ "assignments": [
30
+ {
31
+ "id": "allow_1",
32
+ "name": "allow",
33
+ "type": "string",
34
+ "value": "<chat id>"
35
+ }
36
+ ]
37
+ },
38
+ "options": {}
39
+ },
40
+ "id": "911b7e65-1f7c-4681-865b-40a8cc8c4170",
41
+ "name": "AllowList",
42
+ "type": "n8n-nodes-base.set",
43
+ "position": [
44
+ -896,
45
+ 80
46
+ ],
47
+ "typeVersion": 3.4
48
+ },
49
+ {
50
+ "parameters": {
51
+ "conditions": {
52
+ "options": {
53
+ "caseSensitive": true,
54
+ "leftValue": "",
55
+ "typeValidation": "loose",
56
+ "version": 3
57
+ },
58
+ "combinator": "and",
59
+ "conditions": [
60
+ {
61
+ "id": "auth_check",
62
+ "operator": {
63
+ "type": "number",
64
+ "operation": "equals"
65
+ },
66
+ "leftValue": "={{ $('Listen for incoming events').first().json.message.from.id }}",
67
+ "rightValue": "={{ $json.allow }}"
68
+ }
69
+ ]
70
+ },
71
+ "looseTypeValidation": true,
72
+ "options": {}
73
+ },
74
+ "id": "342754af-d745-4d8f-aab0-d4f81bc1743c",
75
+ "name": "If1",
76
+ "type": "n8n-nodes-base.if",
77
+ "position": [
78
+ -672,
79
+ 80
80
+ ],
81
+ "typeVersion": 2.3
82
+ },
83
+ {
84
+ "parameters": {
85
+ "fields": {
86
+ "values": [
87
+ {
88
+ "name": "text",
89
+ "stringValue": "={{ $('Listen for incoming events').item.json.message.text || '' }}"
90
+ },
91
+ {
92
+ "name": "sessionId",
93
+ "stringValue": "={{ $('Listen for incoming events').item.json.message.from.id }}"
94
+ }
95
+ ]
96
+ },
97
+ "options": {}
98
+ },
99
+ "id": "46702015-eacb-45a0-8a82-1baa5cc13bc4",
100
+ "name": "Voice or Text",
101
+ "type": "n8n-nodes-base.set",
102
+ "position": [
103
+ -448,
104
+ 80
105
+ ],
106
+ "typeVersion": 3.2
107
+ },
108
+ {
109
+ "parameters": {
110
+ "conditions": {
111
+ "options": {
112
+ "caseSensitive": true,
113
+ "leftValue": "",
114
+ "typeValidation": "strict",
115
+ "version": 2
116
+ },
117
+ "combinator": "and",
118
+ "conditions": [
119
+ {
120
+ "id": "voice_check",
121
+ "operator": {
122
+ "type": "string",
123
+ "operation": "empty",
124
+ "singleValue": true
125
+ },
126
+ "leftValue": "={{ $('Listen for incoming events').item.json.message.text }}",
127
+ "rightValue": ""
128
+ }
129
+ ]
130
+ },
131
+ "options": {}
132
+ },
133
+ "id": "8884e905-9c26-47c6-b1c9-1b4ed640896b",
134
+ "name": "If",
135
+ "type": "n8n-nodes-base.if",
136
+ "position": [
137
+ -224,
138
+ 80
139
+ ],
140
+ "typeVersion": 2.2
141
+ },
142
+ {
143
+ "parameters": {
144
+ "resource": "file",
145
+ "fileId": "={{ $('Listen for incoming events').item.json.message.voice.file_id }}",
146
+ "additionalFields": {}
147
+ },
148
+ "id": "1603f070-eac2-40f6-9997-cc19b448ada1",
149
+ "name": "Get Voice File",
150
+ "type": "n8n-nodes-base.telegram",
151
+ "position": [
152
+ 0,
153
+ 0
154
+ ],
155
+ "webhookId": "7731f83c-2346-4983-8916-c1360836de7d",
156
+ "typeVersion": 1.1
157
+ },
158
+ {
159
+ "parameters": {
160
+ "resource": "audio",
161
+ "operation": "transcribe",
162
+ "options": {}
163
+ },
164
+ "id": "616213f1-01ae-4e07-a85d-da85a75df75f",
165
+ "name": "Speech to Text",
166
+ "type": "@n8n/n8n-nodes-langchain.openAi",
167
+ "position": [
168
+ 224,
169
+ 0
170
+ ],
171
+ "typeVersion": 1.3
172
+ },
173
+ {
174
+ "parameters": {
175
+ "promptType": "define",
176
+ "text": "={{ $json.text }}",
177
+ "options": {
178
+ "systemMessage": "You are a helpful assistant.\n\nToday's date is {{ $now }}.\n\nGuidelines:\n- When fetching emails, filter out any promotional emails.\n- When summarizing emails, include Sender, Message date, subject, and brief summary of email.\n- if the user did not specify a date in the request assume they are asking for today\n- Use baserow tool to answer questions about tasks\n- When answering questions about calendar events, filter out events that don't apply to the question. For example, the question is about events for today, only reply with events for today. Don't mention future events if it's more than 1 week away"
179
+ }
180
+ },
181
+ "id": "f4aad433-122b-4247-b159-6d2a40549938",
182
+ "name": "Angie, AI Assistant",
183
+ "type": "@n8n/n8n-nodes-langchain.agent",
184
+ "position": [
185
+ 704,
186
+ 80
187
+ ],
188
+ "typeVersion": 3.1
189
+ },
190
+ {
191
+ "parameters": {
192
+ "options": {}
193
+ },
194
+ "id": "03a33ec8-b4f0-4e98-9fe6-616bda6b5a41",
195
+ "name": "OpenAI Chat Model",
196
+ "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
197
+ "position": [
198
+ 448,
199
+ 304
200
+ ],
201
+ "typeVersion": 1
202
+ },
203
+ {
204
+ "parameters": {
205
+ "sessionIdType": "customKey",
206
+ "sessionKey": "angie_session_default",
207
+ "contextWindowLength": 10
208
+ },
209
+ "id": "9b74e818-3241-4e65-beec-063ce2be804d",
210
+ "name": "Simple Memory",
211
+ "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
212
+ "position": [
213
+ 576,
214
+ 304
215
+ ],
216
+ "typeVersion": 1.3
217
+ },
218
+ {
219
+ "parameters": {
220
+ "databaseId": 146496,
221
+ "tableId": 372174,
222
+ "additionalOptions": {}
223
+ },
224
+ "id": "6e15db3c-0e61-4b44-b002-351dd739398b",
225
+ "name": "Tasks",
226
+ "type": "n8n-nodes-base.baserowTool",
227
+ "position": [
228
+ 704,
229
+ 304
230
+ ],
231
+ "typeVersion": 1
232
+ },
233
+ {
234
+ "parameters": {
235
+ "descriptionType": "manual",
236
+ "toolDescription": "Useful for getting contact information. For example emails or phone numbers.",
237
+ "databaseId": 146496,
238
+ "tableId": 372177,
239
+ "additionalOptions": {}
240
+ },
241
+ "id": "5566f43b-eb18-4bc8-9ba9-f3fc466253e8",
242
+ "name": "Contacts",
243
+ "type": "n8n-nodes-base.baserowTool",
244
+ "position": [
245
+ 832,
246
+ 304
247
+ ],
248
+ "typeVersion": 1
249
+ },
250
+ {
251
+ "parameters": {
252
+ "operation": "getAll",
253
+ "calendar": {
254
+ "__rl": true,
255
+ "mode": "list",
256
+ "value": "user@example.com"
257
+ },
258
+ "options": {
259
+ "timeMin": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('date', 'the date after which to fetch the messages in format YYYY-MM-DDTHH:MM:SS') }}",
260
+ "fields": "=items(summary, start(dateTime))"
261
+ }
262
+ },
263
+ "id": "bf450ea8-0144-4cf6-bb99-3d479b37063b",
264
+ "name": "Google Calendar",
265
+ "type": "n8n-nodes-base.googleCalendarTool",
266
+ "position": [
267
+ 960,
268
+ 304
269
+ ],
270
+ "typeVersion": 1.1
271
+ },
272
+ {
273
+ "parameters": {
274
+ "chatId": "={{ $('Listen for incoming events').first().json.message.from.id }}",
275
+ "text": "={{ $json.output }}",
276
+ "additionalFields": {
277
+ "appendAttribution": false,
278
+ "parse_mode": "Markdown"
279
+ }
280
+ },
281
+ "id": "e9cf83cb-b0f3-4309-96a9-e081d9c329e6",
282
+ "name": "Telegram",
283
+ "type": "n8n-nodes-base.telegram",
284
+ "position": [
285
+ 1296,
286
+ 80
287
+ ],
288
+ "webhookId": "40027a52-0dce-4542-a6ec-496040e9d094",
289
+ "typeVersion": 1.1
290
+ },
291
+ {
292
+ "parameters": {
293
+ "operation": "getAll",
294
+ "filters": {}
295
+ },
296
+ "id": "7b64557f-b030-4e62-ab52-f39abeb2794e",
297
+ "name": "Get many messages in Gmail",
298
+ "type": "n8n-nodes-base.gmailTool",
299
+ "position": [
300
+ 1088,
301
+ 304
302
+ ],
303
+ "webhookId": "48dd8198-8fd5-4cfc-897c-72cbc15d319f",
304
+ "typeVersion": 2.2
305
+ }
306
+ ],
307
+ "connections": {
308
+ "Listen for incoming events": {
309
+ "main": [
310
+ [
311
+ {
312
+ "node": "AllowList",
313
+ "type": "main",
314
+ "index": 0
315
+ }
316
+ ]
317
+ ]
318
+ },
319
+ "AllowList": {
320
+ "main": [
321
+ [
322
+ {
323
+ "node": "If1",
324
+ "type": "main",
325
+ "index": 0
326
+ }
327
+ ]
328
+ ]
329
+ },
330
+ "If1": {
331
+ "main": [
332
+ [
333
+ {
334
+ "node": "Voice or Text",
335
+ "type": "main",
336
+ "index": 0
337
+ }
338
+ ]
339
+ ]
340
+ },
341
+ "Voice or Text": {
342
+ "main": [
343
+ [
344
+ {
345
+ "node": "If",
346
+ "type": "main",
347
+ "index": 0
348
+ }
349
+ ]
350
+ ]
351
+ },
352
+ "If": {
353
+ "main": [
354
+ [
355
+ {
356
+ "node": "Get Voice File",
357
+ "type": "main",
358
+ "index": 0
359
+ }
360
+ ],
361
+ [
362
+ {
363
+ "node": "Angie, AI Assistant",
364
+ "type": "main",
365
+ "index": 0
366
+ }
367
+ ]
368
+ ]
369
+ },
370
+ "Get Voice File": {
371
+ "main": [
372
+ [
373
+ {
374
+ "node": "Speech to Text",
375
+ "type": "main",
376
+ "index": 0
377
+ }
378
+ ]
379
+ ]
380
+ },
381
+ "Speech to Text": {
382
+ "main": [
383
+ [
384
+ {
385
+ "node": "Angie, AI Assistant",
386
+ "type": "main",
387
+ "index": 0
388
+ }
389
+ ]
390
+ ]
391
+ },
392
+ "Angie, AI Assistant": {
393
+ "main": [
394
+ [
395
+ {
396
+ "node": "Telegram",
397
+ "type": "main",
398
+ "index": 0
399
+ }
400
+ ]
401
+ ]
402
+ },
403
+ "OpenAI Chat Model": {
404
+ "ai_languageModel": [
405
+ [
406
+ {
407
+ "node": "Angie, AI Assistant",
408
+ "type": "ai_languageModel",
409
+ "index": 0
410
+ }
411
+ ]
412
+ ]
413
+ },
414
+ "Simple Memory": {
415
+ "ai_memory": [
416
+ [
417
+ {
418
+ "node": "Angie, AI Assistant",
419
+ "type": "ai_memory",
420
+ "index": 0
421
+ }
422
+ ]
423
+ ]
424
+ },
425
+ "Tasks": {
426
+ "ai_tool": [
427
+ [
428
+ {
429
+ "node": "Angie, AI Assistant",
430
+ "type": "ai_tool",
431
+ "index": 0
432
+ }
433
+ ]
434
+ ]
435
+ },
436
+ "Contacts": {
437
+ "ai_tool": [
438
+ [
439
+ {
440
+ "node": "Angie, AI Assistant",
441
+ "type": "ai_tool",
442
+ "index": 0
443
+ }
444
+ ]
445
+ ]
446
+ },
447
+ "Google Calendar": {
448
+ "ai_tool": [
449
+ [
450
+ {
451
+ "node": "Angie, AI Assistant",
452
+ "type": "ai_tool",
453
+ "index": 0
454
+ }
455
+ ]
456
+ ]
457
+ },
458
+ "Get many messages in Gmail": {
459
+ "ai_tool": [
460
+ [
461
+ {
462
+ "node": "Angie, AI Assistant",
463
+ "type": "ai_tool",
464
+ "index": 0
465
+ }
466
+ ]
467
+ ]
468
+ }
469
+ },
470
+ "pinData": {},
471
+ "meta": {
472
+ "instanceId": "48f9007a4d0e1a91936b441574a682e3216460c6ca816348665f2c35d7390c3f"
473
+ }
474
+ }