N8n AI agent filter specific informations for notion api request

I’m currently building an AI Agent workflow in n8n to retrieve tasks from a Notion database, filtered by project. The agent should allow users to ask questions like:

“What are the open tasks for the project ‘Webseiten’?”

The goal is that the AI interprets this input, identifies the project name (“Webseiten”), looks up the corresponding Notion page ID (via a custom tool called Get Project Page ID), and uses that ID to search for tasks in the Tasks DB (via a tool called Search inside Task DB).

All tools are connected properly, and the agent has access to the required memory, tools, and output parser. The logic inside the system prompt is well-defined and works when tested manually. Here’s how it’s structured in the prompt:

  1. Detect project names and retrieve the project ID using the tool Get Project Page ID.
  2. Pass the resulting ID to the tool Search inside Task DB, alongside a “done” status and optional deadline filters.
  3. Output a structured task list with titles, deadlines, project relation, etc.

Despite this logic working conceptually, I’m running into a critical issue:

Problem

The AI Agent does not pass any data into the Get Project Page ID tool.

Although the user input clearly contains the project name (“Webseiten”), the tool receives an empty input object ({}), and the internal expression {{ $json.project }} evaluates to undefined. As a result, the Project ID can’t be resolved, and all subsequent tools fail due to missing required filters (e.g. project_id).

My body for Http request: get project page ID:
{
“filter”: {
“property”: “Projektname”,
“rich_text”: {
“contains”: “{{ $json.project }}”
}
}
}

What I expect

I would expect the AI Agent to:

  1. Parse the user message correctly.
  2. Extract the project name (“Webseiten”).
  3. Use the Get Project Page ID tool and pass { "project": "Webseiten" } as input.
  4. Receive the correct page ID.
  5. Pass that ID into Search inside Task DB with the proper filter.

However, step 3 never happens because the input is missing entirely — even though it’s clearly required by the system prompt and mentioned in the user input.

My questions

  • Is this a bug or known limitation in how tools get called and filled via the AI Agent node?
  • Do I need to use special variable names or mappings to ensure the input gets passed?
  • Do I have to pre-declare the variable (e.g. project) elsewhere in the flow?

Any insights from the community would be super helpful, as this seems like a blocker for enabling more powerful, AI-driven workflows with tool chaining.


Information on my n8n setup

  • n8n version: 1.44.1 (n8n Cloud)
  • Database: Default (SQLite)
  • Execution Mode: own
  • Running via: n8n Cloud
  • Operating System: macOS (development), cloud-hosted (execution)

it is working that it shows me the open tasks of the database:

but the problem is that it is not applying the filter for search and the input is empty for “get project page id”

This is my take on the task:

Here is our chat:

Here is the database:

Thanks a lot for your help! This makes it more clear now.

But there is still one error I came accross.

If I want to filter for two criterias:
customer page id and project page id it is not working when only one filter is applied.
There is an error. It expects two filter inputs.

It only works when the initial message provides both: Customer and Project.

is there a workaround that it also work with only one or none filter?

Here is my workflow:

My filters:

When only one input is delivered (it appears an error):

There was nothing about customer page in your explanation, so I didn’t expect this to be a part of the equation. There were only projects and tasks.

the way to build a dynamic filter which takes zero or no filters would be either to teach AI agent to make JSON filters from natural language by explaining what operations are, what the format is, and how to combine them etc OR to get all records and explain the logic of filtering to the ai agent, like I did in my example - in natural language. The first is more bullet proof, but requires a good explanation of the filtering logic, the second is much easier to implement, but needs to pass more text to the model (read more tokens). Which one you prefer is for you to decide.

Hope it helps.

I see you created a separate topic for this question, so if any of the answer was helpful in this topic, please mark it as solution. Thanks you.

Cheers.