i m using n8n on localhost via nodejs, i m trying to generate the times zone for the places based on the input & then geenrate a single csv file having these timezones in each row and using basicllm & free model in the chatbot for it, but it gives me “error”: “Cannot read properties of undefined (reading ‘message’)” and fails the llm m not getting the desired output from it ,
{
"name": "find timezone",
"nodes": [
{
"parameters": {
"batchSize": 5,
"options": {
"reset": false
}
},
"id": "9d581765-cfbb-4815-ac0b-4a1007e10672",
"name": "Split In Batches",
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 1,
"position": [
-180,
295
],
"alwaysOutputData": false
},
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
-840,
295
],
"id": "fad341bf-c0f4-46a6-ab14-ff00a93a6d64",
"name": "When clicking ‘Test workflow’"
},
{
"parameters": {
"options": {
"delimiter": ","
}
},
"type": "n8n-nodes-base.extractFromFile",
"typeVersion": 1,
"position": [
-400,
295
],
"id": "a678ec6d-8bd6-4410-b05f-b08fe30566b8",
"name": "Extract from File"
},
{
"parameters": {
"fileSelector": "P:/places.csv",
"options": {
"dataPropertyName": "data"
}
},
"type": "n8n-nodes-base.readWriteFile",
"typeVersion": 1,
"position": [
-620,
295
],
"id": "a0f6f571-4d8b-434a-86e0-2c897cc67bf7",
"name": "Read/Write Files from Disk"
},
{
"parameters": {
"operation": "toFile",
"fileFormat": "csv",
"binaryPropertyName": "={{ $json.output.Timezone }}",
"options": {
"fileName": "P:/timezone.csv"
}
},
"name": "Spreadsheet File1",
"type": "n8n-nodes-base.spreadsheetFile",
"typeVersion": 1,
"position": [
1100,
100
],
"id": "b7808fec-dacd-4da7-aaea-8ed29f9aa439"
},
{
"parameters": {
"options": {}
},
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 3,
"position": [
60,
20
],
"id": "7f198072-90f4-4592-8a40-bdc0e9802465",
"name": "Loop Over Items"
},
{
"parameters": {
"promptType": "define",
"text": "=state: {{ $json.state }}",
"hasOutputParser": true,
"messages": {
"messageValues": [
{
"message": "=You are an intelligent assistant well versed with geography. Based on the state given to you by user or human in prompt, find the GMT time zone applicable to it.\n\n#Input\nstate: {{ $json.state || \"Unknown Location\" }}\n\n#Output\n{\n \"Timezone\": \"\"\n}\n\nYour response must strictly follow the JSON format above with the Timezone field properly filled in. The Timezone should be expressed as a string with the GMT offset (e.g., \"+5.5\", \"-4\", \"+0\").\n\nExample 1:\n#Input\n\"Pune\"\n\n#Output\n{\n \"Timezone\": \"+5.5\"\n}\n\nExample 2:\n#Input\n\"Maharashtra\"\n\n#Output\n{\n \"Timezone\": \"+5.5\"\n}\n\nExample 3:\n#Input\n\"India\"\n\n#Output\n{\n \"Timezone\": \"+5.5\"\n}\n\nAlways return valid JSON format that can be parsed by n8n. Do not include any explanatory text outside of the JSON structure.\n\n"
}
]
}
},
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"typeVersion": 1.6,
"position": [
480,
20
],
"id": "5ae7cb93-2811-461b-92e7-8e160807db75",
"name": "Basic LLM Chain",
"retryOnFail": true,
"onError": "continueRegularOutput"
},
{
"parameters": {
"jsonSchemaExample": "{ \n \"Timezone\": \"\"\n}"
},
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"typeVersion": 1.2,
"position": [
680,
240
],
"id": "d01a9361-5793-482a-aaad-511f78eab8e7",
"name": "Structured Output Parser"
},
{
"parameters": {
"model": "nvidia/llama-3.3-nemotron-super-49b-v1:free",
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
"typeVersion": 1,
"position": [
480,
300
],
"id": "555f6e2d-fdab-4e8f-8021-08658700dd29",
"name": "OpenRouter Chat Model",
"credentials": {
"openRouterApi": {
"id": "YCRLuvBrVkvzzjz4",
"name": "openrouter chat bot"
}
}
},
{
"parameters": {
"jsCode": "// Get the raw input string from the 'places' node\nconst input = $json.place || \"\";\n\n// Split by comma\nconst parts = input.split(', ').map(p => p.trim());\n\n// Extract city and state\nconst city = parts[0] || \"\";\nconst state = parts[1] || \"\";\n\n// Return formatted JSON\nreturn [\n {\n json: {\n city,\n state\n }\n }\n];\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
120,
300
],
"id": "3689318c-3c6e-4525-b0d7-f6426577802c",
"name": "Code1"
},
{
"parameters": {
"mode": "combine",
"combineBy": "combineByPosition",
"options": {}
},
"type": "n8n-nodes-base.merge",
"typeVersion": 3.1,
"position": [
880,
120
],
"id": "9e62f0b0-bf3a-4fcb-9e35-58c2e9b03942",
"name": "Merge"
},
{
"parameters": {
"amount": 1
},
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [
856,
345
],
"id": "68e49ccc-e3b1-4f31-919a-bf17d3f1dc23",
"name": "Wait",
"webhookId": "0558c280-85d4-4720-a198-f5934422989b"
}
],
"pinData": {},
"connections": {
"Split In Batches": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"When clicking ‘Test workflow’": {
"main": [
[
{
"node": "Read/Write Files from Disk",
"type": "main",
"index": 0
}
]
]
},
"Read/Write Files from Disk": {
"main": [
[
{
"node": "Extract from File",
"type": "main",
"index": 0
}
]
]
},
"Extract from File": {
"main": [
[
{
"node": "Split In Batches",
"type": "main",
"index": 0
}
]
]
},
"Spreadsheet File1": {
"main": [
[]
]
},
"Loop Over Items": {
"main": [
[],
[
{
"node": "Code1",
"type": "main",
"index": 0
},
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "Basic LLM Chain",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"OpenRouter Chat Model": {
"ai_languageModel": [
[
{
"node": "Basic LLM Chain",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Basic LLM Chain": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
},
{
"node": "Wait",
"type": "main",
"index": 0
}
]
]
},
"Code1": {
"main": [
[
{
"node": "Basic LLM Chain",
"type": "main",
"index": 0
}
]
]
},
"Merge": {
"main": [
[
{
"node": "Spreadsheet File1",
"type": "main",
"index": 0
}
]
]
},
"Wait": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "0a58e663-08ff-4060-9d75-62c8e09afb8a",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "7e17052359c1df516e7f3a27dabc5631cbc7be8e742a6f1a2871050b378afa67"
},
"id": "5HkRVIR4XH4IGgmQ",
"tags": []
}`