AI Agent Code Tool - How to use data from other nodes?

This workflow has more nodes, but i didn’t include all. This workflow starts with a webhook.

I’m creating an AI chatbot flow that queries a Google Sheets spreadsheet and returns a R$ value for a date, example output:

{“14/07/2025”: {“Room A”: 150,“Room B”: 200,“Room C”: 300},
“15/07/2025”: {“Room A”:150,“Room B”: 200,“Room C”: 300},…

I’m using a “merge” to combine it with the customer’s message and some vars in this JSON, so I have something like:"

{
"nome": "John Doe",
"message": "Quais os valores dos quartos para o dia 15?",
"14/07/2025": {"Quarto A": 150,"Quarto B": 200,"Quarto C": 300},
"15/07/2025": {"Quarto A": 150,"Quarto B": 200,"Quarto C": 300},
...
}

Then, it should access an AI Agent node, which will interpret “the 15th” as 15/07/2025, use a Code Tool (built into the AI Agent node), and return the room values.

I expect the AI Agent node to:

  1. Interpret the customer’s message,
  2. Use the Code Tool node to fetch the values for each date,
  3. Return a customized message + the values per date.

I’m not using the JSON directly in the AI Agent because the input could have over 300 rows (one for each day of the year).

What should i do?

I assume that this date 15th to 15-7-2025 means of current month( if yes then give model current date input).
also you have description of code tool wrong change that and try it again.

Hey @Ferrgabe hope all is well, welcome to the community.

I would like to propose you use the sheet tool and let AI Agent figure out the rest, for example:

Our chat:

ME:
What is the price for the 15th?

AI:
Room prices for 15/07/2025:

Quarto A: $150
Quarto B: $200
Quarto C: $300



ME:
What are the prices for the first three days of the next week?

AI:
Room prices for the first three days of the next week (21/07/2025 to 23/07/2025):

21/07/2025 - Quarto A: $210, Quarto B: $260, Quarto C: $360
22/07/2025 - Quarto A: $220, Quarto B: $270, Quarto C: $370
23/07/2025 - Quarto A: $230, Quarto B: $280, Quarto C: $380



ME:
What about next weekend?

AI:
Room prices for next weekend (26/07/2025 - 27/07/2025):

26/07/2025 - Quarto A: $260, Quarto B: $310, Quarto C: $410
27/07/2025 - Quarto A: $270, Quarto B: $320, Quarto C: $420
Chat photo

1 Like

Hey @jabbson!

It worked, i didn’t know there was a Google Sheets Tool.

Thanks for your help!

Kindly mark the answer as solution if it was helpful with your question.

Have a good day!

1 Like