tunnel_farming_agent / tunnel_farming_agent.json
persadian's picture
init
953439a verified
{
"name": "Tunnel Farming Agent",
"nodes": [
{
"parameters": {
"options": {}
},
"id": "f9ffdee9-8b38-4bc2-a43f-e185a8341196",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1,
"position": [2180, 460],
"credentials": {
"openAiApi": {
"id": "xAeHxzxTT16sMdwS",
"name": "Backup OpenAI Account"
}
}
},
{
"parameters": {
"jsonMode": "expressionData",
"jsonData": "={{ $json.data || $json.text || $json.concatenated_data }}",
"options": {
"metadata": {
"metadataValues": [
{
"name": "=file_id",
"value": "={{ $('Download Text').item.json.metadata.file_id }}"
}
]
}
}
},
"id": "a3c7e1f6-aa1d-4714-b2c5-d75f24667bda",
"name": "Default Data Loader",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"typeVersion": 1,
"position": [2140, 1240]
},
{
"parameters": {
"model": "text-embedding-3-small",
"options": {}
},
"id": "e37e744c-bb04-46e1-a128-4d13e083d698",
"name": "Embeddings OpenAI",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"typeVersion": 1,
"position": [1920, 1300],
"credentials": {
"openAiApi": {
"id": "xAeHxzxTT16sMdwS",
"name": "Backup OpenAI Account"
}
}
},
{
"parameters": {
"name": "tunnel_farming_documents",
"description": "Contains all the tunnel farming documents for green pepper cultivation."
},
"id": "9d3559b7-c9de-4c2d-bc19-d2ca521c0338",
"name": "Retrieve Documents",
"type": "@n8n/n8n-nodes-langchain.toolVectorStore",
"typeVersion": 1,
"position": [1800, 360]
},
{
"parameters": {
"sessionIdType": "customKey",
"sessionKey": "={{ $('Prep Input Fields').item.json.session_id }}"
},
"id": "be640347-8482-4b77-b402-502db940e1ba",
"name": "Postgres Chat Memory",
"type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
"typeVersion": 1,
"position": [960, 580],
"credentials": {
"postgres": {
"id": "erIa9T64hNNeDuvB",
"name": "Prod Postgres account"
}
}
},
{
"parameters": {
"operation": "delete",
"tableId": "sensor_data",
"filterType": "string",
"filterString": "=metadata->>file_id=like.*{{ $json.file_id }}*"
},
"id": "2a601eb3-3c62-403a-86af-5abe5f926b89",
"name": "Delete Old Doc Rows",
"type": "n8n-nodes-base.supabase",
"typeVersion": 1,
"position": [920, 1000],
"credentials": {
"supabaseApi": {
"id": "hOLIm3Jeg9JcG616",
"name": "Prod Supabase account"
}
}
},
{
"parameters": {
"public": true,
"options": {}
},
"id": "ec94b853-13aa-46cb-98a3-16143137911b",
"name": "When chat message received",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"typeVersion": 1.1,
"position": [0, 0],
"webhookId": "15e4d662-3f98-48d0-9f50-68838769ecac"
},
{
"parameters": {
"httpMethod": "POST",
"path": "invoke-tunnel-farming-agent",
"authentication": "headerAuth",
"responseMode": "responseNode",
"options": {}
},
"id": "748f1c4f-013a-4e8f-861b-0c3daf754363",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [-500, 580],
"credentials": {
"httpHeaderAuth": {
"id": "o5akNgXQQR74Sezh",
"name": "Header Auth account"
}
}
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "9a9a245e-f1a1-4282-bb02-a81ffe629f0f",
"name": "query",
"value": "={{ {\n\"type\": \"human\",\n\"content\": $json.body.query,\n} }}",
"type": "string"
},
{
"id": "b80831d8-c653-4203-8706-adedfdb98f77",
"name": "user_id",
"value": "={{ $json.body.user_id }}",
"type": "string"
},
{
"id": "ea6f016e-2904-4701-8d8d-acabc83c705a",
"name": "request_id",
"value": "={{ $json.body.request_id }}",
"type": "string"
},
{
"id": "aca1a7d0-4b20-4b45-abb5-2c2d16c7e5f6",
"name": "session_id",
"value": "={{ $json.body.session_id }}",
"type": "string"
}
]
},
"options": {}
},
"id": "004fc62d-46f2-4a61-9c60-b8338429bf97",
"name": "Prep Input Fields",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [-220, 420]
},
{
"parameters": {
"tableId": "messages",
"fieldsUi": {
"fieldValues": [
{
"fieldId": "session_id",
"fieldValue": "={{ $json.session_id }}"
},
{
"fieldId": "message",
"fieldValue": "={{ JSON.parse($json.query) }}"
}
]
}
},
"id": "da69e927-1274-40bf-8ba5-e659be70a0f0",
"name": "Add User Message to DB",
"type": "n8n-nodes-base.supabase",
"typeVersion": 1,
"position": [40, 360],
"credentials": {
"supabaseApi": {
"id": "hOLIm3Jeg9JcG616",
"name": "Prod Supabase account"
}
}
},
{
"parameters": {
"promptType": "define",
"text": "={{ $('Prep Input Fields').item.json.query }}",
"options": {
"systemMessage": "You are a helpful and intelligent tunnel farming data analysis agent specializing in green pepper cultivation. Your goal is to assist in monitoring and optimizing tunnel farming operations on 8 hectares of land. Provide insights on soil health, irrigation, pest control, and yield optimization. Use the tools at your disposal to analyze real-time data and answer user queries."
}
},
"id": "7746d35e-0e93-4f0a-bed8-b5e3e3b70120",
"name": "Tunnel Farming Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.6,
"position": [1080, 240]
}
],
"connections": {
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Retrieve Documents",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Retrieve Documents": {
"ai_tool": [
[
{
"node": "Tunnel Farming Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Postgres Chat Memory": {
"ai_memory": [
[
{
"node": "Tunnel Farming Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "Prep Input Fields",
"type": "main",
"index": 0
}
]
]
},
"Prep Input Fields": {
"main": [
[
{
"node": "Add User Message to DB",
"type": "main",
"index": 0
}
]
]
},
"Add User Message to DB": {
"main": [
[
{
"node": "Tunnel Farming Agent",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1"
},
"id": "KzdWiRlX9PqcJOBh",
"tags": [
{
"id": "0tXJXfH2daB7QdK5",
"name": "tunnel-farming"
}
]
}