Hi n8n community,
I’m working on a workflow to process emails for beauty salon appointments, and I’m stuck on an error in the HTTP Request node: “JSON parameter needs to be valid JSON.” I’d really appreciate any help!
My setup uses n8n with Postmark, ChatGPT 3.5, and Supabase. The workflow:
- A Webhook node receives emails from Postmark (e.g., to [email protected]).
- An HTTP Request node sends the email to ChatGPT to extract details (client name, service, date, etc.) as JSON.
- A Code node processes the response, and a Switch node routes based on appointment type (new, update, or cancel).
- Supabase nodes store the data.
The error happens when testing this email:
To: [email protected]
Body: Hola, Antonio Gomez quiere una cita para un corte de pelo el 12 de junio de 2025 a las 17:00. Su número es 123456789.
I think Spanish characters (like “ó” or “é”) in the email body are breaking the JSON in the HTTP Request node. Here’s the node’s setup:
{
“method”: “POST”,
“url”: “https://api.openai.com/v1/chat/completions”,
“authentication”: “predefinedCredentialType”,
“nodeCredentialType”: “openAiApi”,
“sendHeaders”: true,
“specifyHeaders”: “json”,
“jsonHeaders”: “{"Content-Type": "application/json"}”,
“sendBody”: true,
“specifyBody”: “json”,
“jsonBody”: “{\n "model": "gpt-3.5-turbo",\n "messages": [\n {\n "role": "system",\n "content": "Eres un asistente experto en analizar correos electrónicos de citas… [prompt to extract JSON with fields like codigo_centro, nombre, telefono, etc.]"\n },\n {\n "role": "user",\n "content": "Destinatario (To): {{ $node[‘Webhook’].json.body.To || ‘unknown’ }}\nCuerpo del correo: {{ $node[‘Webhook’].json.body.TextBody || $node[‘Webhook’].json.body.HtmlBody || ‘No body available’ }}"\n }\n ],\n "temperature": 0.3,\n "max_tokens": 500\n}”
}
What I’ve tried:
Validated the JSON in a linter (looks fine without dynamic data).
Removed accents (e.g., “cita” to “cita”), which sometimes works, but real emails will have Spanish characters.
Tested a simpler email, but special characters still cause the error.
Questions:
How do I handle Spanish characters in the email body to avoid JSON errors?
Should I add a Code node to clean the Webhook output before ChatGPT?
Any tips for n8n + OpenAI API to prevent JSON issues?
Happy to share more details if needed. Thanksl.
n8n: Hosted on AWS ECS Fargate (n8nio/n8n:1.0.0).
Webhook URL: http://52.212.47.51:5678/postmark-inbound.