feat: Add Chat Trigger node (#7409)

Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jesper Bylund <mail@jesperbylund.com>
Co-authored-by: OlegIvaniv <me@olegivaniv.com>
Co-authored-by: Deborah <deborah@starfallprojects.co.uk>
Co-authored-by: Jan Oberhauser <janober@users.noreply.github.com>
Co-authored-by: Jon <jonathan.bennetts@gmail.com>
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com>
Co-authored-by: Giulio Andreini <andreini@netseven.it>
Co-authored-by: Mason Geloso <Mason.geloso@gmail.com>
Co-authored-by: Mason Geloso <hone@Masons-Mac-mini.local>
Co-authored-by: Mutasem Aldmour <mutasem@n8n.io>
This commit is contained in:
Alex Grozav
2024-01-09 13:11:39 +02:00
committed by GitHub
parent 1387541e33
commit af49e95cc7
90 changed files with 2671 additions and 668 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

View File

@@ -0,0 +1,238 @@
{
"name": "Hosted n8n AI Chat Manual",
"nodes": [
{
"parameters": {
"options": {}
},
"id": "e6043748-44fc-4019-9301-5690fe26c614",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1,
"position": [
860,
540
],
"credentials": {
"openAiApi": {
"id": "cIIkOhl7tUX1KsL6",
"name": "OpenAi account"
}
}
},
{
"parameters": {
"sessionKey": "={{ $json.sessionId }}"
},
"id": "0a68a59a-8ab6-4fa5-a1ea-b7f99a93109b",
"name": "Window Buffer Memory",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"typeVersion": 1,
"position": [
640,
540
]
},
{
"parameters": {
"text": "={{ $json.chatInput }}",
"options": {}
},
"id": "3d4e0fbf-d761-4569-b02e-f5c1eeb830c8",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.1,
"position": [
840,
300
]
},
{
"parameters": {
"dataType": "string",
"value1": "={{ $json.action }}",
"rules": {
"rules": [
{
"value2": "loadPreviousSession",
"outputKey": "loadPreviousSession"
},
{
"value2": "sendMessage",
"outputKey": "sendMessage"
}
]
}
},
"id": "84213c7b-abc7-4f40-9567-cd3484a4ae6b",
"name": "Switch",
"type": "n8n-nodes-base.switch",
"typeVersion": 2,
"position": [
300,
280
]
},
{
"parameters": {
"simplifyOutput": false
},
"id": "3be7f076-98ed-472a-80b6-bf8d9538ac87",
"name": "Chat Messages Retriever",
"type": "@n8n/n8n-nodes-langchain.memoryChatRetriever",
"typeVersion": 1,
"position": [
620,
140
]
},
{
"parameters": {
"options": {}
},
"id": "3417c644-8a91-4524-974a-45b4a46d0e2e",
"name": "Respond to Webhook",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1,
"position": [
1240,
140
]
},
{
"parameters": {
"public": true,
"authentication": "n8nUserAuth",
"options": {
"loadPreviousSession": "manually",
"responseMode": "responseNode"
}
},
"id": "1b30c239-a819-45b4-b0ae-bdd5b92a5424",
"name": "Chat Trigger",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"typeVersion": 1,
"position": [
80,
280
],
"webhookId": "ed3dea26-7d68-42b3-9032-98fe967d441d"
},
{
"parameters": {
"aggregate": "aggregateAllItemData",
"options": {}
},
"id": "79672cf0-686b-41eb-90ae-fd31b6da837d",
"name": "Aggregate",
"type": "n8n-nodes-base.aggregate",
"typeVersion": 1,
"position": [
1000,
140
]
}
],
"pinData": {},
"connections": {
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Window Buffer Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
},
{
"node": "Chat Messages Retriever",
"type": "ai_memory",
"index": 0
}
]
]
},
"Switch": {
"main": [
[
{
"node": "Chat Messages Retriever",
"type": "main",
"index": 0
}
],
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Chat Messages Retriever": {
"main": [
[
{
"node": "Aggregate",
"type": "main",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
]
]
},
"Chat Trigger": {
"main": [
[
{
"node": "Switch",
"type": "main",
"index": 0
}
]
]
},
"Aggregate": {
"main": [
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1"
},
"versionId": "425c0efe-3aa0-4e0e-8c06-abe12234b1fd",
"id": "1569HF92Y02EUtsU",
"meta": {
"instanceId": "374b43d8b8d6299cc777811a4ad220fc688ee2d54a308cfb0de4450a5233ca9e"
},
"tags": []
}

View File

@@ -1,245 +1,77 @@
{
"name": "AI Webhook Chat",
"name": "Hosted n8n AI Chat",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "513107b3-6f3a-4a1e-af21-659f0ed14183",
"responseMode": "responseNode",
"options": {
"domainAllowlist": "*.localhost"
}
},
"id": "51ab2689-647d-4cff-9d6f-0ba4df45e904",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1,
"position": [
900,
200
],
"webhookId": "513107b3-6f3a-4a1e-af21-659f0ed14183"
},
{
"parameters": {
"options": {}
},
"id": "3c7fd563-f610-41fa-b198-7fcf100e2815",
"name": "Chat OpenAI",
"id": "4c109d13-62a2-4e23-9979-e50201db743d",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1,
"position": [
1720,
620
640,
540
],
"credentials": {
"openAiApi": {
"id": "B5Fiv70Adfg6htxn",
"name": "Alex's OpenAI Account"
"id": "cIIkOhl7tUX1KsL6",
"name": "OpenAi account"
}
}
},
{
"parameters": {
"sessionKey": "={{ $json.body.sessionId }}"
"sessionKey": "={{ $json.sessionId }}"
},
"id": "ebc23ffa-3bcf-494f-bcb8-51a5fff91885",
"id": "b416df7b-4802-462f-8f74-f0a71dc4c0be",
"name": "Window Buffer Memory",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"typeVersion": 1,
"position": [
1920,
620
340,
540
]
},
{
"parameters": {
"simplifyOutput": false
},
"id": "d6721a60-159b-4a93-ac6b-b81e16d9f16f",
"name": "Memory Chat Retriever",
"type": "@n8n/n8n-nodes-langchain.memoryChatRetriever",
"typeVersion": 1,
"position": [
1780,
-40
]
},
{
"parameters": {
"sessionKey": "={{ $json.body.sessionId }}"
},
"id": "347edc3a-1dda-4996-b778-dcdc447ecfd8",
"name": "Memory Chat Retriever Window Buffer Memory",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"typeVersion": 1,
"position": [
1800,
160
]
},
{
"parameters": {
"options": {
"responseCode": 200,
"responseHeaders": {
"entries": [
{
"name": "sessionId",
"value": "={{ $json.body.sessionId }}"
},
{
"name": "Access-Control-Allow-Headers",
"value": "*"
}
]
}
}
},
"id": "d229963e-e2f1-4381-87d2-47043bd6ccc7",
"name": "Respond to Webhook",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1,
"position": [
2460,
220
]
},
{
"parameters": {
"dataType": "string",
"value1": "={{ $json.body.action }}",
"rules": {
"rules": [
{
"value2": "loadPreviousSession"
},
{
"value2": "sendMessage",
"output": 1
}
]
}
},
"id": "fc4ad994-5f38-4dce-b1e5-397acc512687",
"name": "Chatbot Action",
"type": "n8n-nodes-base.switch",
"typeVersion": 1,
"position": [
1320,
200
]
},
{
"parameters": {
"jsCode": "const response = { data: [] };\n\nfor (const item of $input.all()) {\n response.data.push(item.json);\n}\n\nreturn {\n json: response,\n pairedItem: 0\n};"
},
"id": "e1a80bdc-411a-42df-88dd-36915b1ae8f4",
"name": "Code",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
2160,
-40
]
},
{
"parameters": {
"text": "={{ $json.body.message }}",
"text": "={{ $json.chatInput }}",
"options": {}
},
"id": "f28f5c00-c742-41d5-8ddb-f0f59ab111a3",
"name": "Agent",
"id": "4de25807-a2ef-4453-900e-e00e0021ecdc",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1,
"typeVersion": 1.1,
"position": [
1780,
340
620,
300
]
},
{
"parameters": {
"jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n item.json.body = JSON.parse(item.json.body);\n}\n\nreturn $input.all();"
"public": true,
"options": {
"loadPreviousSession": "memory"
}
},
"id": "415c071b-18b2-4ac5-8634-e3d939bf36ac",
"name": "Transform request body",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"id": "5a9612ae-51c1-4be2-bd8b-8556872d1149",
"name": "Chat Trigger",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"typeVersion": 1,
"position": [
1120,
200
]
340,
300
],
"webhookId": "f406671e-c954-4691-b39a-66c90aa2f103"
}
],
"pinData": {},
"connections": {
"Webhook": {
"main": [
[
{
"node": "Transform request body",
"type": "main",
"index": 0
}
]
]
},
"Memory Chat Retriever": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"Memory Chat Retriever Window Buffer Memory": {
"ai_memory": [
[
{
"node": "Memory Chat Retriever",
"type": "ai_memory",
"index": 0
}
]
]
},
"Chatbot Action": {
"main": [
[
{
"node": "Memory Chat Retriever",
"type": "main",
"index": 0
}
],
[
{
"node": "Agent",
"type": "main",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
]
]
},
"Chat OpenAI": {
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Agent",
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
@@ -250,29 +82,23 @@
"ai_memory": [
[
{
"node": "Agent",
"node": "AI Agent",
"type": "ai_memory",
"index": 0
},
{
"node": "Chat Trigger",
"type": "ai_memory",
"index": 0
}
]
]
},
"Agent": {
"Chat Trigger": {
"main": [
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
]
]
},
"Transform request body": {
"main": [
[
{
"node": "Chatbot Action",
"node": "AI Agent",
"type": "main",
"index": 0
}
@@ -284,8 +110,8 @@
"settings": {
"executionOrder": "v1"
},
"versionId": "12c145a2-74bf-48b5-a87a-ba707949eaed",
"id": "L3FlJuFOxZcHtoFT",
"versionId": "6076136f-fdb4-48d9-b483-d1c24c95ef9e",
"id": "zaBHnDtj22BzEQ6K",
"meta": {
"instanceId": "374b43d8b8d6299cc777811a4ad220fc688ee2d54a308cfb0de4450a5233ca9e"
},