@n8n/workflow-sdk 0.8.0 → 0.10.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 (211) hide show
  1. package/dist/build.tsbuildinfo +1 -1
  2. package/dist/codegen/code-generator.js +8 -8
  3. package/dist/codegen/code-generator.js.map +1 -1
  4. package/dist/codegen/subnode-generator.d.ts +4 -0
  5. package/dist/codegen/subnode-generator.js +23 -2
  6. package/dist/codegen/subnode-generator.js.map +1 -1
  7. package/dist/generate-types/generate-types.d.ts +1 -0
  8. package/dist/generate-types/generate-types.js +27 -1
  9. package/dist/generate-types/generate-types.js.map +1 -1
  10. package/dist/generate-types/generate-zod-schemas.js +1 -1
  11. package/dist/generate-types/generate-zod-schemas.js.map +1 -1
  12. package/dist/index.d.ts +3 -1
  13. package/dist/index.js +6 -2
  14. package/dist/index.js.map +1 -1
  15. package/dist/prompts/best-practices/guides/chatbot.d.ts +7 -0
  16. package/dist/prompts/best-practices/guides/chatbot.js +120 -0
  17. package/dist/prompts/best-practices/guides/chatbot.js.map +1 -0
  18. package/dist/prompts/best-practices/guides/content-generation.d.ts +7 -0
  19. package/dist/prompts/best-practices/guides/content-generation.js +117 -0
  20. package/dist/prompts/best-practices/guides/content-generation.js.map +1 -0
  21. package/dist/prompts/best-practices/guides/data-analysis.d.ts +7 -0
  22. package/dist/prompts/best-practices/guides/data-analysis.js +369 -0
  23. package/dist/prompts/best-practices/guides/data-analysis.js.map +1 -0
  24. package/dist/prompts/best-practices/guides/data-extraction.d.ts +7 -0
  25. package/dist/prompts/best-practices/guides/data-extraction.js +124 -0
  26. package/dist/prompts/best-practices/guides/data-extraction.js.map +1 -0
  27. package/dist/prompts/best-practices/guides/data-persistence.d.ts +7 -0
  28. package/dist/prompts/best-practices/guides/data-persistence.js +199 -0
  29. package/dist/prompts/best-practices/guides/data-persistence.js.map +1 -0
  30. package/dist/prompts/best-practices/guides/data-transformation.d.ts +7 -0
  31. package/dist/prompts/best-practices/guides/data-transformation.js +148 -0
  32. package/dist/prompts/best-practices/guides/data-transformation.js.map +1 -0
  33. package/dist/prompts/best-practices/guides/document-processing.d.ts +7 -0
  34. package/dist/prompts/best-practices/guides/document-processing.js +334 -0
  35. package/dist/prompts/best-practices/guides/document-processing.js.map +1 -0
  36. package/dist/prompts/best-practices/guides/enrichment.d.ts +7 -0
  37. package/dist/prompts/best-practices/guides/enrichment.js +273 -0
  38. package/dist/prompts/best-practices/guides/enrichment.js.map +1 -0
  39. package/dist/prompts/best-practices/guides/form-input.d.ts +7 -0
  40. package/dist/prompts/best-practices/guides/form-input.js +175 -0
  41. package/dist/prompts/best-practices/guides/form-input.js.map +1 -0
  42. package/dist/prompts/best-practices/guides/human-in-the-loop.d.ts +7 -0
  43. package/dist/prompts/best-practices/guides/human-in-the-loop.js +270 -0
  44. package/dist/prompts/best-practices/guides/human-in-the-loop.js.map +1 -0
  45. package/dist/prompts/best-practices/guides/knowledge-base.d.ts +7 -0
  46. package/dist/prompts/best-practices/guides/knowledge-base.js +270 -0
  47. package/dist/prompts/best-practices/guides/knowledge-base.js.map +1 -0
  48. package/dist/prompts/best-practices/guides/monitoring.d.ts +7 -0
  49. package/dist/prompts/best-practices/guides/monitoring.js +173 -0
  50. package/dist/prompts/best-practices/guides/monitoring.js.map +1 -0
  51. package/dist/prompts/best-practices/guides/notification.d.ts +7 -0
  52. package/dist/prompts/best-practices/guides/notification.js +137 -0
  53. package/dist/prompts/best-practices/guides/notification.js.map +1 -0
  54. package/dist/prompts/best-practices/guides/scheduling.d.ts +7 -0
  55. package/dist/prompts/best-practices/guides/scheduling.js +154 -0
  56. package/dist/prompts/best-practices/guides/scheduling.js.map +1 -0
  57. package/dist/prompts/best-practices/guides/scraping-and-research.d.ts +7 -0
  58. package/dist/prompts/best-practices/guides/scraping-and-research.js +160 -0
  59. package/dist/prompts/best-practices/guides/scraping-and-research.js.map +1 -0
  60. package/dist/prompts/best-practices/guides/triage.d.ts +7 -0
  61. package/dist/prompts/best-practices/guides/triage.js +151 -0
  62. package/dist/prompts/best-practices/guides/triage.js.map +1 -0
  63. package/dist/prompts/best-practices/index.d.ts +20 -0
  64. package/dist/prompts/best-practices/index.js +69 -0
  65. package/dist/prompts/best-practices/index.js.map +1 -0
  66. package/dist/prompts/best-practices/types.d.ts +25 -0
  67. package/dist/prompts/best-practices/types.js +40 -0
  68. package/dist/prompts/best-practices/types.js.map +1 -0
  69. package/dist/prompts/index.d.ts +3 -0
  70. package/dist/prompts/index.js +25 -0
  71. package/dist/prompts/index.js.map +1 -0
  72. package/dist/prompts/node-guidance/index.d.ts +3 -0
  73. package/dist/prompts/node-guidance/index.js +20 -0
  74. package/dist/prompts/node-guidance/index.js.map +1 -0
  75. package/dist/prompts/node-guidance/node-recommendations/audio-generation.d.ts +2 -0
  76. package/dist/prompts/node-guidance/node-recommendations/audio-generation.js +18 -0
  77. package/dist/prompts/node-guidance/node-recommendations/audio-generation.js.map +1 -0
  78. package/dist/prompts/node-guidance/node-recommendations/format-recommendation.d.ts +2 -0
  79. package/dist/prompts/node-guidance/node-recommendations/format-recommendation.js +27 -0
  80. package/dist/prompts/node-guidance/node-recommendations/format-recommendation.js.map +1 -0
  81. package/dist/prompts/node-guidance/node-recommendations/image-generation.d.ts +2 -0
  82. package/dist/prompts/node-guidance/node-recommendations/image-generation.js +18 -0
  83. package/dist/prompts/node-guidance/node-recommendations/image-generation.js.map +1 -0
  84. package/dist/prompts/node-guidance/node-recommendations/index.d.ts +6 -0
  85. package/dist/prompts/node-guidance/node-recommendations/index.js +17 -0
  86. package/dist/prompts/node-guidance/node-recommendations/index.js.map +1 -0
  87. package/dist/prompts/node-guidance/node-recommendations/text-manipulation.d.ts +2 -0
  88. package/dist/prompts/node-guidance/node-recommendations/text-manipulation.js +27 -0
  89. package/dist/prompts/node-guidance/node-recommendations/text-manipulation.js.map +1 -0
  90. package/dist/prompts/node-guidance/node-recommendations/types.d.ts +26 -0
  91. package/dist/prompts/node-guidance/node-recommendations/types.js +16 -0
  92. package/dist/prompts/node-guidance/node-recommendations/types.js.map +1 -0
  93. package/dist/prompts/node-guidance/node-recommendations/video-generation.d.ts +2 -0
  94. package/dist/prompts/node-guidance/node-recommendations/video-generation.js +15 -0
  95. package/dist/prompts/node-guidance/node-recommendations/video-generation.js.map +1 -0
  96. package/dist/prompts/node-guidance/node-tips/index.d.ts +3 -0
  97. package/dist/prompts/node-guidance/node-tips/index.js +8 -0
  98. package/dist/prompts/node-guidance/node-tips/index.js.map +1 -0
  99. package/dist/prompts/node-guidance/node-tips/structured-output-parser.d.ts +2 -0
  100. package/dist/prompts/node-guidance/node-tips/structured-output-parser.js +35 -0
  101. package/dist/prompts/node-guidance/node-tips/structured-output-parser.js.map +1 -0
  102. package/dist/prompts/node-guidance/node-tips/types.d.ts +7 -0
  103. package/dist/prompts/node-guidance/node-tips/types.js +3 -0
  104. package/dist/prompts/node-guidance/node-tips/types.js.map +1 -0
  105. package/dist/prompts/node-guidance/node-tips/webhook.d.ts +2 -0
  106. package/dist/prompts/node-guidance/node-tips/webhook.js +38 -0
  107. package/dist/prompts/node-guidance/node-tips/webhook.js.map +1 -0
  108. package/dist/prompts/node-guidance/parameter-guides/embedding-nodes.d.ts +2 -0
  109. package/dist/prompts/node-guidance/parameter-guides/embedding-nodes.js +70 -0
  110. package/dist/prompts/node-guidance/parameter-guides/embedding-nodes.js.map +1 -0
  111. package/dist/prompts/node-guidance/parameter-guides/gmail.d.ts +2 -0
  112. package/dist/prompts/node-guidance/parameter-guides/gmail.js +53 -0
  113. package/dist/prompts/node-guidance/parameter-guides/gmail.js.map +1 -0
  114. package/dist/prompts/node-guidance/parameter-guides/http-request.d.ts +2 -0
  115. package/dist/prompts/node-guidance/parameter-guides/http-request.js +139 -0
  116. package/dist/prompts/node-guidance/parameter-guides/http-request.js.map +1 -0
  117. package/dist/prompts/node-guidance/parameter-guides/if-node.d.ts +2 -0
  118. package/dist/prompts/node-guidance/parameter-guides/if-node.js +159 -0
  119. package/dist/prompts/node-guidance/parameter-guides/if-node.js.map +1 -0
  120. package/dist/prompts/node-guidance/parameter-guides/index.d.ts +12 -0
  121. package/dist/prompts/node-guidance/parameter-guides/index.js +26 -0
  122. package/dist/prompts/node-guidance/parameter-guides/index.js.map +1 -0
  123. package/dist/prompts/node-guidance/parameter-guides/predecessor-output.d.ts +2 -0
  124. package/dist/prompts/node-guidance/parameter-guides/predecessor-output.js +25 -0
  125. package/dist/prompts/node-guidance/parameter-guides/predecessor-output.js.map +1 -0
  126. package/dist/prompts/node-guidance/parameter-guides/resource-locator.d.ts +2 -0
  127. package/dist/prompts/node-guidance/parameter-guides/resource-locator.js +40 -0
  128. package/dist/prompts/node-guidance/parameter-guides/resource-locator.js.map +1 -0
  129. package/dist/prompts/node-guidance/parameter-guides/set-node.d.ts +2 -0
  130. package/dist/prompts/node-guidance/parameter-guides/set-node.js +94 -0
  131. package/dist/prompts/node-guidance/parameter-guides/set-node.js.map +1 -0
  132. package/dist/prompts/node-guidance/parameter-guides/switch-node.d.ts +2 -0
  133. package/dist/prompts/node-guidance/parameter-guides/switch-node.js +75 -0
  134. package/dist/prompts/node-guidance/parameter-guides/switch-node.js.map +1 -0
  135. package/dist/prompts/node-guidance/parameter-guides/system-message.d.ts +2 -0
  136. package/dist/prompts/node-guidance/parameter-guides/system-message.js +96 -0
  137. package/dist/prompts/node-guidance/parameter-guides/system-message.js.map +1 -0
  138. package/dist/prompts/node-guidance/parameter-guides/text-fields.d.ts +2 -0
  139. package/dist/prompts/node-guidance/parameter-guides/text-fields.js +31 -0
  140. package/dist/prompts/node-guidance/parameter-guides/text-fields.js.map +1 -0
  141. package/dist/prompts/node-guidance/parameter-guides/tool-nodes.d.ts +2 -0
  142. package/dist/prompts/node-guidance/parameter-guides/tool-nodes.js +76 -0
  143. package/dist/prompts/node-guidance/parameter-guides/tool-nodes.js.map +1 -0
  144. package/dist/prompts/node-guidance/parameter-guides/types.d.ts +18 -0
  145. package/dist/prompts/node-guidance/parameter-guides/types.js +3 -0
  146. package/dist/prompts/node-guidance/parameter-guides/types.js.map +1 -0
  147. package/dist/prompts/node-selection/ai-nodes.d.ts +2 -0
  148. package/dist/prompts/node-selection/ai-nodes.js +35 -0
  149. package/dist/prompts/node-selection/ai-nodes.js.map +1 -0
  150. package/dist/prompts/node-selection/connection-parameters.d.ts +1 -0
  151. package/dist/prompts/node-selection/connection-parameters.js +13 -0
  152. package/dist/prompts/node-selection/connection-parameters.js.map +1 -0
  153. package/dist/prompts/node-selection/index.d.ts +5 -0
  154. package/dist/prompts/node-selection/index.js +16 -0
  155. package/dist/prompts/node-selection/index.js.map +1 -0
  156. package/dist/prompts/node-selection/native-preference.d.ts +1 -0
  157. package/dist/prompts/node-selection/native-preference.js +18 -0
  158. package/dist/prompts/node-selection/native-preference.js.map +1 -0
  159. package/dist/prompts/node-selection/trigger-selection.d.ts +1 -0
  160. package/dist/prompts/node-selection/trigger-selection.js +23 -0
  161. package/dist/prompts/node-selection/trigger-selection.js.map +1 -0
  162. package/dist/prompts/node-selection/use-case-patterns.d.ts +2 -0
  163. package/dist/prompts/node-selection/use-case-patterns.js +58 -0
  164. package/dist/prompts/node-selection/use-case-patterns.js.map +1 -0
  165. package/dist/prompts/sdk-reference/additional-functions.d.ts +1 -0
  166. package/dist/prompts/sdk-reference/additional-functions.js +20 -0
  167. package/dist/prompts/sdk-reference/additional-functions.js.map +1 -0
  168. package/dist/prompts/sdk-reference/expressions.d.ts +1 -0
  169. package/dist/prompts/sdk-reference/expressions.js +34 -0
  170. package/dist/prompts/sdk-reference/expressions.js.map +1 -0
  171. package/dist/prompts/sdk-reference/index.d.ts +5 -0
  172. package/dist/prompts/sdk-reference/index.js +14 -0
  173. package/dist/prompts/sdk-reference/index.js.map +1 -0
  174. package/dist/prompts/sdk-reference/workflow-patterns-detailed.d.ts +1 -0
  175. package/dist/prompts/sdk-reference/workflow-patterns-detailed.js +398 -0
  176. package/dist/prompts/sdk-reference/workflow-patterns-detailed.js.map +1 -0
  177. package/dist/prompts/sdk-reference/workflow-patterns.d.ts +2 -0
  178. package/dist/prompts/sdk-reference/workflow-patterns.js +479 -0
  179. package/dist/prompts/sdk-reference/workflow-patterns.js.map +1 -0
  180. package/dist/prompts/sdk-reference/workflow-rules.d.ts +1 -0
  181. package/dist/prompts/sdk-reference/workflow-rules.js +23 -0
  182. package/dist/prompts/sdk-reference/workflow-rules.js.map +1 -0
  183. package/dist/types/base.d.ts +8 -2
  184. package/dist/types/base.js.map +1 -1
  185. package/dist/workflow-builder/constants.d.ts +13 -0
  186. package/dist/workflow-builder/constants.js +17 -1
  187. package/dist/workflow-builder/constants.js.map +1 -1
  188. package/dist/workflow-builder/layout-utils.d.ts +7 -1
  189. package/dist/workflow-builder/layout-utils.js +452 -0
  190. package/dist/workflow-builder/layout-utils.js.map +1 -1
  191. package/dist/workflow-builder/node-builders/node-builder.d.ts +1 -1
  192. package/dist/workflow-builder/node-builders/node-builder.js +7 -3
  193. package/dist/workflow-builder/node-builders/node-builder.js.map +1 -1
  194. package/dist/workflow-builder/plugins/defaults.js +1 -0
  195. package/dist/workflow-builder/plugins/defaults.js.map +1 -1
  196. package/dist/workflow-builder/plugins/serializers/json-serializer.js +12 -1
  197. package/dist/workflow-builder/plugins/serializers/json-serializer.js.map +1 -1
  198. package/dist/workflow-builder/plugins/types.d.ts +1 -0
  199. package/dist/workflow-builder/plugins/validators/expression-prefix-validator.js +3 -0
  200. package/dist/workflow-builder/plugins/validators/expression-prefix-validator.js.map +1 -1
  201. package/dist/workflow-builder/plugins/validators/filter-node-validator.d.ts +2 -0
  202. package/dist/workflow-builder/plugins/validators/filter-node-validator.js +90 -0
  203. package/dist/workflow-builder/plugins/validators/filter-node-validator.js.map +1 -0
  204. package/dist/workflow-builder/plugins/validators/index.d.ts +1 -0
  205. package/dist/workflow-builder/plugins/validators/index.js +3 -1
  206. package/dist/workflow-builder/plugins/validators/index.js.map +1 -1
  207. package/dist/workflow-builder/workflow-import.js +1 -0
  208. package/dist/workflow-builder/workflow-import.js.map +1 -1
  209. package/dist/workflow-builder.js +2 -1
  210. package/dist/workflow-builder.js.map +1 -1
  211. package/package.json +52 -5
@@ -0,0 +1,369 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataAnalysisBestPractices = void 0;
4
+ const types_1 = require("../types");
5
+ class DataAnalysisBestPractices {
6
+ constructor() {
7
+ this.technique = types_1.WorkflowTechnique.DATA_ANALYSIS;
8
+ this.version = '1.0.0';
9
+ this.documentation = `# Best Practices: Data Analysis Workflows
10
+
11
+ ## Workflow Design
12
+
13
+ Structure workflows following the Input → Transform → Output pattern. Use clear node naming (e.g., "Fetch Sales Data", "Calculate Averages", "IF High Variance?") to document the flow.
14
+
15
+ Start with appropriate triggers:
16
+ - Manual Trigger for on-demand analysis
17
+ - Cron/Schedule Trigger for periodic analysis (daily/weekly reports)
18
+ - Webhook Trigger for event-driven analysis
19
+
20
+ Break complex workflows into modular sub-workflows using the Execute Workflow node for reusable components like "Outlier Detection" or "Data Preparation".
21
+
22
+ CRITICAL: For large datasets, use Split In Batches node to process items in chunks (e.g., 100 at a time) to prevent memory issues. Always test with realistic data volumes.
23
+
24
+ Example pattern:
25
+ - Trigger → HTTP Request (fetch data) → Spreadsheet File (parse CSV) → Set (clean fields) → Filter (remove nulls) → Code (analyze) → HTML (format report) → Email (send results)
26
+
27
+ ## Data Preparation Strategy
28
+
29
+ 1. **Fetch Data**: Use dedicated integration nodes or HTTP Request for APIs. Import cURL commands directly to HTTP node for complex APIs.
30
+ 2. **Parse & Convert**: Convert to JSON using Spreadsheet File node for CSV/Excel. Enable "Convert types where required" on condition nodes.
31
+ 3. **Clean Data**: Use Set node with "Keep Only Set" enabled to drop unused fields. Filter node for removing null values or focusing on data subsets.
32
+ 4. **Merge/Enrich**: Use Merge node by key or index to combine multiple sources. Choose correct merge mode to avoid mismatched items.
33
+
34
+ ## Analysis Implementation
35
+
36
+ Use Function node (not Function Item) when analysis needs all items as a whole (calculating totals, finding trends). Function Item operates per item only.
37
+
38
+ For AI-powered analysis, filter irrelevant content first to minimize tokens. Batch data into single prompts when possible.
39
+
40
+ Always pin data after external calls to test downstream logic without re-fetching. This saves API costs and speeds development.
41
+
42
+ ## Output & Integration
43
+
44
+ Format results appropriately:
45
+ - HTML/Markdown nodes for reports
46
+ - Set node to prepare specific output fields (totalSales, anomalyCount)
47
+ - Database nodes to store analysis history
48
+ - Webhook Response for API-triggered workflows
49
+
50
+ Use conditional branches (IF nodes) for post-analysis actions:
51
+ - Create tasks if anomalies detected
52
+ - Send alerts for critical thresholds
53
+ - Avoid infinite loops by using proper conditions
54
+
55
+ ## Recommended Nodes
56
+
57
+ ### HTTP Request (n8n-nodes-base.httpRequest)
58
+
59
+ **Purpose**: Fetch datasets from URLs or APIs
60
+
61
+ **Use Cases**:
62
+ - Pull data from REST APIs for analysis
63
+ - Fetch CSV/JSON files from URLs
64
+ - Query external data sources
65
+
66
+ **Best Practices**:
67
+ - Import cURL commands for complex requests
68
+ - Use authentication credentials properly
69
+ - Handle pagination for large datasets
70
+
71
+ ### Spreadsheet File (n8n-nodes-base.spreadsheetFile)
72
+
73
+ **Purpose**: Parse CSV/Excel files into JSON items for processing
74
+
75
+ **Use Cases**:
76
+ - Import CSV data from file uploads
77
+ - Process Excel spreadsheets
78
+ - Convert tabular data to JSON
79
+
80
+ **Best Practices**:
81
+ - Specify correct file format
82
+ - Handle header rows properly
83
+ - Test with various file encodings
84
+
85
+ ### Set / Edit Fields (n8n-nodes-base.set)
86
+
87
+ **Purpose**: Clean data, select relevant fields, rename columns, convert data types
88
+
89
+ **Key Setting**: "Keep Only Set" - drops all fields not explicitly defined
90
+
91
+ **Use Cases**:
92
+ - Remove unused columns to reduce data size
93
+ - Rename fields to standardized names
94
+ - Convert data types (string to number)
95
+ - Add calculated fields
96
+
97
+ **Best Practices**:
98
+ - Enable "Keep Only Set" to drop unused data
99
+ - Always verify output structure
100
+ - Use expressions for calculated fields
101
+
102
+ ### Filter (n8n-nodes-base.filter)
103
+
104
+ **Purpose**: Remove unwanted items based on conditions
105
+
106
+ **Use Cases**:
107
+ - Remove null values
108
+ - Filter outliers before analysis
109
+ - Focus on specific data subsets
110
+
111
+ **Best Practices**:
112
+ - Filter early to reduce processing load
113
+ - Use multiple conditions when needed
114
+ - Document filter logic clearly
115
+
116
+ ### IF (n8n-nodes-base.if)
117
+
118
+ **Purpose**: Branch workflow based on analysis results
119
+
120
+ **Use Cases**:
121
+ - Route anomalies vs normal data
122
+ - Trigger alerts for threshold breaches
123
+ - Create conditional outputs
124
+
125
+ **Best Practices**:
126
+ - Enable "Convert types where required" for comparisons
127
+ - Use clear condition names
128
+ - Handle both true and false branches
129
+
130
+ ### Code / Function (n8n-nodes-base.function)
131
+
132
+ **Purpose**: Custom JavaScript for calculations, statistics, anomaly detection
133
+
134
+ **Use Cases**:
135
+ - Calculate statistical measures (mean, median, std dev)
136
+ - Detect outliers and anomalies
137
+ - Perform complex transformations
138
+ - Implement custom algorithms
139
+
140
+ **Best Practices**:
141
+ - Use Function node (not Function Item) for whole-dataset operations
142
+ - Return proper data structure: \`return items\`
143
+ - Add comments to explain logic
144
+ - Test with edge cases
145
+
146
+ **Note**: Consider using the newer Code node (n8n-nodes-base.code) as Function node is deprecated.
147
+
148
+ ### Aggregate (n8n-nodes-base.aggregate)
149
+
150
+ **Purpose**: Group items, gather values into arrays, count occurrences by category
151
+
152
+ **Use Cases**:
153
+ - Group sales by region
154
+ - Count items by category
155
+ - Calculate sums and averages per group
156
+
157
+ **Best Practices**:
158
+ - Choose appropriate aggregation function
159
+ - Use grouping keys effectively
160
+ - Simplifies statistical calculations
161
+
162
+ ### Split In Batches (n8n-nodes-base.splitInBatches)
163
+
164
+ **Purpose**: Process large datasets in chunks to prevent memory overload
165
+
166
+ **Use Cases**:
167
+ - Handle datasets with 1000+ items
168
+ - Process API results in batches
169
+ - Prevent workflow timeouts
170
+
171
+ **Best Practices**:
172
+ - Set appropriate batch size (e.g., 100 items)
173
+ - Test with realistic data volumes
174
+ - Use loop logic properly
175
+
176
+ ### Merge (n8n-nodes-base.merge)
177
+
178
+ **Purpose**: Combine data from multiple sources by key/index
179
+
180
+ **Modes**:
181
+ - Merge by Key: Join data like database operations
182
+ - Merge by Index: Combine parallel data streams
183
+ - Wait mode: Synchronize parallel branches
184
+
185
+ **Use Cases**:
186
+ - Join customer data with transaction data
187
+ - Combine multiple API responses
188
+ - Enrich data from multiple sources
189
+
190
+ **Best Practices**:
191
+ - Choose correct merge mode
192
+ - Ensure matching keys exist
193
+ - Handle missing data gracefully
194
+
195
+ ### Database Nodes
196
+
197
+ **MySQL** (n8n-nodes-base.mySql):
198
+ - Purpose: Query MySQL databases for analysis data
199
+ - Use cases: Fetch historical data, store results
200
+
201
+ **Postgres** (n8n-nodes-base.postgres):
202
+ - Purpose: Query PostgreSQL databases
203
+ - Use cases: Complex analytical queries, time-series data
204
+
205
+ **MongoDB** (n8n-nodes-base.mongoDb):
206
+ - Purpose: Query NoSQL document databases
207
+ - Use cases: Unstructured data analysis, JSON documents
208
+
209
+ **Best Practices**:
210
+ - Use parameterized queries for security
211
+ - Query source data efficiently with proper indexes
212
+ - Store analysis results for historical tracking
213
+ - Use appropriate data types
214
+
215
+ ### Google Sheets (n8n-nodes-base.googleSheets)
216
+
217
+ **Purpose**: Read/write spreadsheet data
218
+
219
+ **Use Cases**:
220
+ - Import data for analysis
221
+ - Append summary statistics
222
+ - Build analysis logs
223
+ - Share results with stakeholders
224
+
225
+ **Best Practices**:
226
+ - Use range specifications efficiently
227
+ - Handle large sheets with batching
228
+ - Consider API rate limits
229
+
230
+ ### AI Agent (@n8n/n8n-nodes-langchain.agent)
231
+
232
+ **Purpose**: Leverage AI for text analysis, sentiment detection, complex pattern recognition
233
+
234
+ **Use Cases**:
235
+ - Sentiment analysis of customer feedback
236
+ - Text classification
237
+ - Extract insights from unstructured data
238
+ - Natural language processing
239
+
240
+ **Best Practices**:
241
+ - Filter irrelevant content first to minimize tokens
242
+ - Batch data into single prompts when possible
243
+ - Use structured output for consistency
244
+ - Consider API costs and latency
245
+
246
+ ### HTML (n8n-nodes-base.html)
247
+
248
+ **Purpose**: Generate formatted reports with tables and styling
249
+
250
+ **Use Cases**:
251
+ - Create analysis reports
252
+ - Build dashboards
253
+ - Color-code data quality scores
254
+ - Format tables with results
255
+
256
+ **Best Practices**:
257
+ - Use templates for consistent formatting
258
+ - Include visualizations where helpful
259
+ - Make reports mobile-friendly
260
+
261
+ ### Email (n8n-nodes-base.emailSend)
262
+
263
+ **Purpose**: Send analysis reports to stakeholders automatically
264
+
265
+ **Use Cases**:
266
+ - Scheduled report delivery
267
+ - Alert notifications
268
+ - Share findings with teams
269
+
270
+ **Best Practices**:
271
+ - Use clear subject lines
272
+ - Include summary in email body
273
+ - Attach detailed reports when needed
274
+ - Schedule appropriately
275
+
276
+ ## Common Pitfalls to Avoid
277
+
278
+ ### Data Type Mismatches
279
+
280
+ **Problem**: JSON data types matter. Comparing string vs number yields incorrect results. The comparison "5" > "10" is lexicographically true (wrong for numbers).
281
+
282
+ **Solution**:
283
+ - Always convert data types before comparisons
284
+ - Use Number() or parseInt() for numeric operations
285
+ - Enable "Convert types where required" on IF nodes
286
+ - Validate data types early in workflow
287
+ - Use proper type casting in Code nodes
288
+
289
+ ### Memory Issues with Large Datasets
290
+
291
+ **Problem**: Processing thousands of items at once can crash workflows or timeout.
292
+
293
+ **Solution**:
294
+ - Use Split In Batches node for datasets over 100 items
295
+ - Set appropriate batch sizes (50-100 items)
296
+ - Test with realistic data volumes during development
297
+ - Monitor memory usage in production
298
+ - Consider sub-workflows for complex processing
299
+
300
+ ### Not Pinning Data During Development
301
+
302
+ **Problem**: Re-fetching data from APIs repeatedly wastes time and costs money during development.
303
+
304
+ **Solution**:
305
+ - Always pin data after external calls
306
+ - Test downstream logic without re-fetching
307
+ - Saves API costs and speeds development
308
+ - Use manual triggers to control execution
309
+
310
+ ### Incorrect Aggregation Logic
311
+
312
+ **Problem**: Using Function Item instead of Function node for whole-dataset calculations.
313
+
314
+ **Solution**:
315
+ - Use Function node (not Function Item) for totals, averages, trends
316
+ - Function Item operates per item only
317
+ - Understand the difference between item-level and dataset-level operations
318
+ - Use Aggregate node for common operations
319
+
320
+ ### Missing Data Cleaning
321
+
322
+ **Problem**: Null values, inconsistent formats, or outliers skew analysis results.
323
+
324
+ **Solution**:
325
+ - Use Filter node to remove null values
326
+ - Standardize data formats early
327
+ - Handle missing data explicitly
328
+ - Use Set node to clean and normalize fields
329
+ - Document data quality assumptions
330
+
331
+ ### Poor Error Handling
332
+
333
+ **Problem**: Failed API calls or data issues break the entire workflow.
334
+
335
+ **Solution**:
336
+ - Use "Continue on Fail" setting appropriately
337
+ - Add IF nodes to check for empty datasets
338
+ - Implement error logging
339
+ - Use Error Trigger workflows for global handling
340
+ - Validate data quality before analysis
341
+
342
+ ### Hardcoded Values
343
+
344
+ **Problem**: Thresholds, API endpoints, or configuration values are hardcoded in nodes.
345
+
346
+ **Solution**:
347
+ - Store configuration in environment variables
348
+ - Use Google Sheets or databases for thresholds
349
+ - Makes workflows reusable and maintainable
350
+ - Enable non-technical users to adjust parameters
351
+
352
+ ### Inefficient Query Patterns
353
+
354
+ **Problem**: Fetching entire datasets when only summary data is needed.
355
+
356
+ **Solution**:
357
+ - Use database aggregation functions
358
+ - Filter data at the source
359
+ - Use appropriate indexes
360
+ - Implement pagination for large results
361
+ - Consider pre-aggregated views
362
+ `;
363
+ }
364
+ getDocumentation() {
365
+ return this.documentation;
366
+ }
367
+ }
368
+ exports.DataAnalysisBestPractices = DataAnalysisBestPractices;
369
+ //# sourceMappingURL=data-analysis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-analysis.js","sourceRoot":"","sources":["../../../../src/prompts/best-practices/guides/data-analysis.ts"],"names":[],"mappings":";;;AACA,oCAA6C;AAE7C,MAAa,yBAAyB;IAAtC;QACU,cAAS,GAAG,yBAAiB,CAAC,aAAa,CAAC;QAC5C,YAAO,GAAG,OAAO,CAAC;QAEV,kBAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiWjC,CAAC;IAKF,CAAC;IAHA,gBAAgB;QACf,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;CACD;AA1WD,8DA0WC"}
@@ -0,0 +1,7 @@
1
+ import type { BestPracticesDocument } from '../types';
2
+ export declare class DataExtractionBestPractices implements BestPracticesDocument {
3
+ readonly technique: "data_extraction";
4
+ readonly version = "1.0.0";
5
+ private readonly documentation;
6
+ getDocumentation(): string;
7
+ }
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataExtractionBestPractices = void 0;
4
+ const types_1 = require("../types");
5
+ class DataExtractionBestPractices {
6
+ constructor() {
7
+ this.technique = types_1.WorkflowTechnique.DATA_EXTRACTION;
8
+ this.version = '1.0.0';
9
+ this.documentation = `# Best Practices: Data Extraction Workflows
10
+
11
+ ## Node Selection by Data Type
12
+
13
+ Choose the right node for your data source. Use Extract From File for CSV, Excel, PDF, and text files to convert binary data to JSON for further processing.
14
+
15
+ Use Information Extractor or AI nodes for extracting structured data from unstructured text such as PDFs or emails using LLMs.
16
+
17
+ For binary data, ensure you use nodes like Extract From File to handle files properly.
18
+
19
+ ### Referencing Binary Data from Other Nodes
20
+ When you need to reference binary data from a previous node, use this syntax:
21
+ - Expression: '{{ $('Node Name').item.binary.property_name }}' or {{ $binary.property_name }} if previous item
22
+ - Example for Gmail attachments: '{{ $('Gmail Trigger').item.binary.attachment_0 }}' or {{ $binary.attachment_0 }} if previous item
23
+ - Example for webhook data: '{{ $('Webhook').item.binary.data }}' or {{ $binary.data }} if previous item
24
+ - Important: The property name depends on how the previous node names the binary data
25
+
26
+ ## Data Structure & Type Management
27
+
28
+ Normalize data structure early in your workflow. Use transformation nodes like Split Out, Aggregate, or Set to ensure your data matches n8n's expected structure: an array of objects with a json key.
29
+ Not transforming incoming data to n8n's expected format causes downstream node failures.
30
+
31
+ When working with large amounts of information, n8n's display can be hard to view. Use the Edit Fields node to help organize and view data more clearly during development and debugging.
32
+
33
+ ## Large File Handling
34
+
35
+ Process files in batches or use sub-workflows to avoid memory issues. For large binary files, consider enabling filesystem mode (N8N_DEFAULT_BINARY_DATA_MODE=filesystem) if self-hosted, to store binary data on disk instead of memory.
36
+
37
+ Processing too many items or large files at once can crash your instance. Always batch or split processing for large datasets to manage memory effectively.
38
+
39
+ ## Binary Data Management
40
+
41
+ Binary data can be lost if intermediate nodes (like Set or Code) do not have "Include Other Input Fields" enabled, especially in sub-workflows. Always verify binary data is preserved through your workflow pipeline.
42
+
43
+ ## AI-Powered Extraction
44
+
45
+ Leverage AI for unstructured data using nodes like Information Extractor or Summarization Chain to extract structured data from unstructured sources such as PDFs, emails, or web pages.
46
+
47
+ ## Recommended Nodes
48
+
49
+ ### Loop Over Items (n8n-nodes-base.splitInBatches)
50
+
51
+ Purpose: Looping over a set of items extracted from a data set, for example if pulling a lot of data
52
+ from a Google Sheet or database then looping over the items is required. This node MUST be used
53
+ if the user mentions a large amount of data, it is necessary to batch the data to process all of it.
54
+
55
+ ### Extract From File (n8n-nodes-base.extractFromFile)
56
+
57
+ Purpose: Converts binary data from CSV, Excel, PDF, and text files to JSON for processing
58
+
59
+ Pitfalls:
60
+
61
+ - Ensure the correct binary field name is specified in the node configuration
62
+ - Verify file format compatibility before extraction
63
+
64
+ ### HTML Extract (n8n-nodes-base.htmlExtract)
65
+
66
+ Purpose: Scrapes data from web pages using CSS selectors
67
+
68
+ ### Split Out (n8n-nodes-base.splitOut)
69
+
70
+ Purpose: Processes arrays of items individually for sequential operations.
71
+ Example: If retrieving a JSON array using a HTTP request, this will return a single item,
72
+ containing that array. If you wish to use a Loop Over Items (n8n-nodes-base.splitInBatches) node]
73
+ then you will need to split out the array into items before looping over it. In a scenario like
74
+ this a split out node MUST be used before looping over the items.
75
+
76
+ ### Edit Fields (Set) (n8n-nodes-base.set)
77
+
78
+ Purpose: Data transformation and mapping to normalize structure
79
+
80
+ Pitfalls:
81
+
82
+ - Enable "Include Other Input Fields" to preserve binary data
83
+ - Pay attention to data types - mixing types causes unexpected failures
84
+
85
+ ### Information Extractor (@n8n/n8n-nodes-langchain.informationExtractor)
86
+
87
+ Purpose: AI-powered extraction of structured data from unstructured text
88
+
89
+ Pitfalls:
90
+
91
+ - Requires proper schema definition for extraction
92
+
93
+ ### Summarization Chain (@n8n/n8n-nodes-langchain.chainSummarization)
94
+
95
+ Purpose: Summarizes large text blocks using AI for condensed information extraction
96
+
97
+ Pitfalls:
98
+
99
+ - Context window limits may truncate very long documents
100
+ - Verify summary quality matches requirements
101
+
102
+ ### HTTP Request (n8n-nodes-base.httpRequest)
103
+
104
+ Purpose: Fetches data from APIs or web pages for extraction
105
+
106
+ ### Code (n8n-nodes-base.code)
107
+
108
+ Purpose: Custom logic for complex data transformations
109
+
110
+ ## Common Pitfalls to Avoid
111
+
112
+ Data Type Confusion: People often mix up data types - n8n can be very lenient but it can lead to problems. Pay close attention to what type you are getting and ensure consistency throughout the workflow.
113
+
114
+ Binary Data Loss: Binary data can be lost if intermediate nodes (Set, Code) do not have "Include Other Input Fields" enabled, especially in sub-workflows. Always verify binary data preservation.
115
+
116
+ Large Data Display Issues: n8n displaying large amounts of information can be hard to view during development. Use the Edit Fields node to help organize and view data more clearly.
117
+ `;
118
+ }
119
+ getDocumentation() {
120
+ return this.documentation;
121
+ }
122
+ }
123
+ exports.DataExtractionBestPractices = DataExtractionBestPractices;
124
+ //# sourceMappingURL=data-extraction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-extraction.js","sourceRoot":"","sources":["../../../../src/prompts/best-practices/guides/data-extraction.ts"],"names":[],"mappings":";;;AACA,oCAA6C;AAE7C,MAAa,2BAA2B;IAAxC;QACU,cAAS,GAAG,yBAAiB,CAAC,eAAe,CAAC;QAC9C,YAAO,GAAG,OAAO,CAAC;QAEV,kBAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4GjC,CAAC;IAKF,CAAC;IAHA,gBAAgB;QACf,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;CACD;AArHD,kEAqHC"}
@@ -0,0 +1,7 @@
1
+ import type { BestPracticesDocument } from '../types';
2
+ export declare class DataPersistenceBestPractices implements BestPracticesDocument {
3
+ readonly technique: "data_persistence";
4
+ readonly version = "1.0.0";
5
+ private readonly documentation;
6
+ getDocumentation(): string;
7
+ }