@n8n/workflow-sdk 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/dist/build.tsbuildinfo +1 -1
  2. package/dist/codegen/parse-workflow-code.js +12 -1
  3. package/dist/codegen/parse-workflow-code.js.map +1 -1
  4. package/dist/generate-types/generate-types.js +1 -1
  5. package/dist/generate-types/generate-types.js.map +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.js +4 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/prompts/best-practices/guides/chatbot.d.ts +7 -0
  10. package/dist/prompts/best-practices/guides/chatbot.js +120 -0
  11. package/dist/prompts/best-practices/guides/chatbot.js.map +1 -0
  12. package/dist/prompts/best-practices/guides/content-generation.d.ts +7 -0
  13. package/dist/prompts/best-practices/guides/content-generation.js +117 -0
  14. package/dist/prompts/best-practices/guides/content-generation.js.map +1 -0
  15. package/dist/prompts/best-practices/guides/data-analysis.d.ts +7 -0
  16. package/dist/prompts/best-practices/guides/data-analysis.js +369 -0
  17. package/dist/prompts/best-practices/guides/data-analysis.js.map +1 -0
  18. package/dist/prompts/best-practices/guides/data-extraction.d.ts +7 -0
  19. package/dist/prompts/best-practices/guides/data-extraction.js +124 -0
  20. package/dist/prompts/best-practices/guides/data-extraction.js.map +1 -0
  21. package/dist/prompts/best-practices/guides/data-persistence.d.ts +7 -0
  22. package/dist/prompts/best-practices/guides/data-persistence.js +199 -0
  23. package/dist/prompts/best-practices/guides/data-persistence.js.map +1 -0
  24. package/dist/prompts/best-practices/guides/data-transformation.d.ts +7 -0
  25. package/dist/prompts/best-practices/guides/data-transformation.js +148 -0
  26. package/dist/prompts/best-practices/guides/data-transformation.js.map +1 -0
  27. package/dist/prompts/best-practices/guides/document-processing.d.ts +7 -0
  28. package/dist/prompts/best-practices/guides/document-processing.js +334 -0
  29. package/dist/prompts/best-practices/guides/document-processing.js.map +1 -0
  30. package/dist/prompts/best-practices/guides/enrichment.d.ts +7 -0
  31. package/dist/prompts/best-practices/guides/enrichment.js +273 -0
  32. package/dist/prompts/best-practices/guides/enrichment.js.map +1 -0
  33. package/dist/prompts/best-practices/guides/form-input.d.ts +7 -0
  34. package/dist/prompts/best-practices/guides/form-input.js +175 -0
  35. package/dist/prompts/best-practices/guides/form-input.js.map +1 -0
  36. package/dist/prompts/best-practices/guides/human-in-the-loop.d.ts +7 -0
  37. package/dist/prompts/best-practices/guides/human-in-the-loop.js +270 -0
  38. package/dist/prompts/best-practices/guides/human-in-the-loop.js.map +1 -0
  39. package/dist/prompts/best-practices/guides/knowledge-base.d.ts +7 -0
  40. package/dist/prompts/best-practices/guides/knowledge-base.js +270 -0
  41. package/dist/prompts/best-practices/guides/knowledge-base.js.map +1 -0
  42. package/dist/prompts/best-practices/guides/monitoring.d.ts +7 -0
  43. package/dist/prompts/best-practices/guides/monitoring.js +173 -0
  44. package/dist/prompts/best-practices/guides/monitoring.js.map +1 -0
  45. package/dist/prompts/best-practices/guides/notification.d.ts +7 -0
  46. package/dist/prompts/best-practices/guides/notification.js +137 -0
  47. package/dist/prompts/best-practices/guides/notification.js.map +1 -0
  48. package/dist/prompts/best-practices/guides/scheduling.d.ts +7 -0
  49. package/dist/prompts/best-practices/guides/scheduling.js +154 -0
  50. package/dist/prompts/best-practices/guides/scheduling.js.map +1 -0
  51. package/dist/prompts/best-practices/guides/scraping-and-research.d.ts +7 -0
  52. package/dist/prompts/best-practices/guides/scraping-and-research.js +160 -0
  53. package/dist/prompts/best-practices/guides/scraping-and-research.js.map +1 -0
  54. package/dist/prompts/best-practices/guides/triage.d.ts +7 -0
  55. package/dist/prompts/best-practices/guides/triage.js +151 -0
  56. package/dist/prompts/best-practices/guides/triage.js.map +1 -0
  57. package/dist/prompts/best-practices/index.d.ts +20 -0
  58. package/dist/prompts/best-practices/index.js +69 -0
  59. package/dist/prompts/best-practices/index.js.map +1 -0
  60. package/dist/prompts/best-practices/types.d.ts +25 -0
  61. package/dist/prompts/best-practices/types.js +40 -0
  62. package/dist/prompts/best-practices/types.js.map +1 -0
  63. package/dist/prompts/index.d.ts +3 -0
  64. package/dist/prompts/index.js +25 -0
  65. package/dist/prompts/index.js.map +1 -0
  66. package/dist/prompts/node-guidance/index.d.ts +3 -0
  67. package/dist/prompts/node-guidance/index.js +20 -0
  68. package/dist/prompts/node-guidance/index.js.map +1 -0
  69. package/dist/prompts/node-guidance/node-recommendations/audio-generation.d.ts +2 -0
  70. package/dist/prompts/node-guidance/node-recommendations/audio-generation.js +18 -0
  71. package/dist/prompts/node-guidance/node-recommendations/audio-generation.js.map +1 -0
  72. package/dist/prompts/node-guidance/node-recommendations/format-recommendation.d.ts +2 -0
  73. package/dist/prompts/node-guidance/node-recommendations/format-recommendation.js +27 -0
  74. package/dist/prompts/node-guidance/node-recommendations/format-recommendation.js.map +1 -0
  75. package/dist/prompts/node-guidance/node-recommendations/image-generation.d.ts +2 -0
  76. package/dist/prompts/node-guidance/node-recommendations/image-generation.js +18 -0
  77. package/dist/prompts/node-guidance/node-recommendations/image-generation.js.map +1 -0
  78. package/dist/prompts/node-guidance/node-recommendations/index.d.ts +6 -0
  79. package/dist/prompts/node-guidance/node-recommendations/index.js +17 -0
  80. package/dist/prompts/node-guidance/node-recommendations/index.js.map +1 -0
  81. package/dist/prompts/node-guidance/node-recommendations/text-manipulation.d.ts +2 -0
  82. package/dist/prompts/node-guidance/node-recommendations/text-manipulation.js +27 -0
  83. package/dist/prompts/node-guidance/node-recommendations/text-manipulation.js.map +1 -0
  84. package/dist/prompts/node-guidance/node-recommendations/types.d.ts +26 -0
  85. package/dist/prompts/node-guidance/node-recommendations/types.js +16 -0
  86. package/dist/prompts/node-guidance/node-recommendations/types.js.map +1 -0
  87. package/dist/prompts/node-guidance/node-recommendations/video-generation.d.ts +2 -0
  88. package/dist/prompts/node-guidance/node-recommendations/video-generation.js +15 -0
  89. package/dist/prompts/node-guidance/node-recommendations/video-generation.js.map +1 -0
  90. package/dist/prompts/node-guidance/node-tips/index.d.ts +3 -0
  91. package/dist/prompts/node-guidance/node-tips/index.js +8 -0
  92. package/dist/prompts/node-guidance/node-tips/index.js.map +1 -0
  93. package/dist/prompts/node-guidance/node-tips/structured-output-parser.d.ts +2 -0
  94. package/dist/prompts/node-guidance/node-tips/structured-output-parser.js +35 -0
  95. package/dist/prompts/node-guidance/node-tips/structured-output-parser.js.map +1 -0
  96. package/dist/prompts/node-guidance/node-tips/types.d.ts +7 -0
  97. package/dist/prompts/node-guidance/node-tips/types.js +3 -0
  98. package/dist/prompts/node-guidance/node-tips/types.js.map +1 -0
  99. package/dist/prompts/node-guidance/node-tips/webhook.d.ts +2 -0
  100. package/dist/prompts/node-guidance/node-tips/webhook.js +38 -0
  101. package/dist/prompts/node-guidance/node-tips/webhook.js.map +1 -0
  102. package/dist/prompts/node-guidance/parameter-guides/embedding-nodes.d.ts +2 -0
  103. package/dist/prompts/node-guidance/parameter-guides/embedding-nodes.js +70 -0
  104. package/dist/prompts/node-guidance/parameter-guides/embedding-nodes.js.map +1 -0
  105. package/dist/prompts/node-guidance/parameter-guides/gmail.d.ts +2 -0
  106. package/dist/prompts/node-guidance/parameter-guides/gmail.js +53 -0
  107. package/dist/prompts/node-guidance/parameter-guides/gmail.js.map +1 -0
  108. package/dist/prompts/node-guidance/parameter-guides/http-request.d.ts +2 -0
  109. package/dist/prompts/node-guidance/parameter-guides/http-request.js +139 -0
  110. package/dist/prompts/node-guidance/parameter-guides/http-request.js.map +1 -0
  111. package/dist/prompts/node-guidance/parameter-guides/if-node.d.ts +2 -0
  112. package/dist/prompts/node-guidance/parameter-guides/if-node.js +159 -0
  113. package/dist/prompts/node-guidance/parameter-guides/if-node.js.map +1 -0
  114. package/dist/prompts/node-guidance/parameter-guides/index.d.ts +12 -0
  115. package/dist/prompts/node-guidance/parameter-guides/index.js +26 -0
  116. package/dist/prompts/node-guidance/parameter-guides/index.js.map +1 -0
  117. package/dist/prompts/node-guidance/parameter-guides/predecessor-output.d.ts +2 -0
  118. package/dist/prompts/node-guidance/parameter-guides/predecessor-output.js +25 -0
  119. package/dist/prompts/node-guidance/parameter-guides/predecessor-output.js.map +1 -0
  120. package/dist/prompts/node-guidance/parameter-guides/resource-locator.d.ts +2 -0
  121. package/dist/prompts/node-guidance/parameter-guides/resource-locator.js +40 -0
  122. package/dist/prompts/node-guidance/parameter-guides/resource-locator.js.map +1 -0
  123. package/dist/prompts/node-guidance/parameter-guides/set-node.d.ts +2 -0
  124. package/dist/prompts/node-guidance/parameter-guides/set-node.js +94 -0
  125. package/dist/prompts/node-guidance/parameter-guides/set-node.js.map +1 -0
  126. package/dist/prompts/node-guidance/parameter-guides/switch-node.d.ts +2 -0
  127. package/dist/prompts/node-guidance/parameter-guides/switch-node.js +75 -0
  128. package/dist/prompts/node-guidance/parameter-guides/switch-node.js.map +1 -0
  129. package/dist/prompts/node-guidance/parameter-guides/system-message.d.ts +2 -0
  130. package/dist/prompts/node-guidance/parameter-guides/system-message.js +96 -0
  131. package/dist/prompts/node-guidance/parameter-guides/system-message.js.map +1 -0
  132. package/dist/prompts/node-guidance/parameter-guides/text-fields.d.ts +2 -0
  133. package/dist/prompts/node-guidance/parameter-guides/text-fields.js +31 -0
  134. package/dist/prompts/node-guidance/parameter-guides/text-fields.js.map +1 -0
  135. package/dist/prompts/node-guidance/parameter-guides/tool-nodes.d.ts +2 -0
  136. package/dist/prompts/node-guidance/parameter-guides/tool-nodes.js +76 -0
  137. package/dist/prompts/node-guidance/parameter-guides/tool-nodes.js.map +1 -0
  138. package/dist/prompts/node-guidance/parameter-guides/types.d.ts +18 -0
  139. package/dist/prompts/node-guidance/parameter-guides/types.js +3 -0
  140. package/dist/prompts/node-guidance/parameter-guides/types.js.map +1 -0
  141. package/dist/prompts/node-selection/ai-nodes.d.ts +2 -0
  142. package/dist/prompts/node-selection/ai-nodes.js +35 -0
  143. package/dist/prompts/node-selection/ai-nodes.js.map +1 -0
  144. package/dist/prompts/node-selection/connection-parameters.d.ts +1 -0
  145. package/dist/prompts/node-selection/connection-parameters.js +13 -0
  146. package/dist/prompts/node-selection/connection-parameters.js.map +1 -0
  147. package/dist/prompts/node-selection/index.d.ts +5 -0
  148. package/dist/prompts/node-selection/index.js +16 -0
  149. package/dist/prompts/node-selection/index.js.map +1 -0
  150. package/dist/prompts/node-selection/native-preference.d.ts +1 -0
  151. package/dist/prompts/node-selection/native-preference.js +18 -0
  152. package/dist/prompts/node-selection/native-preference.js.map +1 -0
  153. package/dist/prompts/node-selection/trigger-selection.d.ts +1 -0
  154. package/dist/prompts/node-selection/trigger-selection.js +23 -0
  155. package/dist/prompts/node-selection/trigger-selection.js.map +1 -0
  156. package/dist/prompts/node-selection/use-case-patterns.d.ts +2 -0
  157. package/dist/prompts/node-selection/use-case-patterns.js +58 -0
  158. package/dist/prompts/node-selection/use-case-patterns.js.map +1 -0
  159. package/dist/prompts/sdk-reference/additional-functions.d.ts +1 -0
  160. package/dist/prompts/sdk-reference/additional-functions.js +20 -0
  161. package/dist/prompts/sdk-reference/additional-functions.js.map +1 -0
  162. package/dist/prompts/sdk-reference/expressions.d.ts +1 -0
  163. package/dist/prompts/sdk-reference/expressions.js +34 -0
  164. package/dist/prompts/sdk-reference/expressions.js.map +1 -0
  165. package/dist/prompts/sdk-reference/index.d.ts +5 -0
  166. package/dist/prompts/sdk-reference/index.js +14 -0
  167. package/dist/prompts/sdk-reference/index.js.map +1 -0
  168. package/dist/prompts/sdk-reference/workflow-patterns-detailed.d.ts +1 -0
  169. package/dist/prompts/sdk-reference/workflow-patterns-detailed.js +398 -0
  170. package/dist/prompts/sdk-reference/workflow-patterns-detailed.js.map +1 -0
  171. package/dist/prompts/sdk-reference/workflow-patterns.d.ts +2 -0
  172. package/dist/prompts/sdk-reference/workflow-patterns.js +479 -0
  173. package/dist/prompts/sdk-reference/workflow-patterns.js.map +1 -0
  174. package/dist/prompts/sdk-reference/workflow-rules.d.ts +1 -0
  175. package/dist/prompts/sdk-reference/workflow-rules.js +23 -0
  176. package/dist/prompts/sdk-reference/workflow-rules.js.map +1 -0
  177. package/dist/typeguards.d.ts +3 -0
  178. package/dist/typeguards.js +14 -0
  179. package/dist/typeguards.js.map +1 -0
  180. package/dist/workflow-builder/plugins/defaults.js +1 -0
  181. package/dist/workflow-builder/plugins/defaults.js.map +1 -1
  182. package/dist/workflow-builder/plugins/validators/filter-node-validator.d.ts +2 -0
  183. package/dist/workflow-builder/plugins/validators/filter-node-validator.js +90 -0
  184. package/dist/workflow-builder/plugins/validators/filter-node-validator.js.map +1 -0
  185. package/dist/workflow-builder/plugins/validators/index.d.ts +1 -0
  186. package/dist/workflow-builder/plugins/validators/index.js +3 -1
  187. package/dist/workflow-builder/plugins/validators/index.js.map +1 -1
  188. package/dist/workflow-builder.js +15 -0
  189. package/dist/workflow-builder.js.map +1 -1
  190. package/package.json +48 -2
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormInputBestPractices = void 0;
4
+ const types_1 = require("../types");
5
+ class FormInputBestPractices {
6
+ constructor() {
7
+ this.technique = types_1.WorkflowTechnique.FORM_INPUT;
8
+ this.version = '1.0.0';
9
+ this.documentation = `# Best Practices: Form Input Workflows
10
+
11
+ ## Workflow Design
12
+
13
+ ### Critical: Always Store Raw Form Data
14
+
15
+ ALWAYS store raw form responses to a persistent data storage destination even if the primary purpose of the workflow is
16
+ to trigger another action (like sending to an API or triggering a notification). This allows users to monitor
17
+ form responses as part of the administration of their workflow.
18
+
19
+ Required storage destinations include:
20
+ - Google Sheets node
21
+ - Airtable node
22
+ - n8n Data Tables
23
+ - PostgreSQL/MySQL/MongoDB nodes
24
+ - Any other database or spreadsheet service
25
+
26
+ IMPORTANT: Simply using Set or Merge nodes is NOT sufficient. These nodes only transform data in memory - they do not
27
+ persist data. You must use an actual storage node (like Google Sheets, Airtable, or Data Tables) to write the data.
28
+
29
+ Storage Requirements:
30
+ - Store the un-edited user input immediately after the form steps are complete
31
+ - Do not store only a summary or edited version of the user's inputs - store the raw data
32
+ - For single-step forms: store immediately after the form trigger
33
+ - For multi-step forms: store immediately after aggregating all steps with Set/Merge nodes
34
+ - The storage node should appear in the workflow right after data collection/aggregation
35
+
36
+ ## Message Attribution
37
+
38
+ n8n forms attach the attribution "n8n workflow" to messages by default - you must disable this setting which will
39
+ often be called "Append n8n Attribution" for the n8n form nodes, add this setting and set it to false.
40
+
41
+ ## Multi-Step Forms
42
+
43
+ Build multi-step forms by chaining multiple Form nodes together. Each Form node represents a page or step in your form
44
+ sequence. Use the n8n Form Trigger node to start the workflow and display the first form page to the user.
45
+
46
+ ## Data Collection & Aggregation
47
+
48
+ Collect and merge all user responses from each form step before writing to your destination (e.g., Data Table). Use
49
+ Set or Merge nodes to combine data as needed. Make sure your JSON keys match the column names in your destination for
50
+ automatic mapping.
51
+
52
+ ## Conditional Logic & Branching
53
+
54
+ Use IF or Switch nodes to direct users to different form pages based on their previous answers. This enables dynamic
55
+ form flows where the path changes based on user input, creating personalized form experiences.
56
+
57
+ ## Dynamic Form Fields
58
+
59
+ For forms that require dynamic options (e.g., dropdowns populated from an API or previous step), generate the form
60
+ definition in a Code node and pass it to the Form node as JSON. You can define forms using JSON for dynamic or
61
+ conditional fields, and even generate form fields dynamically using a Code node if needed.
62
+
63
+ ## Input Validation
64
+
65
+ Validate user input between steps to ensure data quality. If input is invalid, loop back to the relevant form step with
66
+ an error message to guide the user to correct their submission. This prevents bad data from entering your system.
67
+
68
+ ## Recommended Nodes
69
+
70
+ ### n8n Form Trigger (n8n-nodes-base.formTrigger)
71
+
72
+ Purpose: Starts the workflow and displays the first form page to the user
73
+
74
+ Pitfalls:
75
+
76
+ - Use the Production URL for live forms; the Test URL is for development and debugging only
77
+ - Ensure the form trigger is properly configured before sharing URLs with users
78
+
79
+ ### n8n Form (n8n-nodes-base.form)
80
+
81
+ Purpose: Displays form pages in multi-step form sequences
82
+
83
+ Pitfalls:
84
+
85
+ - Each Form node represents one page/step in your form
86
+ - You can define forms using JSON for dynamic or conditional fields
87
+ - Generate form fields dynamically using a Code node if needed for complex scenarios
88
+
89
+ ### Storage Nodes
90
+
91
+ Purpose: Persist raw form data to a storage destination, preference should be for built-in n8n tables
92
+ but use the most applicable node depending on the user's request.
93
+
94
+ Required nodes (use at least one):
95
+ - Data table (n8n-nodes-base.dataTable): Built-in n8n storage for quick setup - preferred
96
+ - Google Sheets (n8n-nodes-base.googleSheets): Best for simple spreadsheet storage
97
+ - Airtable (n8n-nodes-base.airtable): Best for structured database with relationships
98
+ - Postgres (n8n-nodes-base.postgres) / MySQL (n8n-nodes-base.mySql) / MongoDB (n8n-nodes-base.mongoDb): For production database storage
99
+
100
+ Pitfalls:
101
+
102
+ - Every form workflow MUST include a storage node that actually writes data to a destination
103
+ - Set and Merge nodes alone are NOT sufficient - they only transform data in memory
104
+ - The storage node should be placed immediately after the form trigger (single-step) or after data aggregation (multi-step)
105
+
106
+ ### Code (n8n-nodes-base.code)
107
+
108
+ Purpose: Processes form data, generates dynamic form definitions, or implements custom validation logic
109
+
110
+ ### Edit Fields (Set) (n8n-nodes-base.set)
111
+
112
+ Purpose: Aggregates and transforms form data between steps (NOT for storage - use a storage node)
113
+
114
+ ### Merge (n8n-nodes-base.merge)
115
+
116
+ Purpose: Combines data from multiple form steps into a single dataset (NOT for storage - use a storage node)
117
+
118
+ Pitfalls:
119
+
120
+ - Ensure data from all form steps is properly merged before writing to destination
121
+ - Use appropriate merge modes (append, merge by key, etc.) for your use case
122
+ - Remember: Merge prepares data but does not store it - add a storage node after Merge
123
+
124
+ ### If (n8n-nodes-base.if)
125
+
126
+ Purpose: Routes users to different form pages based on their previous answers
127
+
128
+ ### Switch (n8n-nodes-base.switch)
129
+
130
+ Purpose: Implements multi-path conditional routing in complex forms
131
+
132
+ Pitfalls:
133
+
134
+ - Include a default case to handle unexpected input values
135
+ - Keep routing logic clear and maintainable
136
+
137
+ ## Common Pitfalls to Avoid
138
+
139
+ ### Missing Raw Form Response Storage
140
+
141
+ When building n8n forms it is recommended to always store the raw form response to some form of data storage (Googlesheets, Airtable, etc)
142
+ for administration later. It is CRITICAL if you create a n8n form node that you store the raw output with a storage node.
143
+
144
+ ### Data Loss in Multi-Step Forms
145
+
146
+ Aggregate all form step data using Set/Merge nodes before writing to your destination. Failing to merge data from multiple steps
147
+ can result in incomplete form submissions being stored. After merging, ensure you write the complete dataset to a storage node.
148
+
149
+ ### Poor User Experience
150
+
151
+ Use the Form Ending page type to show a completion message or redirect users after submission.
152
+ Without a proper ending, users may be confused about whether their submission was successful.
153
+
154
+ ### Invalid Data
155
+
156
+ Implement validation between form steps to catch errors early. Without validation, invalid data can
157
+ propagate through your workflow and corrupt your destination data.
158
+
159
+ ### Complex Field Generation
160
+
161
+ When generating dynamic form fields, ensure the JSON structure exactly matches what the Form
162
+ node expects. Test thoroughly with the Test URL before going live.
163
+
164
+ ### Mapping Errors
165
+
166
+ When writing to Google Sheets or other destinations, ensure field names match exactly. Mismatched names
167
+ will cause data to be written to wrong columns or fail entirely.
168
+ `;
169
+ }
170
+ getDocumentation() {
171
+ return this.documentation;
172
+ }
173
+ }
174
+ exports.FormInputBestPractices = FormInputBestPractices;
175
+ //# sourceMappingURL=form-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-input.js","sourceRoot":"","sources":["../../../../src/prompts/best-practices/guides/form-input.ts"],"names":[],"mappings":";;;AACA,oCAA6C;AAE7C,MAAa,sBAAsB;IAAnC;QACU,cAAS,GAAG,yBAAiB,CAAC,UAAU,CAAC;QACzC,YAAO,GAAG,OAAO,CAAC;QAEV,kBAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+JjC,CAAC;IAKF,CAAC;IAHA,gBAAgB;QACf,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;CACD;AAxKD,wDAwKC"}
@@ -0,0 +1,7 @@
1
+ import type { BestPracticesDocument } from '../types';
2
+ export declare class HumanInTheLoopBestPractices implements BestPracticesDocument {
3
+ readonly technique: "human_in_the_loop";
4
+ readonly version = "1.0.0";
5
+ private readonly documentation;
6
+ getDocumentation(): string;
7
+ }
@@ -0,0 +1,270 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HumanInTheLoopBestPractices = void 0;
4
+ const types_1 = require("../types");
5
+ class HumanInTheLoopBestPractices {
6
+ constructor() {
7
+ this.technique = types_1.WorkflowTechnique.HUMAN_IN_THE_LOOP;
8
+ this.version = '1.0.0';
9
+ this.documentation = `# Best Practices: Human-in-the-Loop Workflows
10
+
11
+ ## Workflow Design
12
+
13
+ Structure workflows in three stages: Automation → Human Decision → Resume Processing. The Wait node is the core component for implementing pauses.
14
+
15
+ Break the workflow into clear stages:
16
+ 1. **Initial Automation**: Execute automated steps leading to the decision point (data extraction, AI content generation, etc.)
17
+ 2. **Human Notification**: Send notification with resume URL via preferred channel (Email, Slack, Telegram)
18
+ 3. **Wait for Response**: Configure Wait node with appropriate resume condition
19
+ 4. **Process Decision**: Use IF/Switch nodes to branch based on human input
20
+
21
+ Example pattern:
22
+ - Trigger → Generate Content → Email (with resume URLs) → Wait Node → IF (decision) → Publish/Reject
23
+ - HTTP Request (fetch data) → Filter → Email Manager → Wait (On Webhook) → Switch (approval status) → Database Update
24
+
25
+ CRITICAL: Always include the $execution.resumeUrl in notification messages. This unique URL resumes the specific workflow execution when accessed.
26
+
27
+ ## Wait Node Configuration
28
+
29
+ The Wait node supports four resume conditions:
30
+ - **After Time Interval**: Resume after fixed delay (not for human decisions)
31
+ - **At Specified Time**: Resume at specific date/time (not for human decisions)
32
+ - **On Webhook Call**: Resume when URL is accessed (ideal for link-based approvals)
33
+ - **On Form Submitted**: Resume when user submits n8n-hosted form (best for structured input)
34
+
35
+ For human-in-the-loop, use "On Webhook Call" or "On Form Submitted" modes.
36
+
37
+ ### Webhook Configuration
38
+ - Set HTTP method (GET for simple links, POST for data)
39
+ - Configure authentication if needed (None for private URLs, Basic/Token for security)
40
+ - Enable "Ignore Bots" to prevent email scanners/chat bots from triggering
41
+ - Use Webhook Suffix for multiple wait points in same workflow
42
+
43
+ ### Form Configuration
44
+ - Design form fields directly in Wait node
45
+ - Specify field types, labels, validation
46
+ - Form automatically hosts at resume URL
47
+ - Submitted data merges with workflow context
48
+
49
+ ## Timeout Management
50
+
51
+ Always configure "Limit Wait Time" to prevent infinite waits:
52
+ - Set maximum wait duration (e.g., 48 hours)
53
+ - Or specify absolute deadline date
54
+ - Handle timeout case in workflow logic
55
+ - Check if resumed by timeout (no webhook/form data present)
56
+
57
+ ## Communication Patterns
58
+
59
+ ### Direct Link Method
60
+ Include $execution.resumeUrl directly in messages:
61
+
62
+ Email: Click to [Approve]({{$execution.resumeUrl}}?decision=approve) or [Reject]({{$execution.resumeUrl}}?decision=reject)
63
+ Slack: Please review and click: {{$execution.resumeUrl}}
64
+
65
+ ### Platform Response Method
66
+ For responses within platform (Slack reply, email response):
67
+ - Use separate trigger workflow to catch responses
68
+ - Correlate to correct execution via ID
69
+ - Call resume URL programmatically
70
+ - More complex but keeps interaction native
71
+
72
+ ## Data Handling
73
+
74
+ The Wait node preserves all prior workflow data when resuming:
75
+ - Original context remains available
76
+ - New input data (form/webhook) adds to context
77
+ - Access webhook data via $json after Wait node
78
+ - Query parameters available in $json.query
79
+ - Form fields merge directly into JSON output
80
+
81
+ ## Recommended Nodes
82
+
83
+ ### Wait (n8n-nodes-base.wait)
84
+
85
+ **Purpose**: Core node for pausing workflow execution until human input
86
+
87
+ **Key Settings**:
88
+ - Resume: "On Webhook Call" or "On Form Submitted"
89
+ - Authentication: Configure based on security needs
90
+ - Ignore Bots: Enable to prevent accidental triggers
91
+ - Limit Wait Time: Set timeout to prevent infinite waits
92
+
93
+ **Use Cases**:
94
+ - Approval workflows
95
+ - Data collection from humans
96
+ - Multi-step verification processes
97
+
98
+ **Best Practices**:
99
+ - Always include timeout handling
100
+ - Use unique webhook suffixes for multiple waits
101
+ - Test resume URLs during development
102
+
103
+ ### Email (n8n-nodes-base.emailSend)
104
+
105
+ **Purpose**: Send notifications with resume links to users
106
+
107
+ **Use Cases**:
108
+ - Approval request emails
109
+ - Data verification requests
110
+ - Task assignment notifications
111
+
112
+ **Best Practices**:
113
+ - Include clear call-to-action buttons
114
+ - Embed resume URL as hyperlinks
115
+ - Provide context about the decision needed
116
+
117
+ ### Slack (n8n-nodes-base.slack)
118
+
119
+ **Purpose**: Send notifications via Slack with resume links
120
+
121
+ **Best Practices**:
122
+ - Wrap URLs in <> to prevent unfurling
123
+ - Use clear message formatting
124
+ - Consider using blocks for rich formatting
125
+
126
+ ### Telegram (n8n-nodes-base.telegram)
127
+
128
+ **Purpose**: Send notifications via Telegram
129
+
130
+ **Best Practices**:
131
+ - Enable "Ignore Bots" in Wait node
132
+ - Use inline keyboards for better UX
133
+ - Keep messages concise
134
+
135
+ ### IF (n8n-nodes-base.if)
136
+
137
+ **Purpose**: Branch workflow based on human decision
138
+
139
+ **Use Cases**:
140
+ - Route approved vs rejected items
141
+ - Check if response was received (vs timeout)
142
+ - Validate input data
143
+
144
+ **Best Practices**:
145
+ - Handle all possible decision values
146
+ - Include default/timeout branch
147
+ - Use clear condition names
148
+
149
+ ### Switch (n8n-nodes-base.switch)
150
+
151
+ **Purpose**: Multi-way branching for complex decisions
152
+
153
+ **Use Cases**:
154
+ - Multiple approval levels
155
+ - Various response options
156
+ - Status-based routing
157
+
158
+ ### HTTP Request (n8n-nodes-base.httpRequest)
159
+
160
+ **Purpose**: Call external APIs after human decision
161
+
162
+ **Use Cases**:
163
+ - Update external systems
164
+ - Trigger downstream processes
165
+ - Log decisions to external services
166
+
167
+ ### Database Nodes
168
+
169
+ **MySQL** (n8n-nodes-base.mySql), **Postgres** (n8n-nodes-base.postgres), **MongoDB** (n8n-nodes-base.mongoDb):
170
+ - Store approval history
171
+ - Update record status after decision
172
+ - Log human inputs for audit
173
+
174
+ ### Google Sheets (n8n-nodes-base.googleSheets)
175
+
176
+ **Purpose**: Track decisions and maintain approval logs
177
+
178
+ **Use Cases**:
179
+ - Approval tracking spreadsheets
180
+ - Decision audit logs
181
+ - User response collection
182
+
183
+ ## Common Pitfalls to Avoid
184
+
185
+ ### Accidental Resume Triggers
186
+
187
+ **Problem**: Email clients or chat apps preview links and trigger resume unintentionally.
188
+
189
+ **Solution**:
190
+ - Enable "Ignore Bots" option in Wait node
191
+ - Wrap Slack URLs in <> to prevent unfurling
192
+ - Use authentication for sensitive workflows
193
+ - Educate users to click only when ready
194
+
195
+ ### Missing Timeouts
196
+
197
+ **Problem**: Workflow waits forever if human never responds.
198
+
199
+ **Solution**:
200
+ - Always set "Limit Wait Time" (e.g., 3 days)
201
+ - Handle timeout scenario in workflow logic
202
+ - Send reminder before deadline
203
+ - Escalate to another person if timeout occurs
204
+
205
+ ### Lost Context After Wait
206
+
207
+ **Problem**: Assuming data is lost after Wait node resumes.
208
+
209
+ **Solution**:
210
+ - Wait node preserves all prior data automatically
211
+ - New input merges with existing context
212
+ - Test data structure after resume
213
+ - Use expressions to access both old and new data
214
+
215
+ ### Security Issues with Resume URLs
216
+
217
+ **Problem**: Resume URLs exposed to unauthorized users.
218
+
219
+ **Solution**:
220
+ - Treat resume URLs as secrets
221
+ - Use authentication options for sensitive workflows
222
+ - Send only through private channels
223
+ - Consider IP whitelisting if needed
224
+
225
+ ### Multiple Wait Node Confusion
226
+
227
+ **Problem**: Using same webhook URL for different wait points.
228
+
229
+ **Solution**:
230
+ - Use unique Webhook Suffix for each Wait node
231
+ - Generate fresh $execution.resumeUrl for each wait
232
+ - Label wait points clearly
233
+ - Document which URL corresponds to which decision
234
+
235
+ ### Not Handling All Response Types
236
+
237
+ **Problem**: Only handling expected responses, not edge cases.
238
+
239
+ **Solution**:
240
+ - Handle timeout case explicitly
241
+ - Provide default action for unexpected inputs
242
+ - Validate form data before processing
243
+ - Log all decisions for debugging
244
+
245
+ ### Workflow State Persistence
246
+
247
+ **Problem**: Worrying about resource consumption during wait.
248
+
249
+ **Solution**:
250
+ - Waiting executions are saved to database, not running
251
+ - No worker threads consumed during wait
252
+ - Can have hundreds of paused workflows
253
+ - Survives n8n restarts (state in database)
254
+
255
+ ### Complex Parallel Approvals
256
+
257
+ **Problem**: Need multiple people to approve before continuing.
258
+
259
+ **Solution**:
260
+ - Use separate Wait node per approver
261
+ - Or create sub-workflow per approver
262
+ - Use Merge node to synchronize branches
263
+ - Consider approval tracking in database`;
264
+ }
265
+ getDocumentation() {
266
+ return this.documentation;
267
+ }
268
+ }
269
+ exports.HumanInTheLoopBestPractices = HumanInTheLoopBestPractices;
270
+ //# sourceMappingURL=human-in-the-loop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"human-in-the-loop.js","sourceRoot":"","sources":["../../../../src/prompts/best-practices/guides/human-in-the-loop.ts"],"names":[],"mappings":";;;AACA,oCAA6C;AAE7C,MAAa,2BAA2B;IAAxC;QACU,cAAS,GAAG,yBAAiB,CAAC,iBAAiB,CAAC;QAChD,YAAO,GAAG,OAAO,CAAC;QAEV,kBAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yCA8PO,CAAC;IAK1C,CAAC;IAHA,gBAAgB;QACf,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;CACD;AAvQD,kEAuQC"}
@@ -0,0 +1,7 @@
1
+ import type { BestPracticesDocument } from '../types';
2
+ export declare class KnowledgeBaseBestPractices implements BestPracticesDocument {
3
+ readonly technique: "knowledge_base";
4
+ readonly version = "1.0.0";
5
+ private readonly documentation;
6
+ getDocumentation(): string;
7
+ }