Apologies & Help Needed – n8n AI Agent Node with Dynamic JSON to XLSX

Hi everyone,

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:

  1. How to correctly pass JSON to the AI Agent node.
  2. Ensuring the structured output is formatted correctly.
  3. 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!


Information on your n8n setup

  • n8n version:
    1.78.1

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

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


Do you mean this? When isert the parameter {{ $json.output }} in the prompt, the agent still does not see the JSON.

OK, that’s strange, maybe you can try like this. So set your instructions as system message in options. Pass your JSON as user message

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.

in your solution i have that output

1 Like

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.

Is my problem really that difficult to solve? I can’t resolve it myself because I only recently started learning n8n and AI agents.

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.