First of all, I apologize if this question has been asked before or if I missed an existing resource. I’m currently working with n8n and trying to process dynamic JSON data using the AI Agent node, then convert the structured output into an XLSX file.
However, I’m facing issues where the AI Agent doesn’t seem to recognize the incoming JSON properly. I’d appreciate any guidance or examples on:
How to correctly pass JSON to the AI Agent node.
Ensuring the structured output is formatted correctly.
The best way to generate an XLSX file from the processed data.
If anyone has experience with this or knows of a helpful tutorial/video, I’d be really grateful for your advice.
Thanks in advance, and again, my apologies if this has been covered before!
Hey @V_I - I am not a 100% sure from the screenshot you posted, but do you actually use the JSON of the “Information Extractor” Node in your prompt? You should use an expression for that and reference the JSON {{$json}} to give the agent the context. If you just want to build a table, I could imagine it’s easier to ask the model to output CSV and specify how your header maps to the JSON structure. Excel or google sheets can import CSV. For more help, it would be good if you can the workflow or relevant parts of it.
The task I am trying to solve is based on using LlamaIndex to parse a PDF file into .md format, then converting it into JSON. After that, I want to pass the JSON to an AI Agent, which will map the fields and generate a properly structured XLSX file as the final output.
In simple terms, the entire process is about transforming an uploaded PDF into a structured XLSX file.
I get the problem, but I can’t see what your agent node is doing. You said it doesn’t recognize the incoming JSON, but did you reference it? See here for details: Current node input | n8n Docs
thx your solution works, but the same result can be achieved simply by adding a “JSON to XLSX” node without using an AI agent. My problem is that I want to generate an XLSX file in a readable format, but the output I get is not properly formatted. That’s why I want to use an AI agent to correctly format the XLSX table.
That’s why I suggested asking the LLM to generate CSV. To my knowledge, for XLSX output, you need libraries because XLSX is a binary file format (technically a zipped XML structure). I don’t think an LLM will generate that reliably for you.
I don’t think It’s hard to solve. It’s just not a use case for an agent. Sorry if I confused you more. There is an older post about this so you could do this JSON to CSV or Spreadsheet
No, the LLM does not “see” the output parameter that is being passed to it.
I want to create a web app that accepts a PDF file and, after a prompt, outputs a formatted XLSX table. Using PDF parsing via Llama Index.