@n8n/ai-workflow-builder 0.27.1 → 0.29.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 (107) hide show
  1. package/dist/build.tsbuildinfo +1 -1
  2. package/dist/chains/prompt-categorization.d.ts +3 -0
  3. package/dist/chains/prompt-categorization.js +109 -0
  4. package/dist/chains/prompt-categorization.js.map +1 -0
  5. package/dist/chains/prompts/parameter-types/system-message.d.ts +1 -0
  6. package/dist/chains/prompts/parameter-types/system-message.js +75 -0
  7. package/dist/chains/prompts/parameter-types/system-message.js.map +1 -0
  8. package/dist/chains/prompts/prompt-builder.d.ts +1 -0
  9. package/dist/chains/prompts/prompt-builder.js +23 -1
  10. package/dist/chains/prompts/prompt-builder.js.map +1 -1
  11. package/dist/chains/test/integration/test-helpers.d.ts +3 -0
  12. package/dist/chains/test/integration/test-helpers.js +16 -0
  13. package/dist/chains/test/integration/test-helpers.js.map +1 -0
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.js +3 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/tools/best-practices/chatbot.d.ts +7 -0
  18. package/dist/tools/best-practices/chatbot.js +118 -0
  19. package/dist/tools/best-practices/chatbot.js.map +1 -0
  20. package/dist/tools/best-practices/content-generation.d.ts +7 -0
  21. package/dist/tools/best-practices/content-generation.js +79 -0
  22. package/dist/tools/best-practices/content-generation.js.map +1 -0
  23. package/dist/tools/best-practices/data-extraction.d.ts +7 -0
  24. package/dist/tools/best-practices/data-extraction.js +105 -0
  25. package/dist/tools/best-practices/data-extraction.js.map +1 -0
  26. package/dist/tools/best-practices/form-input.d.ts +7 -0
  27. package/dist/tools/best-practices/form-input.js +173 -0
  28. package/dist/tools/best-practices/form-input.js.map +1 -0
  29. package/dist/tools/best-practices/index.d.ts +3 -0
  30. package/dist/tools/best-practices/index.js +27 -0
  31. package/dist/tools/best-practices/index.js.map +1 -0
  32. package/dist/tools/best-practices/scraping-and-research.d.ts +7 -0
  33. package/dist/tools/best-practices/scraping-and-research.js +147 -0
  34. package/dist/tools/best-practices/scraping-and-research.js.map +1 -0
  35. package/dist/tools/builder-tools.js +9 -0
  36. package/dist/tools/builder-tools.js.map +1 -1
  37. package/dist/tools/categorize-prompt.tool.d.ts +5 -0
  38. package/dist/tools/categorize-prompt.tool.js +84 -0
  39. package/dist/tools/categorize-prompt.tool.js.map +1 -0
  40. package/dist/tools/engines/node-search-engine.d.ts +0 -9
  41. package/dist/tools/engines/node-search-engine.js +52 -72
  42. package/dist/tools/engines/node-search-engine.js.map +1 -1
  43. package/dist/tools/get-best-practices.tool.d.ts +33 -0
  44. package/dist/tools/get-best-practices.tool.js +94 -0
  45. package/dist/tools/get-best-practices.tool.js.map +1 -0
  46. package/dist/tools/prompts/main-agent.prompt.js +116 -5
  47. package/dist/tools/prompts/main-agent.prompt.js.map +1 -1
  48. package/dist/tools/validate-workflow.tool.d.ts +5 -0
  49. package/dist/tools/validate-workflow.tool.js +61 -0
  50. package/dist/tools/validate-workflow.tool.js.map +1 -0
  51. package/dist/types/best-practices.d.ts +6 -0
  52. package/dist/types/best-practices.js +3 -0
  53. package/dist/types/best-practices.js.map +1 -0
  54. package/dist/types/categorization.d.ts +23 -0
  55. package/dist/types/categorization.js +38 -0
  56. package/dist/types/categorization.js.map +1 -0
  57. package/dist/types/index.d.ts +2 -0
  58. package/dist/types/tools.d.ts +4 -0
  59. package/dist/utils/operations-processor.d.ts +2 -0
  60. package/dist/utils/operations-processor.js +1 -0
  61. package/dist/utils/operations-processor.js.map +1 -1
  62. package/dist/utils/stream-processor.d.ts +1 -0
  63. package/dist/utils/stream-processor.js +99 -59
  64. package/dist/utils/stream-processor.js.map +1 -1
  65. package/dist/utils/workflow-validation.d.ts +2 -0
  66. package/dist/utils/workflow-validation.js +36 -0
  67. package/dist/utils/workflow-validation.js.map +1 -0
  68. package/dist/validation/checks/agent-prompt.d.ts +3 -0
  69. package/dist/validation/checks/agent-prompt.js +45 -0
  70. package/dist/validation/checks/agent-prompt.js.map +1 -0
  71. package/dist/validation/checks/connections.d.ts +4 -0
  72. package/dist/validation/checks/connections.js +162 -0
  73. package/dist/validation/checks/connections.js.map +1 -0
  74. package/dist/validation/checks/from-ai.d.ts +4 -0
  75. package/dist/validation/checks/from-ai.js +59 -0
  76. package/dist/validation/checks/from-ai.js.map +1 -0
  77. package/dist/validation/checks/index.d.ts +5 -0
  78. package/dist/validation/checks/index.js +14 -0
  79. package/dist/validation/checks/index.js.map +1 -0
  80. package/dist/validation/checks/tools.d.ts +4 -0
  81. package/dist/validation/checks/tools.js +44 -0
  82. package/dist/validation/checks/tools.js.map +1 -0
  83. package/dist/validation/checks/trigger.d.ts +8 -0
  84. package/dist/validation/checks/trigger.js +35 -0
  85. package/dist/validation/checks/trigger.js.map +1 -0
  86. package/dist/validation/programmatic.d.ts +3 -0
  87. package/dist/validation/programmatic.js +20 -0
  88. package/dist/validation/programmatic.js.map +1 -0
  89. package/dist/validation/types.d.ts +41 -0
  90. package/dist/validation/types.js +3 -0
  91. package/dist/validation/types.js.map +1 -0
  92. package/dist/validation/utils/expressions.d.ts +3 -0
  93. package/dist/validation/utils/expressions.js +37 -0
  94. package/dist/validation/utils/expressions.js.map +1 -0
  95. package/dist/validation/utils/is-tool.d.ts +2 -0
  96. package/dist/validation/utils/is-tool.js +7 -0
  97. package/dist/validation/utils/is-tool.js.map +1 -0
  98. package/dist/validation/utils/resolve-connections.d.ts +8 -0
  99. package/dist/validation/utils/resolve-connections.js +64 -0
  100. package/dist/validation/utils/resolve-connections.js.map +1 -0
  101. package/dist/workflow-builder-agent.d.ts +2 -0
  102. package/dist/workflow-builder-agent.js +28 -25
  103. package/dist/workflow-builder-agent.js.map +1 -1
  104. package/dist/workflow-state.d.ts +3 -1
  105. package/dist/workflow-state.js +4 -0
  106. package/dist/workflow-state.js.map +1 -1
  107. package/package.json +12 -7
@@ -0,0 +1,3 @@
1
+ import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
2
+ import { type PromptCategorization } from '../types/categorization';
3
+ export declare function promptCategorizationChain(llm: BaseChatModel, userPrompt: string): Promise<PromptCategorization>;
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.promptCategorizationChain = promptCategorizationChain;
4
+ const prompts_1 = require("@langchain/core/prompts");
5
+ const zod_1 = require("zod");
6
+ const categorization_1 = require("../types/categorization");
7
+ const examplePrompts = [
8
+ {
9
+ prompt: 'Monitor social channels for product mentions and auto-respond with campaign messages',
10
+ techniques: [
11
+ categorization_1.WorkflowTechnique.MONITORING,
12
+ categorization_1.WorkflowTechnique.CHATBOT,
13
+ categorization_1.WorkflowTechnique.CONTENT_GENERATION,
14
+ ],
15
+ },
16
+ {
17
+ prompt: 'Collect partner referral submissions and verify client instances via BigQuery',
18
+ techniques: [
19
+ categorization_1.WorkflowTechnique.FORM_INPUT,
20
+ categorization_1.WorkflowTechnique.HUMAN_IN_THE_LOOP,
21
+ categorization_1.WorkflowTechnique.NOTIFICATION,
22
+ ],
23
+ },
24
+ {
25
+ prompt: 'Scrape competitor pricing pages weekly and generate a summary report of changes',
26
+ techniques: [
27
+ categorization_1.WorkflowTechnique.SCHEDULING,
28
+ categorization_1.WorkflowTechnique.SCRAPING_AND_RESEARCH,
29
+ categorization_1.WorkflowTechnique.DATA_EXTRACTION,
30
+ categorization_1.WorkflowTechnique.DATA_ANALYSIS,
31
+ ],
32
+ },
33
+ {
34
+ prompt: 'Process uploaded PDF contracts to extract client details and update CRM records',
35
+ techniques: [
36
+ categorization_1.WorkflowTechnique.DOCUMENT_PROCESSING,
37
+ categorization_1.WorkflowTechnique.DATA_EXTRACTION,
38
+ categorization_1.WorkflowTechnique.DATA_TRANSFORMATION,
39
+ categorization_1.WorkflowTechnique.ENRICHMENT,
40
+ ],
41
+ },
42
+ {
43
+ prompt: 'Build a searchable internal knowledge base from past support tickets',
44
+ techniques: [
45
+ categorization_1.WorkflowTechnique.DATA_TRANSFORMATION,
46
+ categorization_1.WorkflowTechnique.DATA_ANALYSIS,
47
+ categorization_1.WorkflowTechnique.KNOWLEDGE_BASE,
48
+ ],
49
+ },
50
+ ];
51
+ function formatExamplePrompts() {
52
+ return examplePrompts
53
+ .map((example) => `- ${example.prompt} → ${example.techniques.join(',')}`)
54
+ .join('\n');
55
+ }
56
+ const promptCategorizationTemplate = prompts_1.PromptTemplate.fromTemplate(`Analyze the following user prompt and identify the workflow techniques required to fulfill the request.
57
+ Be specific and identify all relevant techniques.
58
+
59
+ <user_prompt>
60
+ {userPrompt}
61
+ </user_prompt>
62
+
63
+ <workflow_techniques>
64
+ {techniques}
65
+ </workflow_techniques>
66
+
67
+ The following prompt categorization examples show a prompt → techniques involved to provide a sense
68
+ of how the categorization should be carried out.
69
+ <example_categorization>
70
+ ${formatExamplePrompts()}
71
+ </example_categorization>
72
+
73
+ Select a maximum of 5 techniques that you believe are applicable, but only select them if you are
74
+ confident that they are applicable. If the prompt is ambigious or does not provide an obvious workflow
75
+ do not provide any techniques - if confidence is low avoid providing techniques.
76
+
77
+ Select ALL techniques that apply to this workflow. Most workflows use multiple techniques.
78
+ Rate your confidence in this categorization from 0.0 to 1.0.
79
+ `);
80
+ function formatTechniqueList() {
81
+ return Object.entries(categorization_1.TechniqueDescription)
82
+ .map(([key, description]) => `- **${key}**: ${description}`)
83
+ .join('\n');
84
+ }
85
+ async function promptCategorizationChain(llm, userPrompt) {
86
+ const categorizationSchema = zod_1.z.object({
87
+ techniques: zod_1.z
88
+ .array(zod_1.z.nativeEnum(categorization_1.WorkflowTechnique))
89
+ .min(0)
90
+ .max(5)
91
+ .describe('Zero to five workflow techniques identified in the prompt (maximum of 5)'),
92
+ confidence: zod_1.z
93
+ .number()
94
+ .min(0)
95
+ .max(1)
96
+ .describe('Confidence level in this categorization from 0.0 to 1.0'),
97
+ });
98
+ const modelWithStructure = llm.withStructuredOutput(categorizationSchema);
99
+ const prompt = await promptCategorizationTemplate.invoke({
100
+ userPrompt,
101
+ techniques: formatTechniqueList(),
102
+ });
103
+ const structuredOutput = await modelWithStructure.invoke(prompt);
104
+ return {
105
+ techniques: structuredOutput.techniques,
106
+ confidence: structuredOutput.confidence,
107
+ };
108
+ }
109
+ //# sourceMappingURL=prompt-categorization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-categorization.js","sourceRoot":"","sources":["../../src/chains/prompt-categorization.ts"],"names":[],"mappings":";;AA8FA,8DA8BC;AA3HD,qDAAyD;AACzD,6BAAwB;AAExB,2DAIgC;AAEhC,MAAM,cAAc,GAAG;IACtB;QACC,MAAM,EAAE,sFAAsF;QAC9F,UAAU,EAAE;YACX,kCAAiB,CAAC,UAAU;YAC5B,kCAAiB,CAAC,OAAO;YACzB,kCAAiB,CAAC,kBAAkB;SACpC;KACD;IACD;QACC,MAAM,EAAE,+EAA+E;QACvF,UAAU,EAAE;YACX,kCAAiB,CAAC,UAAU;YAC5B,kCAAiB,CAAC,iBAAiB;YACnC,kCAAiB,CAAC,YAAY;SAC9B;KACD;IACD;QACC,MAAM,EAAE,iFAAiF;QACzF,UAAU,EAAE;YACX,kCAAiB,CAAC,UAAU;YAC5B,kCAAiB,CAAC,qBAAqB;YACvC,kCAAiB,CAAC,eAAe;YACjC,kCAAiB,CAAC,aAAa;SAC/B;KACD;IACD;QACC,MAAM,EAAE,iFAAiF;QACzF,UAAU,EAAE;YACX,kCAAiB,CAAC,mBAAmB;YACrC,kCAAiB,CAAC,eAAe;YACjC,kCAAiB,CAAC,mBAAmB;YACrC,kCAAiB,CAAC,UAAU;SAC5B;KACD;IACD;QACC,MAAM,EAAE,sEAAsE;QAC9E,UAAU,EAAE;YACX,kCAAiB,CAAC,mBAAmB;YACrC,kCAAiB,CAAC,aAAa;YAC/B,kCAAiB,CAAC,cAAc;SAChC;KACD;CACD,CAAC;AAEF,SAAS,oBAAoB;IAC5B,OAAO,cAAc;SACnB,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,OAAO,CAAC,MAAM,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B,CAAC,UAAU;KACvC,CAAC;AACH,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const SYSTEM_MESSAGE_GUIDE = "\n## CRITICAL: System Message vs User Prompt Separation\n\nAI nodes (AI Agent, LLM Chain, Anthropic, OpenAI, etc.) have TWO distinct prompt fields that MUST be used correctly:\n\n### Field Separation\n1. **System Message** - Model's persistent identity, role, and instructions\n2. **User Message/Text** - Dynamic user context and data references per execution\n\n**Node-specific field names:**\n- AI Agent: `options.systemMessage` and `text`\n- LLM Chain: `messages.messageValues[]` with system role and `text`\n- Anthropic: `options.system` and `messages.values[]`\n- OpenAI: `messages.values[]` with role \"system\" vs \"user\"\n\n### System Message\nUse for STATIC, ROLE-DEFINING content:\n- Agent identity: \"You are a [role] agent...\"\n- Task description: \"Your task is to...\"\n- Step-by-step instructions: \"1. Do X, 2. Do Y, 3. Do Z\"\n- Behavioral guidelines: \"Always...\", \"Never...\"\n- Tool coordination: \"Call the Research Tool to..., then call...\"\n\n### Text Parameter\nUse for DYNAMIC, EXECUTION-SPECIFIC content:\n- User input: \"={{ $json.chatInput }}\"\n- Workflow context: \"=The research topic is: {{ $json.topic }}\"\n- Data from previous nodes: \"=Process this data: {{ $json.data }}\"\n- Variable context: \"=Analyze for user: {{ $json.userId }}\"\n\n### Common Mistakes to Avoid\n\n\u274C **WRONG - Everything in text field:**\n{\n \"text\": \"=You are an orchestrator agent that coordinates specialized agents. Your task is to: 1) Call Research Agent Tool, 2) Call Fact-Check Agent Tool, 3) Generate report. Research topic: {{ $json.researchTopic }}\"\n}\n\n\u2705 **CORRECT - Properly separated:**\n{\n \"text\": \"=The research topic is: {{ $json.researchTopic }}\",\n \"options\": {\n \"systemMessage\": \"You are an orchestrator agent that coordinates specialized agents.\\n\\nYour task is to:\\n1. Call the Research Agent Tool to gather information\\n2. Call the Fact-Check Agent Tool to verify findings\\n3. Generate a comprehensive report\\n\\nReturn ONLY the final report.\"\n }\n}\n\n### Update Pattern Examples\n\nExample 1 - AI Agent with orchestration:\nInstructions: [\n \"Set text to '=Research topic: {{ $json.researchTopic }}'\",\n \"Set system message to 'You are an orchestrator coordinating research tasks.\\n\\nSteps:\\n1. Call Research Agent Tool\\n2. Call Fact-Check Agent Tool\\n3. Call Report Writer Agent Tool\\n4. Return final HTML report'\"\n]\n\nExample 2 - Chat-based AI node:\nInstructions: [\n \"Set text to '=User question: {{ $json.chatInput }}'\",\n \"Set system message to 'You are a helpful customer support assistant. Answer questions clearly and professionally. Escalate to human if needed.'\"\n]\n\nExample 3 - Data processing with AI:\nInstructions: [\n \"Set text to '=Process this data: {{ $json.inputData }}'\",\n \"Set system message to 'You are a data analysis assistant.\\n\\nTasks:\\n1. Validate data structure\\n2. Calculate statistics\\n3. Identify anomalies\\n4. Return JSON with findings'\"\n]\n\n### Why This Matters\n- **Consistency**: System message stays the same across executions\n- **Maintainability**: Easy to update AI behavior without touching data flow\n- **Best Practice**: Follows standard AI prompt engineering patterns\n- **Clarity**: Separates \"what the AI model is\" from \"what data to process\"\n";
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SYSTEM_MESSAGE_GUIDE = void 0;
4
+ exports.SYSTEM_MESSAGE_GUIDE = `
5
+ ## CRITICAL: System Message vs User Prompt Separation
6
+
7
+ AI nodes (AI Agent, LLM Chain, Anthropic, OpenAI, etc.) have TWO distinct prompt fields that MUST be used correctly:
8
+
9
+ ### Field Separation
10
+ 1. **System Message** - Model's persistent identity, role, and instructions
11
+ 2. **User Message/Text** - Dynamic user context and data references per execution
12
+
13
+ **Node-specific field names:**
14
+ - AI Agent: \`options.systemMessage\` and \`text\`
15
+ - LLM Chain: \`messages.messageValues[]\` with system role and \`text\`
16
+ - Anthropic: \`options.system\` and \`messages.values[]\`
17
+ - OpenAI: \`messages.values[]\` with role "system" vs "user"
18
+
19
+ ### System Message
20
+ Use for STATIC, ROLE-DEFINING content:
21
+ - Agent identity: "You are a [role] agent..."
22
+ - Task description: "Your task is to..."
23
+ - Step-by-step instructions: "1. Do X, 2. Do Y, 3. Do Z"
24
+ - Behavioral guidelines: "Always...", "Never..."
25
+ - Tool coordination: "Call the Research Tool to..., then call..."
26
+
27
+ ### Text Parameter
28
+ Use for DYNAMIC, EXECUTION-SPECIFIC content:
29
+ - User input: "={{ $json.chatInput }}"
30
+ - Workflow context: "=The research topic is: {{ $json.topic }}"
31
+ - Data from previous nodes: "=Process this data: {{ $json.data }}"
32
+ - Variable context: "=Analyze for user: {{ $json.userId }}"
33
+
34
+ ### Common Mistakes to Avoid
35
+
36
+ ❌ **WRONG - Everything in text field:**
37
+ {
38
+ "text": "=You are an orchestrator agent that coordinates specialized agents. Your task is to: 1) Call Research Agent Tool, 2) Call Fact-Check Agent Tool, 3) Generate report. Research topic: {{ $json.researchTopic }}"
39
+ }
40
+
41
+ ✅ **CORRECT - Properly separated:**
42
+ {
43
+ "text": "=The research topic is: {{ $json.researchTopic }}",
44
+ "options": {
45
+ "systemMessage": "You are an orchestrator agent that coordinates specialized agents.\\n\\nYour task is to:\\n1. Call the Research Agent Tool to gather information\\n2. Call the Fact-Check Agent Tool to verify findings\\n3. Generate a comprehensive report\\n\\nReturn ONLY the final report."
46
+ }
47
+ }
48
+
49
+ ### Update Pattern Examples
50
+
51
+ Example 1 - AI Agent with orchestration:
52
+ Instructions: [
53
+ "Set text to '=Research topic: {{ $json.researchTopic }}'",
54
+ "Set system message to 'You are an orchestrator coordinating research tasks.\\n\\nSteps:\\n1. Call Research Agent Tool\\n2. Call Fact-Check Agent Tool\\n3. Call Report Writer Agent Tool\\n4. Return final HTML report'"
55
+ ]
56
+
57
+ Example 2 - Chat-based AI node:
58
+ Instructions: [
59
+ "Set text to '=User question: {{ $json.chatInput }}'",
60
+ "Set system message to 'You are a helpful customer support assistant. Answer questions clearly and professionally. Escalate to human if needed.'"
61
+ ]
62
+
63
+ Example 3 - Data processing with AI:
64
+ Instructions: [
65
+ "Set text to '=Process this data: {{ $json.inputData }}'",
66
+ "Set system message to 'You are a data analysis assistant.\\n\\nTasks:\\n1. Validate data structure\\n2. Calculate statistics\\n3. Identify anomalies\\n4. Return JSON with findings'"
67
+ ]
68
+
69
+ ### Why This Matters
70
+ - **Consistency**: System message stays the same across executions
71
+ - **Maintainability**: Easy to update AI behavior without touching data flow
72
+ - **Best Practice**: Follows standard AI prompt engineering patterns
73
+ - **Clarity**: Separates "what the AI model is" from "what data to process"
74
+ `;
75
+ //# sourceMappingURL=system-message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-message.js","sourceRoot":"","sources":["../../../../src/chains/prompts/parameter-types/system-message.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsEnC,CAAC"}
@@ -2,6 +2,7 @@ import type { INodeTypeDescription } from 'n8n-workflow';
2
2
  import type { PromptBuilderContext } from '../../types/config';
3
3
  export declare class ParameterUpdatePromptBuilder {
4
4
  static buildSystemPrompt(context: PromptBuilderContext): string;
5
+ private static hasSystemMessageParameters;
5
6
  private static isSetNode;
6
7
  private static isIfNode;
7
8
  private static isHttpRequestNode;
@@ -15,6 +15,7 @@ const if_node_1 = require("./node-types/if-node");
15
15
  const set_node_1 = require("./node-types/set-node");
16
16
  const tool_nodes_1 = require("./node-types/tool-nodes");
17
17
  const resource_locator_1 = require("./parameter-types/resource-locator");
18
+ const system_message_1 = require("./parameter-types/system-message");
18
19
  const text_fields_1 = require("./parameter-types/text-fields");
19
20
  const prompt_config_1 = require("./prompt-config");
20
21
  class ParameterUpdatePromptBuilder {
@@ -23,7 +24,10 @@ class ParameterUpdatePromptBuilder {
23
24
  const sections = [];
24
25
  sections.push(core_instructions_1.CORE_INSTRUCTIONS);
25
26
  sections.push(expression_rules_1.EXPRESSION_RULES);
26
- if (this.isSetNode(context.nodeType)) {
27
+ if (this.hasSystemMessageParameters(context.nodeDefinition)) {
28
+ sections.push(system_message_1.SYSTEM_MESSAGE_GUIDE);
29
+ }
30
+ else if (this.isSetNode(context.nodeType)) {
27
31
  sections.push(set_node_1.SET_NODE_GUIDE);
28
32
  }
29
33
  else if (this.isIfNode(context.nodeType)) {
@@ -53,6 +57,24 @@ class ParameterUpdatePromptBuilder {
53
57
  const finalPrompt = sections.join('\n');
54
58
  return finalPrompt;
55
59
  }
60
+ static hasSystemMessageParameters(nodeDefinition) {
61
+ if (!nodeDefinition.properties)
62
+ return false;
63
+ const hasSystemMessageParam = nodeDefinition.properties.some((prop) => {
64
+ if (prop.name === 'options' && prop.type === 'collection') {
65
+ const collectionProp = prop;
66
+ if (Array.isArray(collectionProp.options)) {
67
+ return collectionProp.options.some((opt) => opt.name === 'systemMessage' || opt.name === 'system');
68
+ }
69
+ }
70
+ if (prop.name === 'messages' &&
71
+ (prop.type === 'fixedCollection' || prop.type === 'collection')) {
72
+ return true;
73
+ }
74
+ return false;
75
+ });
76
+ return hasSystemMessageParam;
77
+ }
56
78
  static isSetNode(nodeType) {
57
79
  const category = (0, prompt_config_1.getNodeTypeCategory)(nodeType);
58
80
  return category === 'set';
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-builder.js","sourceRoot":"","sources":["../../../src/chains/prompts/prompt-builder.ts"],"names":[],"mappings":";;;AAEA,4DAAyD;AACzD,gEAA6D;AAC7D,8DAA2D;AAC3D,wDAAqD;AACrD,6FAA0F;AAC1F,+EAA4E;AAC5E,wEAAqE;AACrE,0EAAuE;AACvE,oEAAyE;AACzE,4DAA+D;AAC/D,kDAAqD;AACrD,oDAAuD;AACvD,wDAA2D;AAC3D,yEAA4E;AAC5E,+DAAkE;AAClE,mDAIyB;AAGzB,MAAa,4BAA4B;IAIxC,MAAM,CAAC,iBAAiB,CAAC,OAA6B;QACrD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;QACtC,MAAM,QAAQ,GAAa,EAAE,CAAC;QAG9B,QAAQ,CAAC,IAAI,CAA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AAC,IAAI,CAAC,mCAAgB,CAAC,CAAC;QACjC,CAAC;QAED,IAAI,OAAO,CAAC,wBAAwB,EAAE,CAAC;YACtC,QAAQ,CAAC,IAAI,CAAC,qDAAyB,CAAC,CAAC;QAC1C,CAAC;QAGD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,QAAQ,CAAC,IAAI,CAAC,uCAAsB,CAAC,CAAC;QACvC,CAAC;QAGD,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;IACvC,CAAC;IAKD,MAAM,CAAC,4BAA4B,CAAC,cAAoC;QACvE,IAAI,CAAC,cAAc,CAAC,UAAU;YAAE,OAAO,KAAK,CAAC;QAE7C,MAAM,eAAe,GAAG,CAAC,UAA6B,EAAW,EAAE;YAClE,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;gBAC/B,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB;oBAAE,OAAO,IAAI,CAAC;YACrF,CAAC;YACD,OAAO,KAAK,CAAC;QACd,CAAC,CAAC;QAEF,OAAO,eAAe,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IACnD,CAAC;IAKD,MAAM,CAAC,cAAc,CAAC,MAAc;QAEnC,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACrC,CAAC;CACD;AAlMD,oEAkMC"}
@@ -0,0 +1,3 @@
1
+ import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
2
+ export declare function setupIntegrationLLM(): Promise<BaseChatModel>;
3
+ export declare function shouldRunIntegrationTests(): boolean;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setupIntegrationLLM = setupIntegrationLLM;
4
+ exports.shouldRunIntegrationTests = shouldRunIntegrationTests;
5
+ const llm_config_1 = require("../../../llm-config");
6
+ async function setupIntegrationLLM() {
7
+ const apiKey = process.env.N8N_AI_ANTHROPIC_KEY;
8
+ if (!apiKey) {
9
+ throw new Error('N8N_AI_ANTHROPIC_KEY environment variable is required for integration tests');
10
+ }
11
+ return await (0, llm_config_1.anthropicClaudeSonnet45)({ apiKey });
12
+ }
13
+ function shouldRunIntegrationTests() {
14
+ return process.env.ENABLE_INTEGRATION_TESTS === 'true';
15
+ }
16
+ //# sourceMappingURL=test-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-helpers.js","sourceRoot":"","sources":["../../../../src/chains/test/integration/test-helpers.ts"],"names":[],"mappings":";;AAWA,kDAMC;AAQD,8DAEC;AAzBD,6CAAuD;AAShD,KAAK,UAAU,mBAAmB;IACxC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;IAChD,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC;IAChG,CAAC;IACD,OAAO,MAAM,IAAA,oCAAuB,EAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AAClD,CAAC;AAQD,SAAgB,yBAAyB;IACxC,OAAO,OAAO,CAAC,GAAG,CAAC,wBAAwB,KAAK,MAAM,CAAC;AACxD,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './ai-workflow-builder-agent.service';
2
2
  export type * from './types';
3
3
  export * from './workflow-state';
4
+ export { resolveConnections } from './validation/utils/resolve-connections';
package/dist/index.js CHANGED
@@ -14,6 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.resolveConnections = void 0;
17
18
  __exportStar(require("./ai-workflow-builder-agent.service"), exports);
18
19
  __exportStar(require("./workflow-state"), exports);
20
+ var resolve_connections_1 = require("./validation/utils/resolve-connections");
21
+ Object.defineProperty(exports, "resolveConnections", { enumerable: true, get: function () { return resolve_connections_1.resolveConnections; } });
19
22
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sEAAoD;AAEpD,mDAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,sEAAoD;AAEpD,mDAAiC;AACjC,8EAA4E;AAAnE,yHAAA,kBAAkB,OAAA"}
@@ -0,0 +1,7 @@
1
+ import type { BestPracticesDocument } from '../../types/best-practices';
2
+ export declare class ChatbotBestPractices implements BestPracticesDocument {
3
+ readonly technique: "chatbot";
4
+ readonly version = "1.0.0";
5
+ private readonly documentation;
6
+ getDocumentation(): string;
7
+ }
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChatbotBestPractices = void 0;
4
+ const categorization_1 = require("../../types/categorization");
5
+ class ChatbotBestPractices {
6
+ technique = categorization_1.WorkflowTechnique.CHATBOT;
7
+ version = '1.0.0';
8
+ documentation = `# Best Practices: Chatbot Workflows
9
+
10
+ ## Workflow Design
11
+
12
+ Break chatbot logic into manageable steps and use error handling nodes (IF, Switch) with fallback mechanisms to manage unexpected inputs.
13
+
14
+ Most chatbots run through external platforms like Slack, Telegram, or WhatsApp rather than through the n8n chat interface - if the user
15
+ requests a service like this don't use the built in chat interface nodes. If the user mentions chatting but does not mention a service
16
+ then use the built in n8n chat node.
17
+
18
+ CRITICAL: The user may ask to be able to chat to a workflow as well as trigger it via some other method, for example scheduling information
19
+ gathering but also being able to chat with the agent - in scenarios like this the two separate workflows MUST be connected through shared memory,
20
+ vector stores, data storage, or direct connections.
21
+
22
+ Example pattern:
23
+ - Schedule Trigger → News Gathering Agent → [memory node via ai_memory]
24
+ - Chat Trigger → Chatbot Agent → [SAME memory node via ai_memory]
25
+ - Result: Both agents share conversation/context history, enabling the chatbot to discuss gathered news
26
+
27
+ For the chatbot always use the same chat node type as used for response. If Telegram has been requested trigger the chatbot via telegram AND
28
+ respond via telegram - do not mix chatbot interfaces.
29
+
30
+ ## Context & Memory Management
31
+
32
+ Always utilise memory in chatbot agent nodes - providing context gives you full conversation history and more control over context.
33
+ Memory nodes enable the bot to handle follow-up questions by maintaining short-term conversation history.
34
+
35
+ Include information with the user prompt such as timestamp, user ID, or session metadata. This enriches context without relying solely on memory and user prompt.
36
+
37
+ If there are other agents involved in the workflow you should share memory between the chatbot and those other agents where it makes sense.
38
+ Connect the same memory node to multiple agents to enable data sharing and context continuity.
39
+
40
+ ## Context Engineering & AI Agent Output
41
+
42
+ It can be beneficial to respond to the user as a tool of the chatbot agent rather than using the agent output - this allows the agent to loop/carry out multiple responses if necessary.
43
+ This will require adding a note to the system prompt for the agent to tell it to use the tool to respond to the user.
44
+
45
+ ## Message Attribution
46
+
47
+ n8n chatbots often attach the attribution "n8n workflow" to messages by default - you must disable this setting which will
48
+ often be called "Append n8n Attribution" for nodes that support it, add this setting and set it to false.
49
+
50
+ ## Recommended Nodes
51
+
52
+ ### Chat Trigger (@n8n/n8n-nodes-langchain.chatTrigger)
53
+
54
+ Purpose: Entry point for user messages in n8n-hosted chat interfaces
55
+
56
+ Pitfalls:
57
+
58
+ - Most production chatbots use external platforms (Slack, Telegram) rather than n8n's chat interface
59
+
60
+ ### AI Agent (@n8n/n8n-nodes-langchain.agent)
61
+
62
+ Purpose: Orchestrates logic, tool use, and LLM calls for intelligent responses
63
+
64
+ ### Chat Model Nodes
65
+
66
+ - OpenAI Chat Model (@n8n/n8n-nodes-langchain.lmChatOpenAi)
67
+ - Google Gemini Chat Model (@n8n/n8n-nodes-langchain.lmChatGoogleGemini)
68
+ - xAI Grok Chat Model (@n8n/n8n-nodes-langchain.lmChatXAiGrok)
69
+ - DeepSeek Chat Model (@n8n/n8n-nodes-langchain.lmChatDeepSeek)
70
+
71
+ Purpose: Connect to LLMs for natural, context-aware responses
72
+
73
+ ### Simple Memory (@n8n/n8n-nodes-langchain.memoryBufferWindow)
74
+
75
+ Purpose: Maintains short-term conversation history for context continuity
76
+
77
+ ### HTTP Request (n8n-nodes-base.httpRequest)
78
+
79
+ Purpose: Fetches external data to enrich chatbot responses with real-time or organizational information
80
+
81
+ ### Database Nodes & Google Sheets
82
+
83
+ - Postgres (n8n-nodes-base.postgres)
84
+ - MySQL (n8n-nodes-base.mySql)
85
+ - MongoDB (n8n-nodes-base.mongoDb)
86
+ - Google Sheets (n8n-nodes-base.googleSheets)
87
+
88
+ Purpose: Store conversation logs, retrieve structured data, or maintain user preferences
89
+
90
+ ### IF / Switch
91
+
92
+ - If (n8n-nodes-base.if)
93
+ - Switch (n8n-nodes-base.switch)
94
+
95
+ Purpose: Conditional logic and error handling for routing messages or managing conversation state
96
+
97
+ ### Integration Nodes
98
+
99
+ - Slack (n8n-nodes-base.slack)
100
+ - Telegram (n8n-nodes-base.telegram)
101
+ - WhatsApp Business Cloud (n8n-nodes-base.whatsApp)
102
+ - Discord (n8n-nodes-base.discord)
103
+
104
+ Purpose: Multi-channel support for deploying chatbots on popular messaging platforms
105
+
106
+ ## Common Pitfalls to Avoid
107
+
108
+ ### Leaving Chatbot Disconnected
109
+
110
+ When a workflow has multiple triggers (e.g., scheduled data collection + chatbot interaction), the chatbot MUST have access to the data
111
+ generated by the workflow. Connect the chatbot through shared memory, vector stores, data storage, or direct data flow connections.
112
+ `;
113
+ getDocumentation() {
114
+ return this.documentation;
115
+ }
116
+ }
117
+ exports.ChatbotBestPractices = ChatbotBestPractices;
118
+ //# sourceMappingURL=chatbot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chatbot.js","sourceRoot":"","sources":["../../../src/tools/best-practices/chatbot.ts"],"names":[],"mappings":";;;AACA,2DAA2D;AAE3D,MAAa,oBAAoB;IACvB,SAAS,GAAG,kCAAiB,CAAC,OAAO,CAAC;IACtC,OAAO,GAAG,OAAO,CAAC;IAEV,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwGjC,CAAC;IAED,gBAAgB;QACf,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;CACD;AAjHD,oDAiHC"}
@@ -0,0 +1,7 @@
1
+ import type { BestPracticesDocument } from '../../types/best-practices';
2
+ export declare class ContentGenerationBestPractices implements BestPracticesDocument {
3
+ readonly technique: "content_generation";
4
+ readonly version = "1.0.0";
5
+ private readonly documentation;
6
+ getDocumentation(): string;
7
+ }
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContentGenerationBestPractices = void 0;
4
+ const categorization_1 = require("../../types/categorization");
5
+ class ContentGenerationBestPractices {
6
+ technique = categorization_1.WorkflowTechnique.CONTENT_GENERATION;
7
+ version = '1.0.0';
8
+ documentation = `# Best Practices: Content Generation Workflows
9
+
10
+ ## Workflow Design
11
+
12
+ Break complex tasks into sequential steps (e.g., generate text, create image, compose video) for modularity and easier troubleshooting.
13
+
14
+ ## Content-Specific Guidance
15
+
16
+ For text generation, validate and sanitize input/output to avoid malformed data. When generating images, prefer binary data over URLs for uploads to avoid media type errors.
17
+
18
+ ## Recommended Nodes
19
+
20
+ ### OpenAI (@n8n/n8n-nodes-langchain.openAi)
21
+
22
+ Purpose: GPT-based text generation, DALL-E image generation, text-to-speech (TTS), and audio transcription
23
+
24
+ ### xAI Grok Chat Model (@n8n/n8n-nodes-langchain.lmChatXAiGrok)
25
+
26
+ Purpose: Conversational AI and text generation
27
+
28
+ ### Google Gemini Chat Model (@n8n/n8n-nodes-langchain.lmChatGoogleGemini)
29
+
30
+ Purpose: Image analysis and generation, video generation from text prompts, multimodal content creation
31
+
32
+ ### ElevenLabs
33
+
34
+ Purpose: Natural-sounding AI voice generation
35
+
36
+ Note: Use HTTP Request node or a community node to integrate with ElevenLabs API
37
+
38
+ ### HTTP Request (n8n-nodes-base.httpRequest)
39
+
40
+ Purpose: Integrating with other LLM and content generation APIs (e.g., Jasper, Writesonic, Anthropic, HuggingFace)
41
+
42
+ ### Edit Image (n8n-nodes-base.editImage)
43
+
44
+ Purpose: Manipulating images - resize, crop, rotate, and format conversion
45
+
46
+ Pitfalls:
47
+
48
+ - Ensure input is valid binary image data
49
+ - Check output format compatibility with downstream nodes
50
+
51
+ ### Markdown (n8n-nodes-base.markdown)
52
+
53
+ Purpose: Formatting and converting text to HTML or Markdown reports
54
+
55
+ ### Facebook Graph API (n8n-nodes-base.facebookGraphApi)
56
+
57
+ Purpose: Uploading videos and images to Instagram and Facebook
58
+
59
+ Pitfalls:
60
+
61
+ - Use binary data fields rather than URLs for media uploads to prevent "media type" errors
62
+ - Verify page IDs and access tokens have correct permissions
63
+
64
+ ### Wait (n8n-nodes-base.wait)
65
+
66
+ Purpose: Handling delays in video processing/uploading and respecting API rate limits
67
+
68
+ ## Common Pitfalls to Avoid
69
+
70
+ Binary Data Handling: For media uploads, use binary fields rather than URLs to prevent "media type" errors, especially with Facebook and Instagram APIs. Download media to binary data first, then upload from binary rather than passing URLs.
71
+
72
+ Async Processing: For long-running content generation tasks (especially video), implement proper wait/polling mechanisms. Don't assume instant completion - many AI services process requests asynchronously.
73
+ `;
74
+ getDocumentation() {
75
+ return this.documentation;
76
+ }
77
+ }
78
+ exports.ContentGenerationBestPractices = ContentGenerationBestPractices;
79
+ //# sourceMappingURL=content-generation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-generation.js","sourceRoot":"","sources":["../../../src/tools/best-practices/content-generation.ts"],"names":[],"mappings":";;;AACA,2DAA2D;AAE3D,MAAa,8BAA8B;IACjC,SAAS,GAAG,kCAAiB,CAAC,kBAAkB,CAAC;IACjD,OAAO,GAAG,OAAO,CAAC;IAEV,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiEjC,CAAC;IAED,gBAAgB;QACf,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;CACD;AA1ED,wEA0EC"}
@@ -0,0 +1,7 @@
1
+ import type { BestPracticesDocument } from '../../types/best-practices';
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
+ }