Cannot read properties of undefined (reading 'content') error

Hey, I’m going to collect data from the particular url by using tavily and record in Monday.com.
I tried everything I can do but “Cannot read properties of undefined (reading ‘content’)” this error keeps popping up.


https://jeseo.app.n8n.cloud/workflow/7xRs9evwdsahPkHw

1 Like

Hey,

I think because it has different chars, maybe using stringify() will help it,

{{ JSON.stringify($json.content) }}

Hopefully fixes the issue,

Best regards,

Samuel

Thank you for your help
I just tried but it didn’t work…

@Jeongmin_Seo your welcome, am wondering if it’s because of is it Chinese text? Do you get same issue with company instead of content? It seems the issue is the simple memory, do you need memory on the ai agent, you can try with postgres as memory for agent or without it? Do you get same error then?

Samuel

I changed the content and deleted the memory but it is still not working…

@Jeongmin_Seo

Hm okay see unrelated to the content, can u save workflow, and restart server, otherwise maybe have to look into config, not 100 percent sure why, but maybe help.

Samuel

still not working… thank you for your help!

Maybe disconnect the memory for now and try again.

From the screenshot the contect seems fine.

We can not enter to your workflow so maybe you can copy the workflow code and paste here

between the

paste here

I don’t know how to upload my JSON file so I will just copy and paste the file below.
Thank you so much for your help.

{
“name”: “Company Screener”,
“nodes”: [
{
“parameters”: {
“keepOnlySet”: true,
“values”: {
“string”: [
{
“name”: “challenge”,
“value”: “={{ $json.body.challenge }}”
}
]
},
“options”: {}
},
“id”: “defb6c08-7586-4af1-8b34-89d1ff936611”,
“name”: “Extract Challenge1”,
“type”: “n8n-nodes-base.set”,
“typeVersion”: 2,
“position”: [
-700,
260
]
},
{
“parameters”: {
“options”: {
“responseCode”: 200
}
},
“id”: “5c80ea9e-23c2-4195-996a-920538516ebc”,
“name”: “Respond to Webhook1”,
“type”: “n8n-nodes-base.respondToWebhook”,
“typeVersion”: 1,
“position”: [
-500,
260
]
},
{
“parameters”: {
“resource”: “boardItem”,
“operation”: “changeColumnValue”,
“boardId”: “2024127077”,
“itemId”: “=\n\n\n”,
“columnId”: “text_mkrmm69t”,
“value”: “={ "text": "{{ $json[‘employeeCount’] }}" }\n”
},
“type”: “n8n-nodes-base.mondayCom”,
“typeVersion”: 1,
“position”: [
520,
260
],
“id”: “fe484d1a-fb94-44f1-966f-9a4849da4d35”,
“name”: “Monday.com3”,
“credentials”: {
“mondayComApi”: {
“id”: “6R5FPdVaCKxBtmjT”,
“name”: “Monday.com account”
}
}
},
{
“parameters”: {
“httpMethod”: “POST”,
“path”: “company-info”,
“responseMode”: “responseNode”,
“options”: {}
},
“id”: “0dcdb2b2-aaee-4c42-8387-35274f4cde0c”,
“name”: “Webhook2”,
“type”: “n8n-nodes-base.webhook”,
“typeVersion”: 1,
“position”: [
-900,
260
],
“webhookId”: “company-info”
},
{
“parameters”: {
“resource”: “boardItem”,
“operation”: “get”,
“itemId”: “={{ $(‘Webhook2’).item.json.body.event.pulseId }}\n”
},
“type”: “n8n-nodes-base.mondayCom”,
“typeVersion”: 1,
“position”: [
-300,
260
],
“id”: “29521d88-ec41-4ecc-8656-016ad65e2a6b”,
“name”: “Monday.com”,
“credentials”: {
“mondayComApi”: {
“id”: “6R5FPdVaCKxBtmjT”,
“name”: “Monday.com account”
}
}
},
{
“parameters”: {
“jsCode”: “const name = $json.name || "unknown-company";\n\nconst slug = name\n .toLowerCase()\n .replace(/\s+/g, "-") // 공백은 하이픈으로\n .replace(/[^a-z0-9\-]/g, ""); // 특수문자 제거\n\nreturn [{\n json: {\n // AI Agent가 인식할 수 있도록 ‘content’ 또는 ‘chatInput’ 필드를 만들어서 \n // Prompt용 문자열(즉 "다음 URL에 접속해서 회사의 임직원 수를 숫자로만 추출해줘: https://thevc.kr/tossbank\”)을 그대로 넣어줍니다.\n content: Please visit the following URL and extract the number of employees from the company, as a numeric value only. : https://thevc.kr/${slug},\n // (기존에 필요했던 값들은 따로 필드로 남겨두셔도 되고 없어도 됩니다)\n company: name,\n url: https://thevc.kr/${slug},\n pulseId: $json.id\n }\n}];\n"
},
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
-80,
260
],
“id”: “777e58d7-f958-49fd-962d-cb15c5ab43d6”,
“name”: “Code”
},
{
“parameters”: {
“promptType”: “define”,
“text”: “={{ JSON.stringify($json.content) }}\n”,
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.agent”,
“typeVersion”: 2,
“position”: [
160,
260
],
“id”: “21650ea9-fe8e-433f-91a8-15533605e1fb”,
“name”: “AI Agent”
},
{
“parameters”: {
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.lmChatGroq”,
“typeVersion”: 1,
“position”: [
120,
420
],
“id”: “0e58426c-385c-4b69-a676-9ad172691d4c”,
“name”: “Groq Chat Model”,
“credentials”: {
“groqApi”: {
“id”: “wODehjE6Inv761R6”,
“name”: “Groq account”
}
}
},
{
“parameters”: {
“toolDescription”: “=다음 URL에 접속해서 회사의 임직원 수를 읽고 추출해줘: {{ $(‘Code’).item.json.url }}”,
“method”: “POST”,
“url”: “https://api.tavily.com/extract”,
“authentication”: “genericCredentialType”,
“genericAuthType”: “httpHeaderAuth”,
“sendHeaders”: true,
“headerParameters”: {
“parameters”: [
{
“name”: “Content-Type”,
“value”: “application/json”
}
]
},
“sendBody”: true,
“specifyBody”: “json”,
“jsonBody”: “={\n "urls": "{{ $(‘Code’).item.json.url }}",\n "include_images": false,\n "extract_depth": "basic",\n "format": "markdown"\n}”,
“options”: {}
},
“type”: “n8n-nodes-base.httpRequestTool”,
“typeVersion”: 4.2,
“position”: [
380,
420
],
“id”: “2902bc61-a6ff-417b-8310-8e42476dad32”,
“name”: “HTTP Request”,
“credentials”: {
“httpHeaderAuth”: {
“id”: “intSYm6njqcTM8Hg”,
“name”: “Auth”
}
}
}
],
“pinData”: {},
“connections”: {
“Extract Challenge1”: {
“main”: [
[
{
“node”: “Respond to Webhook1”,
“type”: “main”,
“index”: 0
}
]
]
},
“Respond to Webhook1”: {
“main”: [
[
{
“node”: “Monday.com”,
“type”: “main”,
“index”: 0
}
]
]
},
“Webhook2”: {
“main”: [
[
{
“node”: “Extract Challenge1”,
“type”: “main”,
“index”: 0
}
]
]
},
Monday.com”: {
“main”: [
[
{
“node”: “Code”,
“type”: “main”,
“index”: 0
}
]
]
},
“Code”: {
“main”: [
[
{
“node”: “AI Agent”,
“type”: “main”,
“index”: 0
}
]
]
},
“Groq Chat Model”: {
“ai_languageModel”: [
[
{
“node”: “AI Agent”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
},
“HTTP Request”: {
“ai_tool”: [
[
{
“node”: “AI Agent”,
“type”: “ai_tool”,
“index”: 0
}
]
]
},
“AI Agent”: {
“main”: [
[
{
“node”: “Monday.com3”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“active”: true,
“settings”: {
“executionOrder”: “v1”
},
“versionId”: “71c4a23a-2d23-4d7a-9e25-1869ba91bcf4”,
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “b816d84b77d0f761599fa33ee65edbf900590cf0113add7a5be9abad670d3aa2”
},
“id”: “7xRs9evwdsahPkHw”,
“tags”:
}

Try and reference the code node by name like this:

{{ $('Code').first().json.content }}

The error suggests that $json is undefined for some reason, even though it holds a value

Are you saying that copy that code into the AI Agent prompt?

I modify the code node a bit.

Please try this version will work or not

Because the original version working too on my end. So it’s quite weird.

Did you execute from the begining of the trigger?

It is not working…
Wait so in your workflow, when you add new item in your Monday.com, does this workflow automatically fill the employment count column?

Thank you for your help