Describe the problem/error/question
I have tried this a thousand times and gave up. I want the format described in StructuredOutputParser to be the one saved in the MongoDB.
Currently the object saved in MongoDB is messy and impossible to read
What is the error message (if any)?
MongoDB gets a object that is impossible to read.
Looks like this
**
_id**
:
ObjectId(‘69420e0156ed567871fee5c5’)
{“Doors are not closing all the way”:"This problem occurs when doors do not latch or close fully
:
null
leading to security
:
null
energy efficiency
:
null
and usability issues."
:
null
“possible causes”:[“Misaligned door hinges”
:
null
“Warped door frame or door leaf”
:
null
“Obstruction in door frame or latch”
:
null
“Faulty or worn-out latch mechanism”
:
null
“Loose screws or hardware”
:
null
“Swelling caused by moisture”]
:
null
“tools”:[“Screwdriver”
:
null
“Hammer”
:
null
“Plane or sandpaper”
:
null
“Measuring tape”
:
null
“Level”
:
null
“Lubricant”
:
null
“Replacement hinges or latch”]
:
null
“steps”:[“Inspect door alignment and hinges for misalignment.”
:
null
“Tighten loose screws or replace faulty hardware.”
:
null
“Check door frame and door leaf for warping or swelling.”
:
null
“Plane or sand down door edges if swollen.”
:
null
“Remove obstructions from the door frame or latch area.”
:
null
“Lubricate hinges and latch mechanism.”
:
null
“Adjust or replace hinges and latch to ensure proper closing.”]}
:
null
Please share your workflow
{
"nodes": [
{
"parameters": {
"promptType": "define",
"text": "=Role: You are a smart property rental maintenance analyzer. you use {{ $json.title }} and {{ $json.description }} from GoogleSheetsTrigger to describe the problem, analysis the causes, describe the tools needed to fix the problem and provide the steps to solve the problem.\n\nTask: use OpenAI to look for information about the issue described in {{ $json.title }} and {{ $json.description }}. Describe the problem, list the potential causes, list the tools needed to fix the problem and describe the steps to fix it. \n\nInput: You have access to the following:\n - OpenAI. Use {{ $json.title }} and {{ $json.description }} from GoogleSheetsTrigger and retrieve the information. Ask OpenAI to produce a JSON output with the next properties: {{ $json.title }}, {{ $json.description }}, possible causes, tools and steps to fix it.\n - StructuredOutputParser. Use to parse output from OpenAI. Use this output for the step insertMongoDB.\n - sendGmail this is used to populate the results found in OpenAI and send the email. Use the JSON output from OpenAI\n - insertMongoDB use this to insert output from StructuredOutputParser in JSON format. Use the JSON format created in step StructuredOutputParser output to store the information.\n\nTools: Use Only these tools to perform your reasoning and take action\n\t- OpenAI Return output of the analysis in JSON format\n\t- sendGmail send the final search result \n - StructuredOutputParser to format the output in JSON format\n - insertMongoDB insert document in the database using the JSON format from StructuredOutputParser\n",
"hasOutputParser": true,
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3,
"position": [
496,
-48
],
"id": "38f9f6fd-b1e5-4cfb-a29f-2da5031eb5ae",
"name": "AI Agent",
"alwaysOutputData": true
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {
"responseFormat": "json_object"
}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [
-16,
256
],
"id": "e9570fe1-d987-4db5-894b-7a4c3f240ac0",
"name": "OpenAI",
"credentials": {
"openAiApi": {
"id": "gzRaCcNCpsNWkSWA",
"name": "OpenAi account"
}
}
},
{
"parameters": {
"sessionIdType": "customKey",
"sessionKey": "trail-run-session",
"contextWindowLength": 3
},
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"typeVersion": 1.3,
"position": [
400,
208
],
"id": "fd423851-d3ff-463a-9e29-661a34efed8e",
"name": "Simple Memory"
},
{
"parameters": {
"sendTo": "[email protected]",
"subject": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Subject', ``, 'string') }}",
"message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
"options": {}
},
"type": "n8n-nodes-base.gmailTool",
"typeVersion": 2.1,
"position": [
480,
368
],
"id": "4202d535-3273-48f2-a14d-7760fc8b7b34",
"name": "sendGmail",
"webhookId": "c89b5969-031e-4bbc-bccf-c263459cca3b",
"credentials": {
"gmailOAuth2": {
"id": "dGozEELVB9Rfxq5S",
"name": "Gmail account"
}
}
},
{
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"title\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"description\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n \"Tools Needed\": {\n \"type\": \"string\"\n },\n \"Steps to Fix\": {\n \"type\": \"string\"\n },\n \"Result\": {\n \"type\": \"string\"\n }\n\t}\n}",
"autoFix": true
},
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"typeVersion": 1.3,
"position": [
912,
96
],
"id": "55a44865-ed29-4d6d-815f-77a6727a442c",
"name": "StructuredOutputParser"
},
{
"parameters": {
"pollTimes": {
"item": [
{
"mode": "everyMonth"
}
]
},
"documentId": {
"__rl": true,
"value": "1bIParwXdYes57_Mf_aSYBFYew7w0vNeXUk26AlTByXI",
"mode": "list",
"cachedResultName": "seralehousingai",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bIParwXdYes57_Mf_aSYBFYew7w0vNeXUk26AlTByXI/edit?usp=drivesdk"
},
"sheetName": {
"__rl": true,
"value": "gid=0",
"mode": "list",
"cachedResultName": "Sheet1",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bIParwXdYes57_Mf_aSYBFYew7w0vNeXUk26AlTByXI/edit#gid=0"
},
"event": "rowAdded",
"options": {}
},
"type": "n8n-nodes-base.googleSheetsTrigger",
"typeVersion": 1,
"position": [
208,
0
],
"id": "19bf56a7-2539-45dd-bd55-41903ffc9ba5",
"name": "GoogleSheetsTrigger",
"credentials": {
"googleSheetsTriggerOAuth2Api": {
"id": "dcIGgwzqgknV5rnU",
"name": "Google Sheets Trigger account"
}
}
},
{
"parameters": {
"operation": "insert",
"collection": "resultsai",
"fields": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Fields', ``, 'string') }}",
"options": {
"dateFields": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Date_Fields', ``, 'string') }}"
}
},
"type": "n8n-nodes-base.mongoDbTool",
"typeVersion": 1.2,
"position": [
896,
352
],
"id": "efe06177-f184-4262-8550-39e9d958b060",
"name": "InsertMongoDB",
"credentials": {
"mongoDb": {
"id": "98cFwwPIV43k1nCL",
"name": "MongoDB account"
}
}
}
],
"connections": {
"AI Agent": {
"main": [
[]
]
},
"OpenAI": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
},
{
"node": "StructuredOutputParser",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Simple Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"sendGmail": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"StructuredOutputParser": {
"ai_outputParser": [
[
{
"node": "AI Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"GoogleSheetsTrigger": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"InsertMongoDB": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
}
},
"pinData": {},
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "070183e3175c0dc97889891db9828b8f76ef8283ce9a0b5fd40bd8e8fb60ed73"
}
}
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
Share the output returned by the last node
{
“type”: “object”,
“properties”: {
“title”: {
“type”: “string”
},
“description”: {
“type”: “string”
},
“Tools Needed”: {
“type”: “string”
},
“Steps to Fix”: {
“type”: “string”
},
“Result”: {
“type”: “string”
}
}
}
Information on your n8n setup
- n8n version:
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app):
- Operating system: