-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMy workflow.json
More file actions
2063 lines (2063 loc) · 63.7 KB
/
My workflow.json
File metadata and controls
2063 lines (2063 loc) · 63.7 KB
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"name": "My workflow",
"nodes": [
{
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n \"type\": \"object\",\n \"properties\": {\n \"learnings\": {\n \"type\": \"array\",\n \"description\": \"List of learnings, max of 3.\",\n \"items\": { \"type\": \"string\" }\n },\n \"followUpQuestions\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\",\n \"description\": \"List of follow-up questions to research the topic further, max of 3.\"\n }\n }\n }\n}"
},
"id": "bae48bc0-343c-45b5-8681-71be6d655eb0",
"name": "Structured Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
3728,
2368
],
"typeVersion": 1.2
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "df28b12e-7c20-4ff5-b5b8-dc773aa14d4b",
"name": "request_id",
"type": "string",
"value": "={{ $execution.id }}"
},
{
"id": "9362c1e7-717d-444a-8ea2-6b5f958c9f3f",
"name": "prompt",
"type": "string",
"value": "={{ $json['What would you like to research?'] }}"
},
{
"id": "09094be4-7844-4a9e-af82-cc8e39322398",
"name": "depth",
"type": "number",
"value": "={{ $json['input-depth'] }}"
},
{
"id": "3fc30a30-7806-4013-835d-97e27ddd7ae1",
"name": "breadth",
"type": "number",
"value": "={{ $json['input-breadth'] }}"
}
]
},
"options": {}
},
"id": "5c6a8188-5ef7-447c-be2e-990f0a55562f",
"name": "Set Variables",
"type": "n8n-nodes-base.set",
"position": [
1072,
720
],
"typeVersion": 3.4
},
{
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n \"type\": \"object\",\n \"properties\": {\n \"questions\": {\n \"type\": \"array\",\n \"description\": \"Follow up questions to clarify the research direction, max of 3.\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n }\n}"
},
"id": "5cb34e23-33dc-4e41-b57b-9bc32d3ffd18",
"name": "Structured Output Parser1",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
1584,
880
],
"typeVersion": 1.2
},
{
"parameters": {
"formTitle": " DeepResearcher",
"formDescription": "=DeepResearcher is a multi-step, recursive approach using the internet to solve complex research tasks, accomplishing in tens of minutes what a human would take many hours.\n\nTo use, provide a short summary of what the research and how \"deep\" you'd like the workflow to investigate. Note, the higher the numbers the more time and cost will occur for the research.\n\nThe workflow is designed to complete independently and when finished, a report will be saved in a Github Repo.",
"options": {
"buttonLabel": "Next",
"path": "deep_research",
"ignoreBots": true
}
},
"id": "b8da4808-eacc-4a66-82c2-48811b49e956",
"name": "On form submission",
"type": "n8n-nodes-base.formTrigger",
"position": [
672,
720
],
"webhookId": "026629c8-7644-493c-b830-d9c72eea307d",
"typeVersion": 2.2
},
{
"parameters": {
"promptType": "define",
"text": "=Given the following prompt from the user, generate a list of SERP queries to research the topic.\nReduce the number of words in each query to its keywords only.\nReturn a maximum of {{ $('JobType Router').first().json.data.breadth }} queries, but feel free to return less if the original prompt is clear. Make sure each query is unique and not similar to each other: <prompt>{{ $('JobType Router').first().json.data.query.trim() }}</prompt>\n\n{{\n$('JobType Router').first().json.data.learnings.length\n ? `Here are some learnings from previous research, use them to generate more specific queries:\\n${$('JobType Router').first().json.data.learnings.map(text => `* ${text}`).join('\\n')}`\n : ''\n}}",
"hasOutputParser": true,
"messages": {
"messageValues": [
{
"type": "HumanMessagePromptTemplate",
"message": "=You are an expert researcher. Today is {{ $now.toLocaleString() }}. Follow these instructions when responding:\n - You may be asked to research subjects that is after your knowledge cutoff, assume the user is right when presented with news.\n - The user is a highly experienced analyst, no need to simplify it, be as detailed as possible and make sure your response is correct.\n - Be highly organized.\n - Suggest solutions that I didn't think about.\n - Be proactive and anticipate my needs.\n - Treat me as an expert in all subject matter.\n - Mistakes erode my trust, so be accurate and thorough.\n - Provide detailed explanations, I'm comfortable with lots of detail.\n - Value good arguments over authorities, the source is irrelevant.\n - Consider new technologies and contrarian ideas, not just the conventional wisdom.\n - You may use high levels of speculation or prediction, just flag it for me."
}
]
}
},
"id": "ec9f3015-dd1f-41be-abb8-1d29e1602e59",
"name": "Generate SERP Queries",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"position": [
1392,
2000
],
"typeVersion": 1.5
},
{
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n \"type\": \"object\",\n \"properties\": {\n \"queries\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"query\": {\n \"type\": \"string\",\n \"description\": \"The SERP query\"\n },\n \"researchGoal\": {\n \"type\": \"string\",\n \"description\": \"First talk about the goal of the research that this query is meant to accomplish, then go deeper into how to advance the research once the results are found, mention additional research directions. Be as specific as possible, especially for additional research directions.\"\n }\n }\n }\n }\n }\n}"
},
"id": "acca8eb2-0a22-4f0d-9e6f-9d28d5b1198d",
"name": "Structured Output Parser2",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
1568,
2160
],
"typeVersion": 1.2
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "acb41e93-70c6-41a3-be0f-e5a74ec3ec88",
"name": "query",
"type": "string",
"value": "={{ $('JobType Router').first().json.data.query }}"
},
{
"id": "7fc54063-b610-42bc-a250-b1e8847c4d1e",
"name": "learnings",
"type": "array",
"value": "={{ $('JobType Router').first().json.data.learnings }}"
},
{
"id": "e8f1c158-56fb-41c8-8d86-96add16289bb",
"name": "breadth",
"type": "number",
"value": "={{ $('JobType Router').first().json.data.breadth }}"
}
]
},
"options": {}
},
"id": "8fc8442f-d1fd-4f55-840e-a937d18f4690",
"name": "Set Initial Query",
"type": "n8n-nodes-base.set",
"position": [
1840,
1360
],
"typeVersion": 3.4
},
{
"parameters": {
"fieldToSplitOut": "output.queries",
"options": {}
},
"id": "edc0f01b-e2ed-4345-b114-9c5fd9aed2ef",
"name": "SERP to Items",
"type": "n8n-nodes-base.splitOut",
"position": [
1728,
2000
],
"typeVersion": 1
},
{
"parameters": {},
"id": "41752dc5-46b6-428c-8b3b-0a765f7d946c",
"name": "Item Ref",
"type": "n8n-nodes-base.noOp",
"position": [
2208,
2208
],
"typeVersion": 1
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "9acec2cc-64c8-4e62-bed4-c3d9ffab1379",
"name": "researchGoal",
"type": "string",
"value": "={{ $('Item Ref').first().json.researchGoal }}"
},
{
"id": "1b2d2dad-429b-4fc9-96c5-498f572a85c3",
"name": "learnings",
"type": "array",
"value": "={{ $json.output.learnings }}"
},
{
"id": "7025f533-02ab-4031-9413-43390fb61f05",
"name": "followUpQuestions",
"type": "string",
"value": "={{ $json.output.followUpQuestions }}"
},
{
"id": "c9e34ea4-5606-46d6-8d66-cb42d772a8b4",
"name": "urls",
"type": "array",
"value": "={{\n$('Get Markdown + URL')\n .all()\n .map(item => item.json.url)\n}}"
}
]
},
"options": {}
},
"id": "4f160202-347f-4900-a797-d7b9ccdfeaf7",
"name": "Research Goal + Learnings",
"type": "n8n-nodes-base.set",
"position": [
3888,
2352
],
"typeVersion": 3.4
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "db509e90-9a86-431f-8149-4094d22666cc",
"name": "should_stop",
"type": "boolean",
"value": "={{\n$runIndex >= ($('JobType Router').first().json.data.depth)\n}}"
},
{
"id": "90986e2b-8aca-4a22-a9db-ed8809d6284d",
"name": "all_learnings",
"type": "array",
"value": "={{\nArray($runIndex+1)\n .fill(0)\n .flatMap((_,idx) => {\n try {\n return $('Generate Learnings')\n .all(0,idx)\n .flatMap(item => item.json.data.flatMap(d => d.learnings))\n } catch (e) {\n return []\n }\n })\n}}"
},
{
"id": "3eade958-e8ab-4975-aac4-f4a4a983c163",
"name": "all_urls",
"type": "array",
"value": "={{\nArray($runIndex+1)\n .fill(0)\n .flatMap((_,idx) => {\n try {\n return $('Generate Learnings')\n .all(0,idx)\n .flatMap(item => item.json.data.flatMap(d => d.urls))\n } catch (e) {\n return []\n }\n })\n}}"
}
]
},
"options": {}
},
"id": "280ae4aa-4280-4511-b47f-3b3a0a685e85",
"name": "Accumulate Results",
"type": "n8n-nodes-base.set",
"position": [
2224,
1360
],
"executeOnce": true,
"typeVersion": 3.4
},
{
"parameters": {
"mode": "raw",
"jsonOutput": "={{ $('Generate Learnings').item.json }}",
"options": {}
},
"id": "12be26c5-95ec-4f55-b30e-c4061e95aa75",
"name": "DeepResearch Results",
"type": "n8n-nodes-base.set",
"position": [
2592,
1552
],
"typeVersion": 3.4
},
{
"parameters": {
"fieldToSplitOut": "data",
"options": {}
},
"id": "b9e4cf54-d289-42ed-87db-a4fc96f238c1",
"name": "Results to Items",
"type": "n8n-nodes-base.splitOut",
"position": [
2752,
1552
],
"typeVersion": 1
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "d88bfe95-9e73-4d25-b45c-9f164b940b0e",
"name": "query",
"type": "string",
"value": "=Previous research goal: {{ $json.researchGoal }}\nFollow-up research directions: {{ $json.followUpQuestions.map(q => `\\n${q}`).join('') }}"
},
{
"id": "4aa20690-d998-458a-b1e4-0d72e6a68e6b",
"name": "learnings",
"type": "array",
"value": "={{ $('Accumulate Results').item.json.all_learnings }}"
},
{
"id": "89acafae-b04a-4d5d-b08b-656e715654e4",
"name": "breadth",
"type": "number",
"value": "={{ $('JobType Router').first().json.data.breadth }}"
}
]
},
"options": {}
},
"id": "cb4145f0-539e-4c3a-b2b6-cf05f2a6380d",
"name": "Set Next Queries",
"type": "n8n-nodes-base.set",
"position": [
2912,
1552
],
"typeVersion": 3.4
},
{
"parameters": {
"options": {}
},
"id": "5cbdcaac-d35c-4c73-a27c-a665d4be8c2f",
"name": "For Each Query...",
"type": "n8n-nodes-base.splitInBatches",
"position": [
2000,
2048
],
"typeVersion": 3
},
{
"parameters": {
"fieldToSplitOut": "output.questions",
"options": {}
},
"id": "80579c45-a98f-49a3-9f19-fe5f630629de",
"name": "Feedback to Items",
"type": "n8n-nodes-base.splitOut",
"position": [
1712,
720
],
"typeVersion": 1
},
{
"parameters": {
"formFields": {
"values": [
{
"fieldLabel": "={{ $json[\"output.questions\"] }}",
"fieldType": "textarea",
"placeholder": "=",
"requiredField": true
}
]
},
"options": {
"formTitle": "DeepResearcher",
"formDescription": "=<img\n src=\"https://res.cloudinary.com/daglih2g8/image/upload/f_auto,q_auto/v1/n8n-workflows/o4wqztloz3j6okfxpeyw\"\n width=\"100%\"\n style=\"border:1px solid #ccc\"\n/>\n<p style=\"text-align:left\">\nAnswer the following clarification questions to assist the DeepResearcher better under the research topic.\n</p>\n<hr style=\"display:block;margin-top:16px;margin-bottom:0\" />\n<p style=\"text-align:left;font-family:sans-serif;font-weight:700;\">\nTotal {{ $('Feedback to Items').all().length }} questions.\n</p>",
"buttonLabel": "Answer"
}
},
"id": "ec8856cf-af53-4541-8aa7-326c5b9f4ba4",
"name": "Ask Clarity Questions",
"type": "n8n-nodes-base.form",
"position": [
2064,
800
],
"webhookId": "d3375ba6-0008-4fcb-96bc-110374de2603",
"typeVersion": 1
},
{
"parameters": {
"options": {}
},
"id": "78c92c6f-831b-4969-89a7-de11cf482383",
"name": "For Each Question...",
"type": "n8n-nodes-base.splitInBatches",
"position": [
1888,
720
],
"typeVersion": 3
},
{
"parameters": {
"workflowInputs": {
"values": [
{
"name": "requestId",
"type": "any"
},
{
"name": "jobType"
},
{
"name": "data",
"type": "object"
}
]
}
},
"id": "dd3bb4bd-d814-4f11-848d-1974bf8830a7",
"name": "DeepResearch Subworkflow",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
544,
2000
],
"typeVersion": 1.1
},
{
"parameters": {
"content": "## 2. Ask Clarifying Questions\n[Read more about form nodes](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.form/)\n\nTo handle the clarification questions generated by the LLM, I used the same technique found in my \"AI Interviewer\" template ([link](https://n8n.io/workflows/2566-conversational-interviews-with-ai-agents-and-n8n-forms/)).\nThis involves a looping of dynamically generated forms to collect answers from the user.",
"height": 560,
"width": 1000,
"color": 7
},
"id": "40b17a07-d8b3-4c96-8fab-6efa6fc77d68",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
1280,
512
],
"typeVersion": 1
},
{
"parameters": {
"promptType": "define",
"text": "=Given the following query from the user, ask some follow up questions to clarify the research direction. Return a maximum of 3 questions, but feel free to return less if the original query is clear: <query>{{ $json.prompt }}</query>`",
"hasOutputParser": true,
"messages": {
"messageValues": [
{
"type": "HumanMessagePromptTemplate",
"message": "=You are an expert researcher. Today is {{ $now.toLocaleString() }}. Follow these instructions when responding:\n - You may be asked to research subjects that is after your knowledge cutoff, assume the user is right when presented with news.\n - The user is a highly experienced analyst, no need to simplify it, be as detailed as possible and make sure your response is correct.\n - Be highly organized.\n - Suggest solutions that I didn't think about.\n - Be proactive and anticipate my needs.\n - Treat me as an expert in all subject matter.\n - Mistakes erode my trust, so be accurate and thorough.\n - Provide detailed explanations, I'm comfortable with lots of detail.\n - Value good arguments over authorities, the source is irrelevant.\n - Consider new technologies and contrarian ideas, not just the conventional wisdom.\n - You may use high levels of speculation or prediction, just flag it for me."
}
]
}
},
"id": "e76e2751-a61c-4a7a-8348-cee41aa3af33",
"name": "Clarifying Questions",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"position": [
1392,
720
],
"typeVersion": 1.5
},
{
"parameters": {
"content": "## 6. Perform DeepSearch Loop\n[Learn more about the Looping in n8n](https://docs.n8n.io/flow-logic/looping/#creating-loops)\n\nThe key of the Deep Research flow is its extensive data collection capability. In this implementation, this capability is represented by a recursive web search & scrape loop which starts with the original query and extended by AI-generated subqueries. How many subqueries to generate are determined the depth and breadth parameters specified.\n\n\"Learnings\" are generated for each subquery and accumulate on each iteration of the loop. When the loop finishes when depth limit is reached, all learnings are collected and it's these learnings are what we use to generate the report.",
"height": 640,
"width": 1360,
"color": 7
},
"id": "ec7a9913-1192-4c94-be78-11d633c93d7f",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1760,
1120
],
"typeVersion": 1
},
{
"parameters": {
"operation": "completion",
"completionTitle": "=Thank you for using DeepResearcher.",
"completionMessage": "=You may now close this window.",
"limitWaitTime": true,
"resumeAmount": 3,
"resumeUnit": "minutes",
"options": {}
},
"id": "2197f870-79a2-4b6d-9d88-7bf4713b5a44",
"name": "End Form",
"type": "n8n-nodes-base.form",
"position": [
3392,
768
],
"webhookId": "88f2534b-2b82-4b40-a4bc-97d96384e8fd",
"typeVersion": 1
},
{
"parameters": {
"workflowId": {
"__rl": true,
"mode": "id",
"value": "={{ $workflow.id }}"
},
"workflowInputs": {
"value": {
"data": "={{\n{\n \"query\": $('Get Initial Query').first().json.query,\n \"learnings\": [],\n \"depth\": $('Set Variables').first().json.depth,\n \"breadth\": $('Set Variables').first().json.breadth,\n}\n}}",
"jobType": "deepresearch_initiate",
"requestId": "={{ $('Set Variables').first().json.request_id }}"
},
"schema": [
{
"id": "requestId",
"display": true,
"removed": false,
"required": false,
"displayName": "requestId",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "jobType",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "jobType",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "data",
"type": "object",
"display": true,
"removed": false,
"required": false,
"displayName": "data",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": true
},
"mode": "each",
"options": {
"waitForSubWorkflow": false
}
},
"id": "9b5fe61d-91d4-4ff5-a3d8-3e233f2fbcd7",
"name": "Initiate DeepResearch",
"type": "n8n-nodes-base.executeWorkflow",
"position": [
3024,
768
],
"typeVersion": 1.2
},
{
"parameters": {
"dataToSave": {
"values": [
{
"key": "requestId",
"value": "={{ $json.requestId }}"
},
{
"key": "=jobType",
"value": "={{ $json.jobType }}"
}
]
}
},
"id": "78e78ce5-c0b3-4f8e-a889-61de9c4e7c29",
"name": "Execution Data",
"type": "n8n-nodes-base.executionData",
"position": [
720,
2000
],
"typeVersion": 1
},
{
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.jobType }}",
"rightValue": "deepresearch_initiate"
}
]
},
"renameOutput": true,
"outputKey": "initiate"
},
{
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "ecbfa54d-fc97-48c5-8d3d-f0538b8d727b",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.jobType }}",
"rightValue": "deepresearch_learnings"
}
]
},
"renameOutput": true,
"outputKey": "learnings"
},
{
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "392f9a98-ec22-4e57-9c8e-0e1ed6b7dafa",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.jobType }}",
"rightValue": "deepresearch_report"
}
]
},
"renameOutput": true,
"outputKey": "report"
}
]
},
"options": {}
},
"id": "e6a285ee-ec7f-408b-8f01-3b22236198da",
"name": "JobType Router",
"type": "n8n-nodes-base.switch",
"position": [
912,
2000
],
"typeVersion": 3.2
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "14b77741-c3c3-4bd2-be6e-37bd09fcea2b",
"name": "query",
"type": "string",
"value": "=Initial query: {{ $('Set Variables').first().json.prompt }}\nFollow-up Questions and Answers:\n{{\n$input.all()\n .map(item => {\n const q = Object.keys(item.json)[0];\n const a = item.json[q];\n return `question: ${q}\\nanswer: ${a}`;\n })\n .join('\\n')\n}}"
}
]
},
"options": {}
},
"id": "a2d0f5d1-2d2c-4065-ad00-9a9f1d1214c5",
"name": "Get Initial Query",
"type": "n8n-nodes-base.set",
"position": [
2064,
640
],
"executeOnce": true,
"typeVersion": 3.4
},
{
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n \"type\": \"object\",\n \"properties\": {\n \"title\": {\n \"type\": \"string\",\n \"description\":\" A short title summarising the research topic\"\n },\n \"description\": {\n \"type\": \"string\",\n \"description\": \"A short description to summarise the research topic\"\n }\n }\n}"
},
"id": "8d43e110-192b-4629-b1ff-16d64f6801c5",
"name": "Structured Output Parser4",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
2592,
912
],
"typeVersion": 1.2
},
{
"parameters": {
"promptType": "define",
"text": "=Create a suitable title for the research report which will be created from the user's query.\n<query>{{ $json.query }}</query>",
"hasOutputParser": true
},
"id": "db4dca3b-38ad-44c3-a421-cf9962edc9a2",
"name": "Report Page Generator",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"position": [
2400,
768
],
"typeVersion": 1.5
},
{
"parameters": {
"content": "## 4. Trigger DeepResearch Asynchronously\n[Learn more about the Execute Trigger node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.executeworkflow/)\n\nn8n handles asynchronous jobs by spinning them off as separate executions. This basically means the user doesn't have to wait or keep their browser window open for our researcher to do its job.\n\nOnce we initiate the Deepresearcher job, we can close out the onboarding journey for a nice user experience.",
"height": 560,
"width": 640,
"color": 7
},
"id": "59780b23-88e1-49f5-861a-80005080d039",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
2928,
512
],
"typeVersion": 1
},
{
"parameters": {
"content": "## 7. Generate Search Queries\n[Learn more about the Basic LLM node](https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.chainllm/)\n\nMuch like a human researcher, the DeepResearcher will rely on web search and content as the preferred source of information. To ensure it can cover a wide range of sources, the AI can first generate relevant research queries of which each can be explored separately.",
"height": 540,
"width": 620,
"color": 7
},
"id": "4cf5cebc-769f-4fdb-9aeb-2c9d21fdc7dc",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
1264,
1808
],
"typeVersion": 1
},
{
"parameters": {
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "75d18d88-6ba6-43df-bef7-3e8ad99ad8bd",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.should_stop }}",
"rightValue": ""
}
]
},
"options": {}
},
"id": "fc4e1a01-1189-43d7-b9c3-af6d0986a0df",
"name": "Is Depth Reached?",
"type": "n8n-nodes-base.if",
"position": [
2384,
1360
],
"typeVersion": 2.2
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "90b3da00-dcd5-4289-bd45-953146a3b0ba",
"name": "all_learnings",
"type": "array",
"value": "={{ $json.all_learnings }}"
},
{
"id": "623dbb3d-83a1-44a9-8ad3-48d92bc42811",
"name": "all_urls",
"type": "array",
"value": "={{ $json.all_urls }}"
}
]
},
"options": {}
},
"id": "15548283-7f64-467d-a4eb-f6fa643b7831",
"name": "Get Research Results",
"type": "n8n-nodes-base.set",
"position": [
2592,
1360
],
"typeVersion": 3.4
},
{
"parameters": {
"content": "## 8. Web Search and Extracting Web Page Contents using [APIFY.com](https://www.apify.com?fpr=414q6)\n[Read more about the HTTP Request node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.httprequest/)\n\nHere is where I deviated a little from the reference implementation. I opted not to use Firecrawl.ai due to (1) high cost of the service and (2) a regular non-ai crawler would work just as well and probably quicker. Instead I'm using [APIFY.com](https://www.apify.com?fpr=414q6) which is a more performant, cost-effective and reliable web scraper service. If you don't want to use Apify, feel free to swap this out with your preferred service.\n\nThis step is the most exciting in terms of improvements and optimisations eg. mix in internal data sources! Add in Perplexity.ai or Jina.ai! Possibilities are endless.",
"height": 740,
"width": 1340,
"color": 7
},
"id": "2c9dc342-1ec7-44a9-bcb4-eb3a424253dd",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
1904,
1808
],
"typeVersion": 1
},
{
"parameters": {
"content": "## 9. Compile Learnings with Reasoning Model\n[Read more about the Basic LLM node](https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.chainllm/)\n\nWith our gathered sources, it's now just a case of giving it to our LLM to compile a list of \"learnings\" from them. For our DeepResearcher, we'll use OpenAI's o3-mini which is the latest reasoning model at time of writing. Reasoning perform better than regular chat models due their chain-of-thought or \"thinking\" process that they perform.\n\nThe \"Learnings\" are then combined with the generated research goal to complete one loop.",
"height": 580,
"width": 800,
"color": 7
},
"id": "22319d12-9fcd-44e6-8448-d6d9a34d2372",
"name": "Sticky Note7",
"type": "n8n-nodes-base.stickyNote",
"position": [
3280,
1968
],
"typeVersion": 1
},
{
"parameters": {
"content": "## 1. Let's Research!\n[Learn more about the form trigger node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.formtrigger)\n\nn8n forms are a really nice way to get our frontend up and running quickly and compared to chat, offers a superior user interface for user input. I've gone perhaps a little extra with the custom html fields but I do enjoy adding a little customisation now and then.",
"height": 560,
"width": 680,
"color": 7
},
"id": "bef328ae-cd91-450f-87dd-8537cd03d421",
"name": "Sticky Note11",
"type": "n8n-nodes-base.stickyNote",
"position": [
592,
512
],
"typeVersion": 1
},
{
"parameters": {
"promptType": "define",
"text": "=You are an expert, insight‑driven researcher tasked with creating a **final report** on the user’s query. \nThe report must:\n\n1. **Length** – ≥ 3 pages (≈ 1,500–2,000 words). \n2. **Content** – integrate every learning from the <learnings> block; do not omit or summarize them away. \n3. **Sources** – cite **every URL** listed in <urls> with inline parentheses [n]. \n * Each citation number must appear next to the claim or fact it supports. \n * At the end of the document, list the reference numbers followed by the full URLs in a Markdown numbered list. \n4. **Structure** – use the following hierarchy (feel free to add sub‑headings as needed, but keep the order): \n - # Introduction \n - ## Background / Context \n - ## Methodology / Research Approach \n - ## Findings / Results \n - ## Discussion \n - ## Conclusions & Recommendations \n - ## Future Work / Next Steps (include only if relevant) \n5. **Formatting** – **Markdown only**. \n * Headings (#, ##, ###) \n * Ordered/unordered lists \n * Tables where they clarify data or comparisons \n * No plain paragraphs unless a complex explanation is needed. \n6. **Tone** – professional, research‑grade, no high‑level one‑sentence summaries. \n7. **No summarization of learnings** – each learning must appear verbatim or as a direct quotation. \n\n**Placeholders**\n\n<prompt>{{ $('JobType Router').first().json.data.query }}</prompt>\n<learnings>{{\n$('JobType Router').first().json.data\n .all_learnings\n .map(item => `<learning>${item}</learning>`) \n .join('\\n')\n}}</learnings>\n<urls>{{ $('JobType Router').first().json.data.all_urls }}</urls>"
},
"id": "ae44d5e7-cc88-459f-ac99-31b25d1fa341",
"name": "DeepResearch Report",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"position": [
1568,
2784
],
"typeVersion": 1.5,
"retryOnFail": true,
"onError": "continueRegularOutput"
},
{
"parameters": {
"promptType": "define",
"text": "=Given the following contents from a SERP search for the query <query>{{ $('Item Ref').first().json.query }}</query>, generate a list of learnings from the contents. Return a maximum of 3 learnings, but feel free to return less if the contents are clear. Make sure each learning is unique and not similar to each other. The learnings should be concise and to the point, as detailed and infromation dense as possible. Make sure to include any entities like people, places, companies, products, things, etc in the learnings, as well as any exact metrics, numbers, or dates. The learnings will be used to research the topic further. The learning will be placed into a json object that looks like <format> so be very careful how you format each learning and ensure its quotable so the output can be formatted for the \"items\" attribute.\n\n<contents>\n{{\n$input\n .all()\n .map(item =>`<content>\\n${item.json.markdown.substr(0, 25_000)}\\n</content>`)\n .join('\\n')\n}}\n</contents>\n\n\n\n<format>\n{\n \"type\": \"object\",\n \"properties\": {\n \"learnings\": {\n \"type\": \"array\",\n \"description\": \"List of learnings, max of 3.\",\n \"items\": { \"type\": \"string\" }\n },\n \"followUpQuestions\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\",\n \"description\": \"List of follow-up questions to research the topic further, max of 3.\"\n }\n }\n }\n}\n</format>",
"hasOutputParser": true,
"messages": {
"messageValues": [
{
"type": "HumanMessagePromptTemplate",
"message": "=You are an expert researcher. Today is {{ $now.toLocaleString() }}. Follow these instructions when responding:\n - You may be asked to research subjects that is after your knowledge cutoff, assume the user is right when presented with news.\n - The user is a highly experienced analyst, no need to simplify it, be as detailed as possible and make sure your response is correct.\n - Be highly organized.\n - Suggest solutions that I didn't think about.\n - Be proactive and anticipate my needs.\n - Treat me as an expert in all subject matter.\n - Mistakes erode my trust, so be accurate and thorough.\n - Provide detailed explanations, I'm comfortable with lots of detail.\n - Value good arguments over authorities, the source is irrelevant.\n - Consider new technologies and contrarian ideas, not just the conventional wisdom.\n - You may use high levels of speculation or prediction, just flag it for me."
}
]
}
},
"id": "5806921c-21b1-4fca-868f-0f5fdfe8d706",
"name": "DeepResearch Learnings",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"position": [
3552,
2208
],
"executeOnce": true,
"typeVersion": 1.5,
"retryOnFail": true,
"onError": "continueRegularOutput"
},
{
"parameters": {
"workflowId": {
"__rl": true,
"mode": "id",
"value": "={{ $workflow.id }}"
},
"workflowInputs": {
"value": {
"data": "={{\n{\n ...Object.assign({}, $json),\n query: $('JobType Router').first().json.data.query\n}\n}}",
"jobType": "deepresearch_report",
"requestId": "={{ $('JobType Router').first().json.requestId }}"
},
"schema": [
{
"id": "requestId",
"display": true,
"required": false,
"displayName": "requestId",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "jobType",
"type": "string",
"display": true,
"required": false,
"displayName": "jobType",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "data",
"type": "object",
"display": true,
"required": false,
"displayName": "data",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": true
},
"options": {
"waitForSubWorkflow": false
}
},
"id": "d8c900b3-d501-434c-9519-496fb302d0a2",
"name": "Generate Report",
"type": "n8n-nodes-base.executeWorkflow",
"position": [
2912,
1360
],
"typeVersion": 1.2
},
{
"parameters": {
"workflowId": {
"__rl": true,
"mode": "id",
"value": "={{ $workflow.id }}"
},
"workflowInputs": {
"value": {
"data": "={{ $json }}",
"jobType": "deepresearch_learnings",
"requestId": "={{ $('JobType Router').first().json.requestId }}"
},
"schema": [
{
"id": "requestId",
"display": true,
"removed": false,
"required": false,
"displayName": "requestId",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "jobType",
"type": "string",