Hi everyone,
I’m currently experimenting with n8n’s AI Agent feature, and I’m facing an issue that I hope someone can help me with.
Goal:
I’m building a simple automation for learning purposes:
- A user sends a message via Twilio (e.g., “Create a Google Sheet called Meeting”).
- The AI Agent (using Groq as the model) receives the message and extracts the sheet name (“Meeting”).
- It should return a clean JSON object like this:
json
CopyEdit
{
"action": "createSpreadsheet",
"title": "Meeting"
}
- This JSON should go into the Google Sheets tool node to create the spreadsheet.
- Finally, I send a confirmation back to the user via Twilio.
The Problem:
The AI Agent isn’t outputting usable JSON. It often wraps the content in markdown/code blocks or includes extra explanation text — which breaks the Google Sheets node input.
What I’m Asking:
- How can I make the AI Agent return clean, raw JSON only, without code blocks or extra text?
- Is there a good way to parse or clean the output if needed?
- Any advice on structuring prompts or flow logic so it works smoothly with the Google Sheets tool?
I’m currently using Groq (DeepSeek) as the model, but I also have access to Google Gemini (PaLM) API if switching models could help.
Thanks in advance! Any guidance, examples, or best practices would be greatly appreciated.