JSON Code not parsing

Describe the problem/error/question: I am having issues with the HTTP Request (POST) to have my AI Agent reply messages in my business page messenger. It is parsing only 1 of 2 variables, it parses de Sender ID but it does not work with the output of the AI Agent response variable.

What is the error message (if any)? JSON parameter needs to be valid JSON

Please share your workflow {

“nodes”: [
{
“parameters”: {
“method”: “POST”,
“url”: “=https://graph.facebook.com/v23.0/{{ $(‘Webhook’).item.json.body.entry[0].messaging[0].sender.id }}/messages?access_token=EAAIoj9kkcksBO67oPogLdcoZChF5ucjOAmpL3xXIjVxINClrgTxZB012uUiN8koqtSMjGRvDxY17VvBZA007iMTu5XjJhoGoq7aCnoYAdpDc5bKSjhI5okcBkCr53ZBhH7XGyOZAHbW1hGZAN97TtiFRy903SHknwixzo9uOgdyuPtlXGESKyOmg3BzaA3K4qPVqFYhE3sdQZDZD”,
“sendBody”: true,
“specifyBody”: “json”,
“jsonBody”: “={\n "recipient": {\n "id": "{{ $(‘Webhook’).item.json.body.entry[0].messaging[0].sender.id }}"\n },\n "messaging_type": "RESPONSE",\n "message": {\n "text": "{{ $json.output }}"\n }\n}”,
“options”: {}
},
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.2,
“position”: [
580,
240
],
“id”: “501e805b-e6e3-44c4-9308-6981fe8b83b7”,
“name”: “HTTP Request”
}
],
“connections”: {},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “270427af964f4be02992a919bf4be11cc2bad6dc44b61ac3c637eec5462441c7”
}
}

Share the output returned by the last node

JSON parameter needs to be valid JSON

Asked

Error details

Other info

Item Index

0

Node type

n8n-nodes-base.httpRequest

Node version

4.2 (Latest)

n8n version

1.100.1 (Cloud)

Time

7/2/2025, 12:58:54 PM

Stack trace

NodeOperationError: JSON parameter needs to be valid JSON at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@[email protected]_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts:366:15) at WorkflowExecute.runNode (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@[email protected][email protected][email protected][email protected]_/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1193:32) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@[email protected][email protected][email protected][email protected]_/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1542:38 at processTicksAndRejections (node:internal/process/task_queues:105:5) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@[email protected][email protected][email protected][email protected]_/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:2108:11

HTTP Request

Execute step

Parameters

Settings


Docs

Import cURL

Method

Fixed

Expression

URL

Fixed

Expression

https://graph.facebook.com/v23.0/{{ $(‘Webhook’).item.json.body.entry[0].messaging[0].sender.id }}/messages?access_token=EAAIoj9kkcksBO67oPogLdcoZChF5ucjOAmpL3xXIjVxINClrgTxZB012uUiN8koqtSMjGRvDxY17VvBZA007iMTu5XjJhoGoq7aCnoYAdpDc5bKSjhI5okcBkCr53ZBhH7XGyOZAHbW1hGZAN97TtiFRy903SHknwixzo9uOgdyuPtlXGESKyOmg3BzaA3K4qPVqFYhE3sdQZDZD

https://graph.facebook.com/v23.0/30798630063084423/messages?access_token=EAAIoj9kkcksBO67oPogLdcoZChF5ucjOAmpL3xXIjVxINClrgTxZB012uUiN8koqtSMjGRvDxY17VvBZA007iMTu5XjJhoGoq7aCnoYAdpDc5bKSjhI5okcBkCr53ZBhH7XGyOZAHbW1hGZAN97TtiFRy903SHknwixzo9uOgdyuPtlXGESKyOmg3BzaA3K4qPVqFYhE3sdQZDZD

Authentication

Send Query Parameters

Send Headers

Send Body

Body Content Type

Fixed

Expression

Specify Body

Fixed

Expression

JSON

Fixed

Expression

{

“recipient”: {

“id”: “{{ $(‘Webhook’).item.json.body.entry[0].messaging[0].sender.id }}”

},

“messaging_type”: “RESPONSE”,

“message”: {

“text”: “{{ $json.output }}”

}

}

{ “recipient”: { “id”: “30798630063084423” }, “messaging_type”: “RESPONSE”, “message”: { “text”: “¡Hola! ¡Bienvenido/a a nuestra Agencia de IA! Nos especializamos en ofrecer servicios de Inteligencia Artificial, automatización de procesos, desarrollo de SOPs (Procedimientos Operativos Estándar) y capacitación para ayudar a las empresas a optimizar sus operaciones y crecer. ¿En qué puedo ayudarte hoy? ¿Estás interesado/a en conocer más sobre alguno de nuestros servicios o tienes alguna necesidad específica que podamos abordar?” } }

Options

No properties

You can view the raw requests this node makes in your browser’s developer console

I wish this node would…

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite): Default
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • **Running n8n via (Docker, npm, n8n cloud, desktop app): n8n cloud
  • Operating system: Windows 11 Home Single Language