I want to make the Window Buffer Memory node compatible with both the Webhook and Chat Message triggers, so I tried to use the following expression to achieve this.
{{ $('Webhook').first().json?.sessionId || $('When chat message received').first().json.sessionId }}
However, it doesn't work. This type of expression works in other nodes.
{
"nodes": [
{
"parameters": {
"public": true,
"initialMessages": "ChatGPT",
"options": {
"allowFileUploads": true,
"allowedFilesMimeTypes": "txt,pdf",
"subtitle": "",
"title": "Hi there! 👋"
}
},
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"typeVersion": 1.1,
"position": [
-120,
180
],
"id": "740a0e1a-c655-4d99-863c-0e8569820fb5",
"name": "When chat message received",
"webhookId": "a8dbf527-12af-4d82-a7a7-ddbd69e6265b"
},
{
"parameters": {
"promptType": "define",
"text": "=sessionId: {{ $json.query?.sessionId || $json.sessionId }}\nchatInput: {{ $json.query?.chatInput || $json.chatInput }}\n",
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.7,
"position": [
240,
120
],
"id": "0fa9f0b1-539d-4dd3-b2f4-c86f0547c40d",
"name": "AI Agent"
},
{
"parameters": {
"options": {
"baseURL": "https://api.chatanywhere.org/v1"
}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1,
"position": [
200,
340
],
"id": "41df6a07-b5bb-4b49-8f44-3cb6bb7e935f",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"id": "oYt1X4B1EySK0Ho4",
"name": "OpenAi Free"
}
}
},
{
"parameters": {
"path": "ZP",
"responseMode": "responseNode",
"options": {}
},
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
-120,
20
],
"id": "be97f8d6-0f80-4d6a-ad51-0db8baa40946",
"name": "Webhook",
"webhookId": "323dbfae-6242-4a36-8501-ad9be790aba0"
},
{
"parameters": {
"options": {}
},
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [
680,
20
],
"id": "9e9e770c-8189-43f6-a78d-47dbfa4951b5",
"name": "Respond to Webhook"
},
{
"parameters": {
"sessionIdType": "customKey",
"sessionKey": "={{ $('Webhook').first().json?.sessionId || $('When chat message received').first().json.sessionId }}"
},
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"typeVersion": 1.3,
"position": [
340,
340
],
"id": "459564ff-871f-4acc-8edb-f10cc0fff173",
"name": "Window Buffer Memory"
}
],
"connections": {
"When chat message received": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Webhook": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Window Buffer Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
}
},
"pinData": {}
}
Bug Description
I want to make the Window Buffer Memory node compatible with both the Webhook and Chat Message triggers, so I tried to use the following expression to achieve this.
However, it doesn't work. This type of expression works in other nodes.
BUG4.mp4
Workflow config code:
To Reproduce
Expected behavior
support ||
Operating System
self-hosted n8n on a Windows 10
n8n Version
1.71
Node.js Version
20.18.0
Database
SQLite (default)
Execution mode
main (default)