@n8n/n8n-nodes-langchain 2.4.2 → 2.5.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 (59) hide show
  1. package/dist/credentials/ChromaCloudApi.credentials.js +82 -0
  2. package/dist/credentials/ChromaCloudApi.credentials.js.map +1 -0
  3. package/dist/credentials/ChromaSelfHostedApi.credentials.js +105 -0
  4. package/dist/credentials/ChromaSelfHostedApi.credentials.js.map +1 -0
  5. package/dist/known/credentials.json +14 -0
  6. package/dist/known/nodes.json +4 -0
  7. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/runAgent.js +3 -2
  8. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/runAgent.js.map +1 -1
  9. package/dist/nodes/code/Code.node.js +1 -1
  10. package/dist/nodes/code/Code.node.js.map +1 -1
  11. package/dist/nodes/embeddings/EmbeddingsAzureOpenAi/EmbeddingsAzureOpenAi.node.js +2 -1
  12. package/dist/nodes/embeddings/EmbeddingsAzureOpenAi/EmbeddingsAzureOpenAi.node.js.map +1 -1
  13. package/dist/nodes/embeddings/EmbeddingsOpenAI/EmbeddingsOpenAi.node.js +3 -5
  14. package/dist/nodes/embeddings/EmbeddingsOpenAI/EmbeddingsOpenAi.node.js.map +1 -1
  15. package/dist/nodes/llms/LMChatAnthropic/LmChatAnthropic.node.js.map +1 -1
  16. package/dist/nodes/llms/LMChatLemonade/LmChatLemonade.node.js +4 -0
  17. package/dist/nodes/llms/LMChatLemonade/LmChatLemonade.node.js.map +1 -1
  18. package/dist/nodes/llms/LMChatOllama/LmChatOllama.node.js +4 -1
  19. package/dist/nodes/llms/LMChatOllama/LmChatOllama.node.js.map +1 -1
  20. package/dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js +15 -10
  21. package/dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js.map +1 -1
  22. package/dist/nodes/llms/LMOpenAi/LmOpenAi.node.js +6 -2
  23. package/dist/nodes/llms/LMOpenAi/LmOpenAi.node.js.map +1 -1
  24. package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js +6 -2
  25. package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js.map +1 -1
  26. package/dist/nodes/llms/LmChatDeepSeek/LmChatDeepSeek.node.js +6 -2
  27. package/dist/nodes/llms/LmChatDeepSeek/LmChatDeepSeek.node.js.map +1 -1
  28. package/dist/nodes/llms/LmChatMistralCloud/LmChatMistralCloud.node.js +5 -0
  29. package/dist/nodes/llms/LmChatMistralCloud/LmChatMistralCloud.node.js.map +1 -1
  30. package/dist/nodes/llms/LmChatOpenRouter/LmChatOpenRouter.node.js +6 -2
  31. package/dist/nodes/llms/LmChatOpenRouter/LmChatOpenRouter.node.js.map +1 -1
  32. package/dist/nodes/llms/LmChatVercelAiGateway/LmChatVercelAiGateway.node.js +6 -2
  33. package/dist/nodes/llms/LmChatVercelAiGateway/LmChatVercelAiGateway.node.js.map +1 -1
  34. package/dist/nodes/llms/LmChatXAiGrok/LmChatXAiGrok.node.js +6 -2
  35. package/dist/nodes/llms/LmChatXAiGrok/LmChatXAiGrok.node.js.map +1 -1
  36. package/dist/nodes/mcp/shared/utils.js +4 -2
  37. package/dist/nodes/mcp/shared/utils.js.map +1 -1
  38. package/dist/nodes/trigger/ChatTrigger/Chat.node.js +118 -108
  39. package/dist/nodes/trigger/ChatTrigger/Chat.node.js.map +1 -1
  40. package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js +22 -13
  41. package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js.map +1 -1
  42. package/dist/nodes/trigger/ChatTrigger/constants.js +28 -18
  43. package/dist/nodes/trigger/ChatTrigger/constants.js.map +1 -1
  44. package/dist/nodes/trigger/ChatTrigger/util.js +75 -4
  45. package/dist/nodes/trigger/ChatTrigger/util.js.map +1 -1
  46. package/dist/nodes/vector_store/VectorStoreChromaDB/VectorStoreChromaDB.node.js +356 -0
  47. package/dist/nodes/vector_store/VectorStoreChromaDB/VectorStoreChromaDB.node.js.map +1 -0
  48. package/dist/nodes/vector_store/VectorStoreChromaDB/chroma.svg +9 -0
  49. package/dist/nodes/vector_store/shared/descriptions.js +24 -0
  50. package/dist/nodes/vector_store/shared/descriptions.js.map +1 -1
  51. package/dist/nodes/vendors/OpenAi/v1/actions/assistant/message.operation.js +6 -2
  52. package/dist/nodes/vendors/OpenAi/v1/actions/assistant/message.operation.js.map +1 -1
  53. package/dist/types/credentials.json +2 -0
  54. package/dist/types/nodes.json +4 -3
  55. package/dist/utils/httpProxyAgent.js +15 -4
  56. package/dist/utils/httpProxyAgent.js.map +1 -1
  57. package/dist/utils/tracing.js +1 -1
  58. package/dist/utils/tracing.js.map +1 -1
  59. package/package.json +12 -8
@@ -21,115 +21,24 @@ __export(Chat_node_exports, {
21
21
  Chat: () => Chat
22
22
  });
23
23
  module.exports = __toCommonJS(Chat_node_exports);
24
+ var import_descriptions = require("n8n-nodes-base/dist/utils/sendAndWait/descriptions");
25
+ var import_utils = require("n8n-nodes-base/dist/utils/sendAndWait/utils");
24
26
  var import_n8n_workflow = require("n8n-workflow");
25
27
  var import_util = require("./util");
26
- const limitWaitTimeProperties = [
27
- {
28
- displayName: "Limit Type",
29
- name: "limitType",
30
- type: "options",
31
- default: "afterTimeInterval",
32
- description: "Sets the condition for the execution to resume. Can be a specified date or after some time.",
33
- options: [
34
- {
35
- name: "After Time Interval",
36
- description: "Waits for a certain amount of time",
37
- value: "afterTimeInterval"
38
- },
39
- {
40
- name: "At Specified Time",
41
- description: "Waits until the set date and time to continue",
42
- value: "atSpecifiedTime"
43
- }
44
- ]
45
- },
46
- {
47
- displayName: "Amount",
48
- name: "resumeAmount",
49
- type: "number",
50
- displayOptions: {
51
- show: {
52
- limitType: ["afterTimeInterval"]
53
- }
54
- },
55
- typeOptions: {
56
- minValue: 0,
57
- numberPrecision: 2
58
- },
59
- default: 1,
60
- description: "The time to wait"
61
- },
62
- {
63
- displayName: "Unit",
64
- name: "resumeUnit",
65
- type: "options",
66
- displayOptions: {
67
- show: {
68
- limitType: ["afterTimeInterval"]
69
- }
70
- },
71
- options: [
72
- {
73
- name: "Minutes",
74
- value: "minutes"
75
- },
76
- {
77
- name: "Hours",
78
- value: "hours"
79
- },
80
- {
81
- name: "Days",
82
- value: "days"
83
- }
84
- ],
85
- default: "hours",
86
- description: "Unit of the interval value"
87
- },
88
- {
89
- displayName: "Max Date and Time",
90
- name: "maxDateAndTime",
91
- type: "dateTime",
92
- displayOptions: {
93
- show: {
94
- limitType: ["atSpecifiedTime"]
95
- }
96
- },
97
- default: "",
98
- description: "Continue execution after the specified date and time"
99
- }
100
- ];
101
- const limitWaitTimeOption = {
102
- displayName: "Limit Wait Time",
103
- name: "limitWaitTime",
104
- type: "fixedCollection",
105
- description: "Whether to limit the time this node should wait for a user response before execution resumes",
106
- default: { values: { limitType: "afterTimeInterval", resumeAmount: 45, resumeUnit: "minutes" } },
107
- options: [
108
- {
109
- displayName: "Values",
110
- name: "values",
111
- values: limitWaitTimeProperties
112
- }
113
- ],
114
- displayOptions: {
115
- show: {
116
- [`/${import_n8n_workflow.CHAT_WAIT_USER_REPLY}`]: [true]
117
- }
118
- }
119
- };
120
28
  class Chat {
121
29
  constructor() {
122
30
  this.description = {
123
31
  usableAsTool: true,
124
- displayName: "Respond to Chat",
32
+ displayName: "Chat",
125
33
  name: "chat",
126
34
  icon: "fa:comments",
127
35
  iconColor: "black",
128
36
  group: ["input"],
129
- version: 1,
130
- description: "Send a message to a chat",
37
+ version: [1, 1.1],
38
+ defaultVersion: 1.1,
39
+ description: "Send a message into the chat",
131
40
  defaults: {
132
- name: "Respond to Chat"
41
+ name: "Chat"
133
42
  },
134
43
  codex: {
135
44
  categories: ["Core Nodes", "HITL"],
@@ -147,6 +56,8 @@ class Chat {
147
56
  },
148
57
  inputs: `={{ (${import_util.configureInputs})($parameter) }}`,
149
58
  outputs: [import_n8n_workflow.NodeConnectionTypes.Main],
59
+ waitingNodeTooltip: import_utils.SEND_AND_WAIT_WAITING_TOOLTIP,
60
+ webhooks: import_descriptions.sendAndWaitWebhooksDescription,
150
61
  properties: [
151
62
  {
152
63
  displayName: "Verify you're using a chat trigger with the 'Response Mode' option set to 'Using Response Nodes'",
@@ -154,6 +65,30 @@ class Chat {
154
65
  type: "notice",
155
66
  default: ""
156
67
  },
68
+ {
69
+ displayName: "Operation",
70
+ name: "operation",
71
+ type: "options",
72
+ default: "send",
73
+ noDataExpression: true,
74
+ options: [
75
+ {
76
+ name: "Send Message",
77
+ value: "send",
78
+ action: "Send a message"
79
+ },
80
+ {
81
+ name: "Send and Wait for Response",
82
+ value: import_n8n_workflow.SEND_AND_WAIT_OPERATION,
83
+ action: "Send message and wait for response"
84
+ }
85
+ ],
86
+ displayOptions: {
87
+ show: {
88
+ "@version": [{ _cnd: { gte: 1.1 } }]
89
+ }
90
+ }
91
+ },
157
92
  {
158
93
  displayName: "Message",
159
94
  name: "message",
@@ -161,7 +96,7 @@ class Chat {
161
96
  default: "",
162
97
  required: true,
163
98
  typeOptions: {
164
- rows: 6
99
+ rows: 4
165
100
  }
166
101
  },
167
102
  {
@@ -169,8 +104,14 @@ class Chat {
169
104
  name: import_n8n_workflow.CHAT_WAIT_USER_REPLY,
170
105
  type: "boolean",
171
106
  default: true,
172
- noDataExpression: true
107
+ noDataExpression: true,
108
+ displayOptions: {
109
+ show: {
110
+ "@version": [{ _cnd: { lt: 1.1 } }]
111
+ }
112
+ }
173
113
  },
114
+ ...(0, import_util.getSendAndWaitPropertiesForChatNode)(),
174
115
  {
175
116
  displayName: "Options",
176
117
  name: "options",
@@ -187,9 +128,29 @@ class Chat {
187
128
  displayName: "Add Memory Input Connection",
188
129
  name: "memoryConnection",
189
130
  type: "boolean",
190
- default: false
131
+ default: false,
132
+ displayOptions: {
133
+ hide: {
134
+ "/responseType": ["approval"]
135
+ }
136
+ }
137
+ },
138
+ {
139
+ ...import_descriptions.limitWaitTimeOption,
140
+ displayOptions: {
141
+ show: {
142
+ [`/${import_n8n_workflow.CHAT_WAIT_USER_REPLY}`]: [true]
143
+ }
144
+ }
191
145
  },
192
- limitWaitTimeOption
146
+ {
147
+ ...import_descriptions.limitWaitTimeOption,
148
+ displayOptions: {
149
+ show: {
150
+ "/operation": [import_n8n_workflow.SEND_AND_WAIT_OPERATION]
151
+ }
152
+ }
153
+ }
193
154
  ]
194
155
  },
195
156
  {
@@ -198,20 +159,42 @@ class Chat {
198
159
  type: "collection",
199
160
  placeholder: "Add Option",
200
161
  default: {},
201
- options: [limitWaitTimeOption],
162
+ options: [import_descriptions.limitWaitTimeOption],
202
163
  displayOptions: {
203
164
  show: {
204
165
  "@tool": [true],
205
166
  [`/${import_n8n_workflow.CHAT_WAIT_USER_REPLY}`]: [true]
206
167
  }
207
168
  }
169
+ },
170
+ {
171
+ displayName: "Options",
172
+ name: "options",
173
+ type: "collection",
174
+ placeholder: "Add Option",
175
+ default: {},
176
+ options: [import_descriptions.limitWaitTimeOption],
177
+ displayOptions: {
178
+ show: {
179
+ "@tool": [true],
180
+ "/operation": [import_n8n_workflow.SEND_AND_WAIT_OPERATION]
181
+ }
182
+ }
208
183
  }
209
184
  ]
210
185
  };
186
+ this.webhook = import_utils.sendAndWaitWebhook;
211
187
  }
212
188
  async onMessage(context, data) {
213
189
  const options = context.getNodeParameter("options", 0, {});
214
- const waitForReply = context.getNodeParameter(import_n8n_workflow.CHAT_WAIT_USER_REPLY, 0, true);
190
+ const nodeVersion = context.getNode().typeVersion;
191
+ let waitForReply;
192
+ if (nodeVersion >= 1.1) {
193
+ const operation = context.getNodeParameter("operation", 0, "sendMessage");
194
+ waitForReply = operation === import_n8n_workflow.SEND_AND_WAIT_OPERATION;
195
+ } else {
196
+ waitForReply = context.getNodeParameter(import_n8n_workflow.CHAT_WAIT_USER_REPLY, 0, true);
197
+ }
215
198
  if (!waitForReply) {
216
199
  const inputData = context.getInputData();
217
200
  return [inputData];
@@ -223,7 +206,33 @@ class Chat {
223
206
  await memory.chatHistory.addUserMessage(message);
224
207
  }
225
208
  }
226
- return [[data]];
209
+ if (nodeVersion < 1.1) {
210
+ return [[data]];
211
+ }
212
+ const responseType = context.getNodeParameter(
213
+ "responseType",
214
+ 0,
215
+ import_n8n_workflow.FREE_TEXT_CHAT_RESPONSE_TYPE
216
+ );
217
+ const isFreeText = responseType === import_n8n_workflow.FREE_TEXT_CHAT_RESPONSE_TYPE;
218
+ return [
219
+ [
220
+ {
221
+ ...data,
222
+ json: {
223
+ // put everything under the `data` key to be consistent
224
+ // with other HITL nodes
225
+ data: {
226
+ ...data.json,
227
+ // if the response type is not "Free Text" and the
228
+ // user has typed something - we assume it's
229
+ // disapproval
230
+ approved: isFreeText ? void 0 : false
231
+ }
232
+ }
233
+ }
234
+ ]
235
+ ];
227
236
  }
228
237
  async execute() {
229
238
  const connectedNodes = this.getParentNodes(this.getNode().name, {
@@ -248,7 +257,7 @@ class Chat {
248
257
  if (parameters.mode === "webhook") {
249
258
  throw new import_n8n_workflow.NodeOperationError(
250
259
  this.getNode(),
251
- '"Embeded chat" is not supported, change the "Mode" in the chat trigger node to the "Hosted Chat"'
260
+ '"Embedded chat" is not supported, change the "Mode" in the chat trigger node to the "Hosted Chat"'
252
261
  );
253
262
  }
254
263
  if (parameters.options.responseMode !== "responseNodes") {
@@ -257,12 +266,13 @@ class Chat {
257
266
  '"Response Mode" in the chat trigger node must be set to "Respond Nodes"'
258
267
  );
259
268
  }
260
- const message = this.getNodeParameter("message", 0) ?? "";
269
+ const message = (0, import_util.getChatMessage)(this);
261
270
  const options = this.getNodeParameter("options", 0, {});
262
271
  if (options.memoryConnection) {
263
272
  const memory = await this.getInputConnectionData(import_n8n_workflow.NodeConnectionTypes.AiMemory, 0);
264
273
  if (memory) {
265
- await memory.chatHistory.addAIMessage(message);
274
+ const text = typeof message === "string" ? message : message.text;
275
+ await memory.chatHistory.addAIMessage(text);
266
276
  }
267
277
  }
268
278
  const waitTill = (0, import_util.configureWaitTillDate)(this);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../nodes/trigger/ChatTrigger/Chat.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport type { BaseChatMemory } from '@langchain/classic/memory';\nimport {\n\tCHAT_TRIGGER_NODE_TYPE,\n\tCHAT_WAIT_USER_REPLY,\n\tNodeConnectionTypes,\n\tNodeOperationError,\n} from 'n8n-workflow';\nimport type {\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeTypeDescription,\n\tINodeType,\n\tINodeProperties,\n\tNodeTypeAndVersion,\n\tINode,\n} from 'n8n-workflow';\n\nimport { configureInputs, configureWaitTillDate } from './util';\n\nconst limitWaitTimeProperties: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Limit Type',\n\t\tname: 'limitType',\n\t\ttype: 'options',\n\t\tdefault: 'afterTimeInterval',\n\t\tdescription:\n\t\t\t'Sets the condition for the execution to resume. Can be a specified date or after some time.',\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'After Time Interval',\n\t\t\t\tdescription: 'Waits for a certain amount of time',\n\t\t\t\tvalue: 'afterTimeInterval',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'At Specified Time',\n\t\t\t\tdescription: 'Waits until the set date and time to continue',\n\t\t\t\tvalue: 'atSpecifiedTime',\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tdisplayName: 'Amount',\n\t\tname: 'resumeAmount',\n\t\ttype: 'number',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tlimitType: ['afterTimeInterval'],\n\t\t\t},\n\t\t},\n\t\ttypeOptions: {\n\t\t\tminValue: 0,\n\t\t\tnumberPrecision: 2,\n\t\t},\n\t\tdefault: 1,\n\t\tdescription: 'The time to wait',\n\t},\n\t{\n\t\tdisplayName: 'Unit',\n\t\tname: 'resumeUnit',\n\t\ttype: 'options',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tlimitType: ['afterTimeInterval'],\n\t\t\t},\n\t\t},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Minutes',\n\t\t\t\tvalue: 'minutes',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Hours',\n\t\t\t\tvalue: 'hours',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Days',\n\t\t\t\tvalue: 'days',\n\t\t\t},\n\t\t],\n\t\tdefault: 'hours',\n\t\tdescription: 'Unit of the interval value',\n\t},\n\t{\n\t\tdisplayName: 'Max Date and Time',\n\t\tname: 'maxDateAndTime',\n\t\ttype: 'dateTime',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tlimitType: ['atSpecifiedTime'],\n\t\t\t},\n\t\t},\n\t\tdefault: '',\n\t\tdescription: 'Continue execution after the specified date and time',\n\t},\n];\n\nconst limitWaitTimeOption: INodeProperties = {\n\tdisplayName: 'Limit Wait Time',\n\tname: 'limitWaitTime',\n\ttype: 'fixedCollection',\n\tdescription:\n\t\t'Whether to limit the time this node should wait for a user response before execution resumes',\n\tdefault: { values: { limitType: 'afterTimeInterval', resumeAmount: 45, resumeUnit: 'minutes' } },\n\toptions: [\n\t\t{\n\t\t\tdisplayName: 'Values',\n\t\t\tname: 'values',\n\t\t\tvalues: limitWaitTimeProperties,\n\t\t},\n\t],\n\tdisplayOptions: {\n\t\tshow: {\n\t\t\t[`/${CHAT_WAIT_USER_REPLY}`]: [true],\n\t\t},\n\t},\n};\n\nexport class Chat implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tusableAsTool: true,\n\t\tdisplayName: 'Respond to Chat',\n\t\tname: 'chat',\n\t\ticon: 'fa:comments',\n\t\ticonColor: 'black',\n\t\tgroup: ['input'],\n\t\tversion: 1,\n\t\tdescription: 'Send a message to a chat',\n\t\tdefaults: {\n\t\t\tname: 'Respond to Chat',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['Core Nodes', 'HITL'],\n\t\t\tsubcategories: {\n\t\t\t\tHITL: ['Human in the Loop'],\n\t\t\t},\n\t\t\talias: ['human', 'wait', 'hitl'],\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-langchain.respondtochat/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\tinputs: `={{ (${configureInputs})($parameter) }}`,\n\t\toutputs: [NodeConnectionTypes.Main],\n\t\tproperties: [\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t\"Verify you're using a chat trigger with the 'Response Mode' option set to 'Using Response Nodes'\",\n\t\t\t\tname: 'generalNotice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Message',\n\t\t\t\tname: 'message',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\trequired: true,\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 6,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Wait for User Reply',\n\t\t\t\tname: CHAT_WAIT_USER_REPLY,\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: true,\n\t\t\t\tnoDataExpression: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tplaceholder: 'Add Option',\n\t\t\t\tdefault: {},\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\thide: {\n\t\t\t\t\t\t'@tool': [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Add Memory Input Connection',\n\t\t\t\t\t\tname: 'memoryConnection',\n\t\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t\tdefault: false,\n\t\t\t\t\t},\n\t\t\t\t\tlimitWaitTimeOption,\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tplaceholder: 'Add Option',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [limitWaitTimeOption],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@tool': [true],\n\t\t\t\t\t\t[`/${CHAT_WAIT_USER_REPLY}`]: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t};\n\n\tasync onMessage(\n\t\tcontext: IExecuteFunctions,\n\t\tdata: INodeExecutionData,\n\t): Promise<INodeExecutionData[][]> {\n\t\tconst options = context.getNodeParameter('options', 0, {}) as {\n\t\t\tmemoryConnection?: boolean;\n\t\t};\n\n\t\tconst waitForReply = context.getNodeParameter(CHAT_WAIT_USER_REPLY, 0, true) as boolean;\n\n\t\tif (!waitForReply) {\n\t\t\tconst inputData = context.getInputData();\n\t\t\treturn [inputData];\n\t\t}\n\n\t\tif (options.memoryConnection) {\n\t\t\tconst memory = (await context.getInputConnectionData(NodeConnectionTypes.AiMemory, 0)) as\n\t\t\t\t| BaseChatMemory\n\t\t\t\t| undefined;\n\n\t\t\tconst message = data.json?.chatInput;\n\n\t\t\tif (memory && message) {\n\t\t\t\tawait memory.chatHistory.addUserMessage(message as string);\n\t\t\t}\n\t\t}\n\n\t\treturn [[data]];\n\t}\n\n\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\tconst connectedNodes = this.getParentNodes(this.getNode().name, {\n\t\t\tincludeNodeParameters: true,\n\t\t});\n\n\t\tlet chatTrigger: INode | NodeTypeAndVersion | undefined | null = connectedNodes.find(\n\t\t\t(node) => node.type === CHAT_TRIGGER_NODE_TYPE && !node.disabled,\n\t\t);\n\n\t\tif (!chatTrigger) {\n\t\t\ttry {\n\t\t\t\t// try to get chat trigger from workflow if node working as a tool\n\t\t\t\tchatTrigger = this.getChatTrigger();\n\t\t\t} catch (error) {}\n\t\t}\n\n\t\tif (!chatTrigger) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'Workflow must be started from a chat trigger node',\n\t\t\t);\n\t\t}\n\n\t\tconst parameters = chatTrigger.parameters as {\n\t\t\tmode?: 'hostedChat' | 'webhook';\n\t\t\toptions: { responseMode: 'lastNode' | 'responseNodes' | 'streaming' | 'responseNode' };\n\t\t};\n\n\t\tif (parameters.mode === 'webhook') {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'\"Embeded chat\" is not supported, change the \"Mode\" in the chat trigger node to the \"Hosted Chat\"',\n\t\t\t);\n\t\t}\n\n\t\tif (parameters.options.responseMode !== 'responseNodes') {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'\"Response Mode\" in the chat trigger node must be set to \"Respond Nodes\"',\n\t\t\t);\n\t\t}\n\n\t\tconst message = (this.getNodeParameter('message', 0) as string) ?? '';\n\t\tconst options = this.getNodeParameter('options', 0, {}) as {\n\t\t\tmemoryConnection?: boolean;\n\t\t};\n\n\t\tif (options.memoryConnection) {\n\t\t\tconst memory = (await this.getInputConnectionData(NodeConnectionTypes.AiMemory, 0)) as\n\t\t\t\t| BaseChatMemory\n\t\t\t\t| undefined;\n\n\t\t\tif (memory) {\n\t\t\t\tawait memory.chatHistory.addAIMessage(message);\n\t\t\t}\n\t\t}\n\n\t\tconst waitTill = configureWaitTillDate(this);\n\n\t\tawait this.putExecutionToWait(waitTill);\n\t\treturn [[{ json: {}, sendMessage: message }]];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0BAKO;AAWP,kBAAuD;AAEvD,MAAM,0BAA6C;AAAA,EAClD;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aACC;AAAA,IACD,SA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AAK;AAAA,IACzD;AAEA,QAAI,CAAC,aAAa;AACjB,UAAI;AAEH,sBAAc,KAAK,eAAe;AAAA,MACnC,SAAS,OAAO;AAAA,MAAC;AAAA,IAClB;AAEA,QAAI,CAAC,aAAa;AACjB,YAAM,IAAI;AAAA,QACT,KAAK,QAAQ;AAAA,QACb;AAAA,MACD;AAAA,IACD;AAEA,UAAM,aAAa,YAAY;AAK/B,QAAI,WAAW,SAAS,WAAW;AAClC,YAAM,IAAI;AAAA,QACT,KAAK,QAAQ;AAAA,QACb;AAAA,MACD;AAAA,IACD;AAEA,QAAI,WAAW,QAAQ,iBAAiB,iBAAiB;AACxD,YAAM,IAAI;AAAA,QACT,KAAK,QAAQ;AAAA,QACb;AAAA,MACD;AAAA,IACD;AAEA,UAAM,UAAW,KAAK,iBAAiB,WAAW,CAAC,KAAgB;AACnE,UAAM,UAAU,KAAK,iBAAiB,WAAW,GAAG,CAAC,CAAC;AAItD,QAAI,QAAQ,kBAAkB;AAC7B,YAAM,SAAU,MAAM,KAAK,uBAAuB,wCAAoB,UAAU,CAAC;AAIjF,UAAI,QAAQ;AACX,cAAM,OAAO,YAAY,aAAa,OAAO;AAAA,MAC9C;AAAA,IACD;AAEA,UAAM,eAAW,mCAAsB,IAAI;AAE3C,UAAM,KAAK,mBAAmB,QAAQ;AACtC,WAAO,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,aAAa,QAAQ,CAAC,CAAC;AAAA,EAC7C;AACD;","names":[]}
1
+ {"version":3,"sources":["../../../../nodes/trigger/ChatTrigger/Chat.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport type { BaseChatMemory } from '@langchain/classic/memory';\nimport {\n\tlimitWaitTimeOption,\n\tsendAndWaitWebhooksDescription,\n} from 'n8n-nodes-base/dist/utils/sendAndWait/descriptions';\nimport {\n\tSEND_AND_WAIT_WAITING_TOOLTIP,\n\tsendAndWaitWebhook,\n} from 'n8n-nodes-base/dist/utils/sendAndWait/utils';\nimport {\n\tCHAT_TRIGGER_NODE_TYPE,\n\tCHAT_WAIT_USER_REPLY,\n\tFREE_TEXT_CHAT_RESPONSE_TYPE,\n\tNodeConnectionTypes,\n\tNodeOperationError,\n\tSEND_AND_WAIT_OPERATION,\n} from 'n8n-workflow';\nimport type {\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeTypeDescription,\n\tINodeType,\n\tNodeTypeAndVersion,\n\tINode,\n} from 'n8n-workflow';\n\nimport {\n\tconfigureInputs,\n\tconfigureWaitTillDate,\n\tgetChatMessage,\n\tgetSendAndWaitPropertiesForChatNode,\n} from './util';\n\nexport class Chat implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tusableAsTool: true,\n\t\tdisplayName: 'Chat',\n\t\tname: 'chat',\n\t\ticon: 'fa:comments',\n\t\ticonColor: 'black',\n\t\tgroup: ['input'],\n\t\tversion: [1, 1.1],\n\t\tdefaultVersion: 1.1,\n\t\tdescription: 'Send a message into the chat',\n\t\tdefaults: {\n\t\t\tname: 'Chat',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['Core Nodes', 'HITL'],\n\t\t\tsubcategories: {\n\t\t\t\tHITL: ['Human in the Loop'],\n\t\t\t},\n\t\t\talias: ['human', 'wait', 'hitl'],\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-langchain.respondtochat/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\tinputs: `={{ (${configureInputs})($parameter) }}`,\n\t\toutputs: [NodeConnectionTypes.Main],\n\t\twaitingNodeTooltip: SEND_AND_WAIT_WAITING_TOOLTIP,\n\t\twebhooks: sendAndWaitWebhooksDescription,\n\t\tproperties: [\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t\"Verify you're using a chat trigger with the 'Response Mode' option set to 'Using Response Nodes'\",\n\t\t\t\tname: 'generalNotice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Operation',\n\t\t\t\tname: 'operation',\n\t\t\t\ttype: 'options',\n\t\t\t\tdefault: 'send',\n\t\t\t\tnoDataExpression: true,\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Send Message',\n\t\t\t\t\t\tvalue: 'send',\n\t\t\t\t\t\taction: 'Send a message',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Send and Wait for Response',\n\t\t\t\t\t\tvalue: SEND_AND_WAIT_OPERATION,\n\t\t\t\t\t\taction: 'Send message and wait for response',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.1 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Message',\n\t\t\t\tname: 'message',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\trequired: true,\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 4,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Wait for User Reply',\n\t\t\t\tname: CHAT_WAIT_USER_REPLY,\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: true,\n\t\t\t\tnoDataExpression: true,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { lt: 1.1 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t...getSendAndWaitPropertiesForChatNode(),\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tplaceholder: 'Add Option',\n\t\t\t\tdefault: {},\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\thide: {\n\t\t\t\t\t\t'@tool': [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Add Memory Input Connection',\n\t\t\t\t\t\tname: 'memoryConnection',\n\t\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t\tdefault: false,\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t\t'/responseType': ['approval'],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t...limitWaitTimeOption,\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t[`/${CHAT_WAIT_USER_REPLY}`]: [true],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t...limitWaitTimeOption,\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'/operation': [SEND_AND_WAIT_OPERATION],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tplaceholder: 'Add Option',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [limitWaitTimeOption],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@tool': [true],\n\t\t\t\t\t\t[`/${CHAT_WAIT_USER_REPLY}`]: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tplaceholder: 'Add Option',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [limitWaitTimeOption],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@tool': [true],\n\t\t\t\t\t\t'/operation': [SEND_AND_WAIT_OPERATION],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t};\n\n\twebhook = sendAndWaitWebhook;\n\n\tasync onMessage(\n\t\tcontext: IExecuteFunctions,\n\t\tdata: INodeExecutionData,\n\t): Promise<INodeExecutionData[][]> {\n\t\tconst options = context.getNodeParameter('options', 0, {}) as {\n\t\t\tmemoryConnection?: boolean;\n\t\t};\n\n\t\tconst nodeVersion = context.getNode().typeVersion;\n\t\tlet waitForReply;\n\t\tif (nodeVersion >= 1.1) {\n\t\t\tconst operation = context.getNodeParameter('operation', 0, 'sendMessage');\n\t\t\twaitForReply = operation === SEND_AND_WAIT_OPERATION;\n\t\t} else {\n\t\t\twaitForReply = context.getNodeParameter(CHAT_WAIT_USER_REPLY, 0, true) as boolean;\n\t\t}\n\n\t\tif (!waitForReply) {\n\t\t\tconst inputData = context.getInputData();\n\t\t\treturn [inputData];\n\t\t}\n\n\t\tif (options.memoryConnection) {\n\t\t\tconst memory = (await context.getInputConnectionData(NodeConnectionTypes.AiMemory, 0)) as\n\t\t\t\t| BaseChatMemory\n\t\t\t\t| undefined;\n\n\t\t\tconst message = data.json?.chatInput;\n\n\t\t\tif (memory && message) {\n\t\t\t\tawait memory.chatHistory.addUserMessage(message as string);\n\t\t\t}\n\t\t}\n\n\t\tif (nodeVersion < 1.1) {\n\t\t\treturn [[data]];\n\t\t}\n\n\t\tconst responseType = context.getNodeParameter(\n\t\t\t'responseType',\n\t\t\t0,\n\t\t\tFREE_TEXT_CHAT_RESPONSE_TYPE,\n\t\t) as string;\n\t\tconst isFreeText = responseType === FREE_TEXT_CHAT_RESPONSE_TYPE;\n\t\treturn [\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\t...data,\n\t\t\t\t\tjson: {\n\t\t\t\t\t\t// put everything under the `data` key to be consistent\n\t\t\t\t\t\t// with other HITL nodes\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t...data.json,\n\t\t\t\t\t\t\t// if the response type is not \"Free Text\" and the\n\t\t\t\t\t\t\t// user has typed something - we assume it's\n\t\t\t\t\t\t\t// disapproval\n\t\t\t\t\t\t\tapproved: isFreeText ? undefined : false,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t];\n\t}\n\n\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\tconst connectedNodes = this.getParentNodes(this.getNode().name, {\n\t\t\tincludeNodeParameters: true,\n\t\t});\n\n\t\tlet chatTrigger: INode | NodeTypeAndVersion | undefined | null = connectedNodes.find(\n\t\t\t(node) => node.type === CHAT_TRIGGER_NODE_TYPE && !node.disabled,\n\t\t);\n\n\t\tif (!chatTrigger) {\n\t\t\ttry {\n\t\t\t\t// try to get chat trigger from workflow if node working as a tool\n\t\t\t\tchatTrigger = this.getChatTrigger();\n\t\t\t} catch (error) {}\n\t\t}\n\n\t\tif (!chatTrigger) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'Workflow must be started from a chat trigger node',\n\t\t\t);\n\t\t}\n\n\t\tconst parameters = chatTrigger.parameters as {\n\t\t\tmode?: 'hostedChat' | 'webhook';\n\t\t\toptions: { responseMode: 'lastNode' | 'responseNodes' | 'streaming' | 'responseNode' };\n\t\t};\n\n\t\tif (parameters.mode === 'webhook') {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'\"Embedded chat\" is not supported, change the \"Mode\" in the chat trigger node to the \"Hosted Chat\"',\n\t\t\t);\n\t\t}\n\n\t\tif (parameters.options.responseMode !== 'responseNodes') {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'\"Response Mode\" in the chat trigger node must be set to \"Respond Nodes\"',\n\t\t\t);\n\t\t}\n\n\t\tconst message = getChatMessage(this);\n\t\tconst options = this.getNodeParameter('options', 0, {}) as {\n\t\t\tmemoryConnection?: boolean;\n\t\t};\n\n\t\tif (options.memoryConnection) {\n\t\t\tconst memory = (await this.getInputConnectionData(NodeConnectionTypes.AiMemory, 0)) as\n\t\t\t\t| BaseChatMemory\n\t\t\t\t| undefined;\n\n\t\t\tif (memory) {\n\t\t\t\tconst text = typeof message === 'string' ? message : message.text;\n\t\t\t\tawait memory.chatHistory.addAIMessage(text);\n\t\t\t}\n\t\t}\n\n\t\tconst waitTill = configureWaitTillDate(this);\n\n\t\tawait this.putExecutionToWait(waitTill);\n\t\treturn [[{ json: {}, sendMessage: message }]];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0BAGO;AACP,mBAGO;AACP,0BAOO;AAUP,kBAKO;AAEA,MAAM,KAA0B;AAAA,EAAhC;AACN,uBAAoC;AAAA,MACnC,cAAc;AAAA,MACd,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,WAAW;AAAA,MACX,OAAO,CAAC,OAAO;AAAA,MACf,SAAS,CAAC,GAAG,GAAG;AAAA,MAChB,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,cAAc,MAAM;AAAA,QACjC,eAAe;AAAA,UACd,MAAM,CAAC,mBAAmB;AAAA,QAC3B;AAAA,QACA,OAAO,CAAC,SAAS,QAAQ,MAAM;AAAA,QAC/B,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MACA,QAAQ,QAAQ,2BAAe;AAAA,MAC/B,SAAS,CAAC,wCAAoB,IAAI;AAAA,MAClC,oBAAoB;AAAA,MACpB,UAA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AI,WAAW,SAAS,WAAW;AAClC,YAAM,IAAI;AAAA,QACT,KAAK,QAAQ;AAAA,QACb;AAAA,MACD;AAAA,IACD;AAEA,QAAI,WAAW,QAAQ,iBAAiB,iBAAiB;AACxD,YAAM,IAAI;AAAA,QACT,KAAK,QAAQ;AAAA,QACb;AAAA,MACD;AAAA,IACD;AAEA,UAAM,cAAU,4BAAe,IAAI;AACnC,UAAM,UAAU,KAAK,iBAAiB,WAAW,GAAG,CAAC,CAAC;AAItD,QAAI,QAAQ,kBAAkB;AAC7B,YAAM,SAAU,MAAM,KAAK,uBAAuB,wCAAoB,UAAU,CAAC;AAIjF,UAAI,QAAQ;AACX,cAAM,OAAO,OAAO,YAAY,WAAW,UAAU,QAAQ;AAC7D,cAAM,OAAO,YAAY,aAAa,IAAI;AAAA,MAC3C;AAAA,IACD;AAEA,UAAM,eAAW,mCAAsB,IAAI;AAE3C,UAAM,KAAK,mBAAmB,QAAQ;AACtC,WAAO,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,aAAa,QAAQ,CAAC,CAAC;AAAA,EAC7C;AACD;","names":[]}
@@ -72,7 +72,7 @@ const streamingResponseMode = {
72
72
  const respondNodesResponseMode = {
73
73
  name: "Using Response Nodes",
74
74
  value: "responseNodes",
75
- description: "Send responses to the chat by using 'Respond to Chat' node"
75
+ description: "Send responses to the chat by using one or more Chat nodes"
76
76
  };
77
77
  const commonOptionsFields = [
78
78
  // CORS parameters are only valid for when chat is used in hosted or webhook mode
@@ -418,7 +418,7 @@ class ChatTrigger extends import_n8n_workflow.Node {
418
418
  default: ""
419
419
  },
420
420
  {
421
- displayName: 'Your n8n users will be able to use this agent in <a href="/home/chat/" target="_blank">Chat</a> once this workflow is published. Make sure to share this workflow with at least Project Chat User access to all users who should use it. Currently, only streaming response mode is supported.',
421
+ displayName: 'Your n8n users will be able to use this agent in <a href="/home/chat/" target="_blank">Chat</a> once this workflow is published. Make sure to share this workflow with at least Project Chat User access to all users who should use it.',
422
422
  name: "availableInChatNotice",
423
423
  type: "notice",
424
424
  displayOptions: {
@@ -543,7 +543,7 @@ class ChatTrigger extends import_n8n_workflow.Node {
543
543
  displayName: "Response Mode",
544
544
  name: "responseMode",
545
545
  type: "options",
546
- options: [streamingResponseMode],
546
+ options: [streamingResponseMode, lastNodeResponseMode],
547
547
  default: "streaming",
548
548
  description: "When and how to respond to the webhook",
549
549
  displayOptions: { show: { "/availableInChat": [true] } }
@@ -578,9 +578,9 @@ class ChatTrigger extends import_n8n_workflow.Node {
578
578
  displayName: "Response Mode",
579
579
  name: "responseMode",
580
580
  type: "options",
581
- options: [streamingResponseMode],
581
+ options: [streamingResponseMode, lastNodeResponseMode, respondNodesResponseMode],
582
582
  default: "streaming",
583
- description: "When and how to respond to the webhook",
583
+ description: "When and how to respond to the chat",
584
584
  displayOptions: { show: { "/availableInChat": [true] } }
585
585
  }
586
586
  ]
@@ -604,19 +604,19 @@ class ChatTrigger extends import_n8n_workflow.Node {
604
604
  displayName: "Response Mode",
605
605
  name: "responseMode",
606
606
  type: "options",
607
- options: [streamingResponseMode],
608
- default: "streaming",
609
- description: "When and how to respond to the webhook",
610
- displayOptions: { show: { "/availableInChat": [true] } }
607
+ options: [lastNodeResponseMode, streamingResponseMode, respondToWebhookResponseMode],
608
+ default: "lastNode",
609
+ description: "When and how to respond to the chat",
610
+ displayOptions: { show: { "/mode": ["webhook"], "/availableInChat": [false] } }
611
611
  },
612
612
  {
613
613
  displayName: "Response Mode",
614
614
  name: "responseMode",
615
615
  type: "options",
616
- options: [lastNodeResponseMode, streamingResponseMode, respondToWebhookResponseMode],
617
- default: "lastNode",
616
+ options: [streamingResponseMode, lastNodeResponseMode],
617
+ default: "streaming",
618
618
  description: "When and how to respond to the chat",
619
- displayOptions: { show: { "/mode": ["webhook"], "/availableInChat": [false] } }
619
+ displayOptions: { show: { "/mode": ["webhook"], "/availableInChat": [true] } }
620
620
  },
621
621
  {
622
622
  displayName: "Response Mode",
@@ -624,8 +624,17 @@ class ChatTrigger extends import_n8n_workflow.Node {
624
624
  type: "options",
625
625
  options: [lastNodeResponseMode, streamingResponseMode, respondNodesResponseMode],
626
626
  default: "lastNode",
627
- description: "When and how to respond to the webhook",
627
+ description: "When and how to respond to the chat",
628
628
  displayOptions: { show: { "/mode": ["hostedChat"], "/availableInChat": [false] } }
629
+ },
630
+ {
631
+ displayName: "Response Mode",
632
+ name: "responseMode",
633
+ type: "options",
634
+ options: [streamingResponseMode, lastNodeResponseMode, respondNodesResponseMode],
635
+ default: "streaming",
636
+ description: "When and how to respond to the chat",
637
+ displayOptions: { show: { "/mode": ["hostedChat"], "/availableInChat": [true] } }
629
638
  }
630
639
  ]
631
640
  }