-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Expand file tree
/
Copy pathWrite a WordPress post with AI (starting from a few keywords).json
More file actions
988 lines (988 loc) · 21.5 KB
/
Copy pathWrite a WordPress post with AI (starting from a few keywords).json
File metadata and controls
988 lines (988 loc) · 21.5 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
{
"id": "mKGMYXJottl0PDtM",
"meta": {
"instanceId": "cb484ba7b742928a2048bf8829668bed5b5ad9787579adea888f05980292a4a7"
},
"name": "Write a WordPress post with AI (starting from a few keywords)",
"tags": [],
"nodes": [
{
"id": "a4f19a81-6101-48c2-9560-9cf231bc240b",
"name": "Form",
"type": "n8n-nodes-base.formTrigger",
"position": [
-580,
320
],
"webhookId": "4b937814-e829-4df7-aaba-31192babf7e1",
"parameters": {
"path": "create-wordpress-post",
"formTitle": "Create a WordPress post with AI",
"formFields": {
"values": [
{
"fieldLabel": "Keywords (comma-separated)",
"requiredField": true
},
{
"fieldType": "dropdown",
"fieldLabel": "Number of chapters",
"fieldOptions": {
"values": [
{
"option": "1"
},
{
"option": "2"
},
{
"option": "3"
},
{
"option": "4"
},
{
"option": "5"
},
{
"option": "6"
},
{
"option": "7"
},
{
"option": "8"
},
{
"option": "9"
},
{
"option": "10"
}
]
},
"requiredField": true
},
{
"fieldType": "number",
"fieldLabel": "Max words count",
"requiredField": true
}
]
},
"responseMode": "responseNode",
"formDescription": "Fill this form with the required information to create a draft post on WordPress"
},
"typeVersion": 2
},
{
"id": "e4cf75f7-00e7-473a-a944-af635581715f",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
209.98769233621147,
140
],
"parameters": {
"color": 4,
"width": 301.3874093724939,
"height": 371.765663140765,
"content": "## Data check"
},
"typeVersion": 1
},
{
"id": "e949a487-6701-4650-b9be-08146b4e93ad",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
225.20535922952297,
200
],
"parameters": {
"color": 7,
"width": 272.8190508599808,
"height": 80,
"content": "Checks that the data returned by OpenAI is correct"
},
"typeVersion": 1
},
{
"id": "662fe28b-c0b7-4aef-b99c-a8c4c641251c",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
1580,
140
],
"parameters": {
"color": 5,
"width": 282.3398199598652,
"height": 371.7656631407652,
"content": "## Draft on WordPress"
},
"typeVersion": 1
},
{
"id": "85996d51-ab98-41f5-b525-d926f04f50a8",
"name": "Sticky Note9",
"type": "n8n-nodes-base.stickyNote",
"position": [
1595,
200
],
"parameters": {
"color": 7,
"width": 254.77269221373095,
"height": 80,
"content": "The article is posted as a draft on WordPress"
},
"typeVersion": 1
},
{
"id": "46f67505-f2dc-4110-b1d4-a27d7814cb52",
"name": "Sticky Note10",
"type": "n8n-nodes-base.stickyNote",
"position": [
1881,
140
],
"parameters": {
"color": 3,
"width": 557.7592769264069,
"height": 369.2595606183891,
"content": "## Featured image"
},
"typeVersion": 1
},
{
"id": "a1beeb4f-f171-4c6a-ac19-7086b09757ab",
"name": "Sticky Note11",
"type": "n8n-nodes-base.stickyNote",
"position": [
1900,
200
],
"parameters": {
"color": 7,
"width": 517.9195082760601,
"height": 80,
"content": "The image is generated with Dall-E, uploaded to WordPress, and then connected to the post as its featured image"
},
"typeVersion": 1
},
{
"id": "d1fd737b-7f14-4371-8720-7742f708e641",
"name": "Sticky Note12",
"type": "n8n-nodes-base.stickyNote",
"position": [
-117.99507693448459,
200
],
"parameters": {
"color": 7,
"width": 287.370178643191,
"height": 80,
"content": "Starting from the given keywords, generates the article title, subtitle, chapters, and image prompt"
},
"typeVersion": 1
},
{
"id": "ccaaf851-613b-4d0c-8b3d-99a35ec9cdad",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-129.93405171072595,
142
],
"parameters": {
"color": 6,
"width": 319.697690939268,
"height": 370.512611879577,
"content": "## Article structure"
},
"typeVersion": 1
},
{
"id": "69bebd7b-8ad5-4b0d-a8df-1b2e6d4be96e",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-640,
140
],
"parameters": {
"color": 7,
"width": 239.97343293577688,
"height": 370.512611879577,
"content": "## User form"
},
"typeVersion": 1
},
{
"id": "2037f81b-189c-4dc4-a4dc-179e4283544c",
"name": "Sticky Note13",
"type": "n8n-nodes-base.stickyNote",
"position": [
-623,
200
],
"parameters": {
"color": 7,
"width": 199.7721486302032,
"height": 80,
"content": "The user triggers the post creation"
},
"typeVersion": 1
},
{
"id": "e8d7f711-185d-499b-ba58-de52ac6a4e58",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
2461,
140
],
"parameters": {
"color": 7,
"width": 219.70753707029849,
"height": 370.512611879577,
"content": "## User feedback"
},
"typeVersion": 1
},
{
"id": "d89bebca-3607-4c66-a13d-07c32262e01a",
"name": "Sticky Note14",
"type": "n8n-nodes-base.stickyNote",
"position": [
2481,
200
],
"parameters": {
"color": 7,
"width": 183.38125554060056,
"height": 80,
"content": "Final confirmation to the user"
},
"typeVersion": 1
},
{
"id": "7df452e2-52f3-4efe-94a4-7d4eab0670c8",
"name": "Sticky Note6",
"type": "n8n-nodes-base.stickyNote",
"position": [
534.9876923362115,
530.9889231025903
],
"parameters": {
"color": 7,
"width": 281.2716777103785,
"height": 288.4116890365125,
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nUser is notified to try again since some data is missing"
},
"typeVersion": 1
},
{
"id": "f881bcd9-c7d2-4a1c-bc1a-beb515d52ade",
"name": "Sticky Note7",
"type": "n8n-nodes-base.stickyNote",
"position": [
-128.98646156983267,
532.991384635348
],
"parameters": {
"color": 7,
"width": 319.8306137081817,
"height": 275.3956890735875,
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nWikipedia is used to write the article"
},
"typeVersion": 1
},
{
"id": "1b788b37-b8b5-47f6-8198-547dac8c76d6",
"name": "Settings",
"type": "n8n-nodes-base.set",
"position": [
-320,
320
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "3a433b0f-9957-4b64-ad81-359ab5e521d5",
"name": "wordpress_url",
"type": "string",
"value": "https://you-wordpress-url-here.com/"
},
{
"id": "ec5430e3-92c5-46e4-8c2c-c87291680892",
"name": "keywords",
"type": "string",
"value": "={{ $json['Keywords (comma-separated)'] }}"
},
{
"id": "5defb0a2-d921-4909-b10d-da59e1768496",
"name": "chapters",
"type": "number",
"value": "={{ $json['Number of chapters'] }}"
},
{
"id": "230ebd0b-73c2-4265-9b3c-57af7fbc48c8",
"name": "words",
"type": "number",
"value": "={{ $json['Max words count'] }}"
}
]
}
},
"typeVersion": 3.3
},
{
"id": "af29ed91-84b5-43f8-b1ce-1c8dc35c2c1b",
"name": "Sticky Note8",
"type": "n8n-nodes-base.stickyNote",
"position": [
-377,
140
],
"parameters": {
"color": 2,
"width": 226.71615243495023,
"height": 370.512611879577,
"content": "## Settings"
},
"typeVersion": 1
},
{
"id": "a6fe2238-22ba-4c54-adef-663bd3955dcc",
"name": "Sticky Note15",
"type": "n8n-nodes-base.stickyNote",
"position": [
-360,
200
],
"parameters": {
"color": 7,
"width": 179.37633247508526,
"height": 80,
"content": "Set the URL of your WordPress here"
},
"typeVersion": 1
},
{
"id": "358ac79f-be7d-44eb-a353-b2ad4ac8d582",
"name": "Check data consistency",
"type": "n8n-nodes-base.if",
"position": [
300,
320
],
"parameters": {
"options": {},
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "9c8c53ea-6079-48da-9d6e-dd527167b123",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
},
"leftValue": "={{ $json.message.content.title }}",
"rightValue": ""
},
{
"id": "a7fabfe1-3539-453a-93d9-8d6d395c3de4",
"operator": {
"type": "array",
"operation": "lengthGte",
"rightType": "number"
},
"leftValue": "={{ $json.message.content.chapters }}",
"rightValue": "={{ 1 }}"
},
{
"id": "a687081e-24e2-423c-a2da-b7c18baf0715",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
},
"leftValue": "={{ $json.message.content.subtitle }}",
"rightValue": ""
},
{
"id": "0a435a69-3699-4b98-b46f-40954c7a7816",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
},
"leftValue": "={{ $json.message.content.introduction }}",
"rightValue": ""
},
{
"id": "1a440144-21f3-42bd-9222-774bd564f3ef",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
},
"leftValue": "={{ $json.message.content.conclusions }}",
"rightValue": ""
},
{
"id": "834ce92d-b1e9-48ef-ae63-1d0841c900b5",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
},
"leftValue": "={{ $json.message.content.imagePrompt }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2
},
{
"id": "479f474a-1687-4588-8485-d793afc6757d",
"name": "Split out chapters",
"type": "n8n-nodes-base.splitOut",
"position": [
600,
320
],
"parameters": {
"options": {},
"fieldToSplitOut": "message.content.chapters"
},
"typeVersion": 1
},
{
"id": "bde7b7db-45c6-4ab3-a705-358000cefbec",
"name": "Merge chapters title and text",
"type": "n8n-nodes-base.merge",
"position": [
1220,
460
],
"parameters": {
"mode": "combine",
"options": {},
"combinationMode": "mergeByPosition"
},
"typeVersion": 2.1
},
{
"id": "0079022b-eaa2-481b-8c78-f8623a63645b",
"name": "Final article text",
"type": "n8n-nodes-base.code",
"position": [
1400,
320
],
"parameters": {
"jsCode": "let article = \"\";\n\n// Introduction\narticle += $('Create post title and structure').first().json.message.content.introduction;\narticle += \"<br><br>\";\n\nfor (const item of $input.all()) {\n article += \"<strong>\" + item.json.title + \"</strong>\";\n article += \"<br><br>\";\n article += item.json.message.content;\n article += \"<br><br>\";\n}\n\n// Conclusions\narticle += \"<strong>Conclusions</strong>\";\narticle += \"<br><br>\";\narticle += $('Create post title and structure').first().json.message.content.conclusions;\n\n\nreturn [\n {\n \"article\": article\n }\n];"
},
"typeVersion": 1
},
{
"id": "d892f00a-90fd-4bbb-bac6-4684d7d0c638",
"name": "Post on Wordpress",
"type": "n8n-nodes-base.wordpress",
"position": [
1680,
320
],
"parameters": {
"title": "={{ $('Create post title and structure').all()[0].json.message.content.title }}",
"additionalFields": {
"status": "draft",
"content": "={{ $json.article }}"
}
},
"credentials": {
"wordpressApi": {
"id": "xxxxxxxxxxx",
"name": "WordPress Credentials"
}
},
"typeVersion": 1
},
{
"id": "a609d80d-f586-4e5f-a72d-01257f676574",
"name": "Upload media",
"type": "n8n-nodes-base.httpRequest",
"position": [
2120,
320
],
"parameters": {
"url": "https://wp-demo.mondo.surf/wp-json/wp/v2/media",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "binaryData",
"sendHeaders": true,
"authentication": "predefinedCredentialType",
"headerParameters": {
"parameters": [
{
"name": "Content-Disposition",
"value": "attachment; filename=\"example.jpg\""
}
]
},
"inputDataFieldName": "data",
"nodeCredentialType": "wordpressApi"
},
"credentials": {
"wordpressApi": {
"id": "xxxxxxxxxxx",
"name": "WordPress Credentials"
}
},
"typeVersion": 4.1
},
{
"id": "bdb2ef52-0201-4fe1-a7a6-59e34e21bf5e",
"name": "Set image ID for the post",
"type": "n8n-nodes-base.httpRequest",
"position": [
2280,
320
],
"parameters": {
"url": "=https://wp-demo.mondo.surf/wp-json/wp/v2/posts/{{ $('Post on Wordpress').item.json.id }}",
"method": "POST",
"options": {},
"sendQuery": true,
"authentication": "predefinedCredentialType",
"queryParameters": {
"parameters": [
{
"name": "featured_media",
"value": "={{ $json.id }}"
}
]
},
"nodeCredentialType": "wordpressApi"
},
"credentials": {
"wordpressApi": {
"id": "xxxxxxxxxxx",
"name": "WordPress Credentials"
}
},
"typeVersion": 4.1
},
{
"id": "a721762f-168d-4c87-ab6d-0d31deecd9a5",
"name": "Respond: Success",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
2520,
320
],
"parameters": {
"options": {},
"respondWith": "json",
"responseBody": "={\n \"formSubmittedText\": \"The article {{ $json.title.rendered }} was correctly created as a draft on WordPress!\"\n}"
},
"typeVersion": 1
},
{
"id": "51b79bc2-035d-4db8-87bb-db6c889b164e",
"name": "Respond: Error",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
620,
580
],
"parameters": {
"options": {},
"respondWith": "json",
"responseBody": "={\n 'formSubmittedText': 'There was a problem creating the article, please refresh the form and try again!'\n}\n\n"
},
"typeVersion": 1
},
{
"id": "d8748498-0800-4208-b993-f233d14da7b6",
"name": "Sticky Note16",
"type": "n8n-nodes-base.stickyNote",
"position": [
533.7711864406776,
140
],
"parameters": {
"color": 2,
"width": 225.47038972308582,
"height": 370.512611879577,
"content": "## Chapters split"
},
"typeVersion": 1
},
{
"id": "4115de31-d4e9-4d77-a055-3dead31c4dc5",
"name": "Sticky Note17",
"type": "n8n-nodes-base.stickyNote",
"position": [
550.7711864406779,
200
],
"parameters": {
"color": 7,
"width": 185.6051460344073,
"height": 80,
"content": "Splits out chapter contents from the previous node"
},
"typeVersion": 1
},
{
"id": "aff8edf6-4e1e-4522-86f7-f0ce88cd0cd4",
"name": "Sticky Note18",
"type": "n8n-nodes-base.stickyNote",
"position": [
792,
198
],
"parameters": {
"color": 7,
"width": 287.370178643191,
"height": 80,
"content": "Writes the text for each chapter"
},
"typeVersion": 1
},
{
"id": "e45715a8-b1ca-4499-a16a-854f8bd4f370",
"name": "Sticky Note19",
"type": "n8n-nodes-base.stickyNote",
"position": [
780,
140
],
"parameters": {
"color": 6,
"width": 333.40108076977657,
"height": 370.512611879577,
"content": "## Chapters text"
},
"typeVersion": 1
},
{
"id": "5c4cd7a1-7dc9-4159-9bd2-dbe5f8feb663",
"name": "Sticky Note21",
"type": "n8n-nodes-base.stickyNote",
"position": [
1138.423429009716,
140
],
"parameters": {
"color": 4,
"width": 420.4253447940705,
"height": 514.2177254645992,
"content": "## Content preparation"
},
"typeVersion": 1
},
{
"id": "7a6d3f7d-0436-4844-b09a-37e805b95a2f",
"name": "Sticky Note22",
"type": "n8n-nodes-base.stickyNote",
"position": [
1160,
200
],
"parameters": {
"color": 7,
"width": 368.1523541074699,
"height": 80,
"content": "Merges the content and prepare it before sending it to WordPress"
},
"typeVersion": 1
},
{
"id": "903b695d-015a-4956-9c63-45802dfb9fdb",
"name": "Generate featured image",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
1940,
320
],
"parameters": {
"prompt": "=Generate a photographic image to be used as the cover image for the article titled: {{ $('Create post title and structure').all()[0].json.message.content.title }}. This is the prompt for the image: {{ $('Create post title and structure').all()[0].json.message.content.imagePrompt }}, photography, realistic, sigma 85mm f/1.4",
"options": {
"size": "1792x1024",
"style": "natural",
"quality": "hd"
},
"resource": "image"
},
"credentials": {
"openAiApi": {
"id": "xxxxxxxxxxx",
"name": "OpenAI Credentials"
}
},
"typeVersion": 1
},
{
"id": "faa847cb-9702-4207-aa1e-6d9f62493527",
"name": "Wikipedia",
"type": "@n8n/n8n-nodes-langchain.toolWikipedia",
"position": [
-20,
620
],
"parameters": {},
"typeVersion": 1
},
{
"id": "9d09c92e-11c0-4ea9-81d6-13bc9266741a",
"name": "Create post title and structure",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
-100,
320
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4-1106-preview",
"cachedResultName": "GPT-4-1106-PREVIEW"
},
"options": {
"maxTokens": 2048
},
"messages": {
"values": [
{
"content": "=Write the title, the subtitle, the chapters details, the introduction, the conclusions, and an image prompt for a SEO-friendly article about these topics:\n{{ $json.keywords }}.\n\nInstructions:\n- Place the article title in a JSON field called `title`\n- Place the subtitle in a JSON field called `subtitle`\n- Place the introduction in a JSON field called `introduction`\n- In the introduction introduce the topic that is then explored in depth in the rest of the text\n- The introduction should be around 60 words\n- Place the conclusions in a JSON field called `conclusions`\n- The conclusions should be around 60 words\n- Use the conclusions to sum all said in the article and offer a conclusion to the reader\n- The image prompt will be used to produce a photographic cover image for the article and should depict the topics discussed in the article\n- Place the image prompt in a JSON field called `imagePrompt`\n- There should be {{ $json.chapters.toString() }} chapters.\n- For each chapter provide a title and an exaustive prompt that will be used to write the chapter text.\n- Place the chapters in an array field called `chapters`\n- For each chapter provide the fields `title` and `prompt`\n- The chapters should follow a logical flow and not repeat the same concepts.\n- The chapters should be one related to the other and not isolated blocks of text. The text should be fluent and folow a linear logic.\n- Don't start the chapters with \"Chapter 1\", \"Chapter 2\", \"Chapter 3\"... just write the title of the chapter\n- For the title and the capthers' titles don't use colons (`:`)\n- For the text, use HTML for formatting, but limited to bold, italic and lists.\n- Don't use markdown for formatting.\n- Always search on Wikipedia for useful information or verify the accuracy of what you write.\n- Never mention it if you don't find information on Wikipedia or the web\n- Go deep in the topic you treat, don't just throw some superficial info"
}
]
},
"jsonOutput": true
},
"credentials": {
"openAiApi": {
"id": "xxxxxxxxxxx",
"name": "OpenAI Credentials"
}
},
"typeVersion": 1
},
{
"id": "2ecd3a50-a34f-4ab9-ad31-e4e6608708fb",
"name": "Create chapters text",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
820,
320
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4-0125-preview",
"cachedResultName": "GPT-4-0125-PREVIEW"
},
"options": {
"maxTokens": 2048
},
"messages": {
"values": [
{
"content": "=Write a chapter for the article: {{ $('Create post title and structure').item.json.message.content.title }}, {{ $('Create post title and structure').item.json.message.content.subtitle }}, that talks about {{ $('Settings').item.json[\"keywords\"] }}\n\nThis is the prompt for the chapter titled {{ $json.title }}: {{ $json.prompt }}.\n\nGuidelines:\n- Just return the plain text for each chapter (no JSON structure).\n- Don't use markdown for formatting.\n- Use HTML for formatting, but limited to bold, italic and lists.\n- Don't add internal titles or headings.\n- The length of each chapther should be around {{ Math.round(($('Settings').item.json.words - 120)/ $('Settings').item.json.chapters) }} words long\n- Go deep in the topic you treat, don't just throw some superficial info\n{{ $itemIndex > 0 ? \"- The previous chapter talks about \" + $input.all()[$itemIndex-1].json.title : \"\" }}\n{{ $itemIndex > 0 ? \"- The promt for the previous chapter is \" + $input.all()[$itemIndex-1].json.prompt : \"\" }}\n{{ $itemIndex < $input.all().length ? \"- The following chapter will talk about \" + $input.all()[$itemIndex+1].json.title: \"\" }}\n{{ $itemIndex < $input.all().length ? \"- The prompt for the following chapter is \" + $input.all()[$itemIndex+1].json.prompt : \"\" }}\n- Consider the previous and following chapters what writing the text for this chapter. The text must be coherent with the previous and following chapters.\n- This chapter should not repeat the concepts already exposed in the previous chapter.\n- This chapter is a part of a larger article so don't include an introduction or conclusions. This chapter should merge with the rest of the article.\n"
}
]
}
},
"credentials": {
"openAiApi": {
"id": "xxxxxxxxxxx",
"name": "OpenAI Credentials"
}
},
"typeVersion": 1
}
],
"active": true,
"pinData": {},
"settings": {
"callerPolicy": "workflowsFromSameOwner",
"executionOrder": "v1",
"saveManualExecutions": true,
"saveDataSuccessExecution": "all"
},
"versionId": "64d94f1e-51c8-40f7-a6b3-80fc43d9e71a",
"connections": {
"Form": {
"main": [
[
{
"node": "Settings",
"type": "main",
"index": 0
}
]
]
},
"Settings": {
"main": [
[
{
"node": "Create post title and structure",
"type": "main",
"index": 0
}
]
]
},
"Wikipedia": {
"ai_tool": [
[
{
"node": "Create post title and structure",
"type": "ai_tool",
"index": 0
}
]
]
},
"Upload media": {
"main": [
[
{
"node": "Set image ID for the post",
"type": "main",
"index": 0
}
]
]
},
"Post on Wordpress": {
"main": [
[
{
"node": "Generate featured image",
"type": "main",
"index": 0
}
]
]
},
"Final article text": {
"main": [
[
{
"node": "Post on Wordpress",
"type": "main",
"index": 0
}
]
]
},
"Split out chapters": {
"main": [
[
{
"node": "Merge chapters title and text",
"type": "main",
"index": 1
},
{
"node": "Create chapters text",
"type": "main",
"index": 0
}
]
]
},
"Create chapters text": {
"main": [
[
{
"node": "Merge chapters title and text",
"type": "main",
"index": 0
}
]
]
},
"Check data consistency": {
"main": [
[
{
"node": "Split out chapters",
"type": "main",
"index": 0
}
],
[
{
"node": "Respond: Error",
"type": "main",
"index": 0
}
]
]
},
"Generate featured image": {
"main": [
[
{
"node": "Upload media",
"type": "main",
"index": 0
}
]
]
},
"Set image ID for the post": {
"main": [
[
{
"node": "Respond: Success",
"type": "main",
"index": 0
}
]
]
},
"Merge chapters title and text": {
"main": [
[
{
"node": "Final article text",
"type": "main",
"index": 0
}
]
]
},
"Create post title and structure": {
"main": [
[
{
"node": "Check data consistency",
"type": "main",
"index": 0
}
]
]
}
}
}