Set node trouble

Why when the node set (Alimentacao IA) works does the user prompt give an error?

Desconected:

Conected:

My workflow:

{
“nodes”: [
{
“parameters”: {
“updates”: [
“messages”
],
“options”: {}
},
“type”: “n8n-nodes-base.whatsAppTrigger”,
“typeVersion”: 1,
“position”: [
-200,
280
],
“id”: “4c4117e3-7e63-4e3e-b475-4035d56b03fa”,
“name”: “Receptor de chate”,
“webhookId”: “806f4a09-5b0f-49e8-8e67-5f4fb03f2cd0”,
“credentials”: {
“whatsAppTriggerApi”: {
“id”: “jLLEXVSiymTmDI5g”,
“name”: “WhatsApp OAuth account”
}
}
},
{
“parameters”: {
“promptType”: “define”,
“text”: “={{ $json.messages[0].text.body }}”,
“options”: {
“systemMessage”: “=”
}
},
“type”: “@n8n/n8n-nodes-langchain.agent”,
“typeVersion”: 1.8,
“position”: [
420,
280
],
“id”: “fdb9f9c1-970b-49fb-bc33-d0af96e422db”,
“name”: “AI Agent”
},
{
“parameters”: {
“model”: {
“__rl”: true,
“value”: “gpt-4o-mini”,
“mode”: “list”,
“cachedResultName”: “gpt-4o-mini”
},
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.lmChatOpenAi”,
“typeVersion”: 1.2,
“position”: [
380,
480
],
“id”: “45ad8069-d884-40fb-9a62-bb5d536b5bb4”,
“name”: “OpenAI Chat Model”,
“credentials”: {
“openAiApi”: {
“id”: “47QO75bhLHAceAfD”,
“name”: “OpenAi account”
}
}
},
{
“parameters”: {
“sessionIdType”: “customKey”,
“sessionKey”: “={{ $(‘Receptor de chate’).item.json.contacts[0].wa_id }}”
},
“type”: “@n8n/n8n-nodes-langchain.memoryBufferWindow”,
“typeVersion”: 1.3,
“position”: [
520,
480
],
“id”: “610d7264-3ea8-49a1-bd37-0c9f1298bfcb”,
“name”: “Simple Memory”
},
{
“parameters”: {
“conditions”: {
“options”: {
“caseSensitive”: true,
“leftValue”: “”,
“typeValidation”: “strict”,
“version”: 2
},
“conditions”: [
{
“id”: “2094a61d-60f9-4aeb-9036-03344c14784b”,
“leftValue”: “={{ $json.messages[0].text.body }}”,
“rightValue”: “”,
“operator”: {
“type”: “string”,
“operation”: “exists”,
“singleValue”: true
}
}
],
“combinator”: “and”
},
“options”: {}
},
“type”: “n8n-nodes-base.if”,
“typeVersion”: 2.2,
“position”: [
80,
280
],
“id”: “b3f2c35c-57a1-48d5-9f56-9ed626103f91”,
“name”: “If”
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “eabc2954-1f24-4282-a4cc-0476a914f6f7”,
“name”: “Exemple”,
“value”: “abcdefghijklmnopqrstuvwxyz”,
“type”: “string”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
80,
80
],
“id”: “625c7941-2e54-4519-bb0a-d40a2a63a739”,
“name”: “Alimentacao IA”
},
{
“parameters”: {
“operation”: “send”,
“phoneNumberId”: “582181234982206”,
“recipientPhoneNumber”: “={{ $(‘If’).item.json.contacts[0].wa_id }}”,
“textBody”: “={{ $json.output }}”,
“additionalFields”: {}
},
“type”: “n8n-nodes-base.whatsApp”,
“typeVersion”: 1,
“position”: [
820,
220
],
“id”: “98679ac9-c4b9-4082-8246-49d4493c2585”,
“name”: “WhatsApp Business Cloud1”,
“webhookId”: “f3c2bbf3-8974-4971-ab7b-7aeaed19a3ff”,
“credentials”: {
“whatsAppApi”: {
“id”: “QZdPdsq29vDSG4Iv”,
“name”: “WhatsApp account”
}
}
}
],
“connections”: {
“Receptor de chate”: {
“main”: [
[
{
“node”: “If”,
“type”: “main”,
“index”: 0
}
]
]
},
“AI Agent”: {
“main”: [
[
{
“node”: “WhatsApp Business Cloud1”,
“type”: “main”,
“index”: 0
}
]
]
},
“OpenAI Chat Model”: {
“ai_languageModel”: [
[
{
“node”: “AI Agent”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
},
“Simple Memory”: {
“ai_memory”: [
[
{
“node”: “AI Agent”,
“type”: “ai_memory”,
“index”: 0
}
]
]
},
“If”: {
“main”: [
[
{
“node”: “AI Agent”,
“type”: “main”,
“index”: 0
}
]
]
},
“Alimentacao IA”: {
“main”: [
[
{
“node”: “AI Agent”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “830499f171848f15a469f0e9f9a863419688d34cef2f92af12f26fd8a2674645”
}
}

So the set node should probably be done in the same path. You will never be able to access that set node within a real execution. As the route is from WhatsApp trigger to if node, then to AI agent, theres no reverse.

I’ve tried several different ways and even this way it doesn’t work.

What do you mean by doesn’t work? You cannot access?

This error appears when I start:
{
“nodes”: [
{
“parameters”: {
“promptType”: “define”,
“text”: “={{ $json.messages[0].text.body }}”,
“options”: {
“systemMessage”: “={{ $json.Exemple }}”
}
},
“type”: “@n8n/n8n-nodes-langchain.agent”,
“typeVersion”: 1.8,
“position”: [
420,
280
],
“id”: “fdb9f9c1-970b-49fb-bc33-d0af96e422db”,
“name”: “AI Agent”
}
],
“connections”: {
“AI Agent”: {
“main”: [

]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “830499f171848f15a469f0e9f9a863419688d34cef2f92af12f26fd8a2674645”
}
}

This only happens when the node is a variable of the node set and placed in the “System Message”

The user message expression doesn’t exist in the previous nodes. Prompt value is red. That should be perhaps the whatsapp query instead, not what seems to be an attempt to access some kind of openai reply.

In your workflow you can: 1 start by whatsapp trigger OR start by Set node.
In last screenshot you need to refer to whatsapp by using {{ $(‘Receptor de chate’).item.json.message[0].text.body }}

$json.message[0].text.body is a valid sintax only if whatsapp is directly connected to AI, i mean this sintax refers to previous diretly connected node

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.