Problem statement: I am using n8n to output the response of an AI Agent to Google Docs unformatted via an HTTP Request node POST request. I am struggling with the “text”: formatting. Either it’s not proper JSON, or my formatting causes n8n to not recognize the AI Agent node.
What is the error message (if any)? “JSON parameter needs to be valid JSON”
The UI shows n8n doing the text translation for the JSON Message body in the UI itself, but when I test, it says invalid JSON. in the JS expression, proper JSON, I believe is to escape what’s in quotes ' or ":
{
“requests”: [
{
“insertText”: {
“location”: {
“index”: 1
},
“text”: “{{ $node[‘AI Agent’].json[‘output’] }}”
}
}
]
}
Information on your n8n setup
n8n version: 1.91.2
**Database (default: SQLite):**default
n8n EXECUTIONS_PROCESS setting (default: own, main): default, I think
Running n8n via (Docker, npm, n8n cloud, desktop app): npm
Struggling a bit to translate that person’s shopify example into my example “InsertText” HTTP POST request: If I try to convert the whole this to js, n8n gives me invalid syntax… Note, I am a bit new to JSON and js, so I’m going to say that’s the issue. I think I’m way off with this example:
I think that shopify example and my lack of experience is confusing me. When you sav to convert the whole thing to an expression, I think that my example above is an attempt to do that, but I need some help with that given my lack of js experience…
@hubschrauber I went with Structure 1 - a simple correction to my mistakes in translating the JSON to JS and that worked with n8n and my agent. Thank you!