Notion n8n AI Agent - setting date filters

I’m building an AI Agent inside n8n that answers questions about customer meetings stored in a Notion database setup (Meetings DB, Customers DB, Projects DB, etc.). The purpose of the agent is to respond to user queries like:

  • “What was discussed in the last meeting with Client X?”
  • “When is the next project meeting for Project Y?”
  • “Summarize the meeting from July 10th for Customer Z”
  • “What’s the latest meeting note for [project/customer]?”

The agent uses dynamic filters (via expressions) to query the Notion Meetings DB via the Notion API. Depending on the user’s prompt, the agent is supposed to:

  • Detect whether the user is asking about a past, upcoming, or specific-dated meeting
  • Filter accordingly using on_or_before, on_or_after, or equals on the Meeting Date field
  • Apply optional filters like customer_id and project_id
  • Extract the matching meeting
  • Then use the resulting meeting ID to fetch and analyze the block content (notes) from that meeting

Now here’s the problem:

Even though the filtering logic works in theory, the agent does not reliably apply the correct temporal filter. For example, when I ask for the “last meeting”, it sometimes returns an upcoming meeting. Or when asking about “the next meeting”, it pulls one that already happened.

I’m passing the following fields into the agent:

  • meeting_date (either parsed from the user query or set to today’s date)
  • mode (e.g. past, future, exact) → which should guide the logic for date filtering

The body for the Notion DB query uses dynamic logic like this:

{
  "filter": {
    "and": [
      {
        "property": "Meeting Date",
        "date": {
          {{ $json.mode === "past" ? `
          "on_or_before": "${$json.meeting_date || new Date().toISOString().split('T')[0]}"
          ` : $json.mode === "exact" ? `
          "equals": "${$json.meeting_date}"
          ` : `
          "on_or_after": "${$json.meeting_date || new Date().toISOString().split('T')[0]}"
          ` }}
        }
      }
      ...
    ]
  },
  ...
}

But the logic doesn’t work reliably – and often the agent ends up using the wrong type of filter or gets confused about past vs. future. This leads to incorrect meeting retrieval.

What I need is a way to make the agent intelligently decide the right filter strategy based on user intent (past, future, or exact) – and consistently apply the correct date filter.

I also want to ensure that:

  • Only the correct meeting_page_id is passed into the block query (no reuse of outdated IDs)

It already works that I get the correct meeting id, customer id, project id, and meeting notes via notion blocks. But what is missing is that the date is correct.

Would appreciate ideas on how to structure the logic more robustly or whether anyone has solved a similar challenge with Notion + n8n + Agents.

Thanks in advance!

it is not pulling me meeting i had in the past (it only shows in the future) - this is probably because of the filter “ascending” no? but i need both - past and future meetings.

Hey @Luca2, hope all is well!

Could you provide the data for tests? The mock databases, which I could run queries against? Export to CSV and share if you can.

Hey, this is my meeting database:

I exported this database in notion via csv:


my main issue:
the filter (meeting date) is not working properly and it didnt get recognized by the ai agent.

What I mean by that is: I am filter inside my ai agent for meetings (ascending oder descending).

my ideal scenario: from the initial message it can see if the meeting is past or upcoming meeting. If yes it applies the correct filter and can check for meetings which were in the past or in the future (based on “Meeting Date” Property in notion).

but right now it only shows me either meetings in the past or in the future because of my filters.


my goal:
I ask the ai agent things like:

  • “What was discussed in the last meeting with Client X?”
  • “When is the next project meeting for Project Y?”
  • “Summarize the meeting from July 10th for Customer Z”
  • “What’s the latest meeting note for [project/customer]?”

then it filters for right customer or / and project id → this already works

and then it is checking for right meetings (this doesnt work) and then it check for input blocks for this meeting (this works already)

so the only issue that it can check for the right meetings.


this is my workflow

Ok, that’s too much to translate, I will do this on my own database. Below is my attempt at solving this:

Here is my chat with the agent:

All dates are correct based on my database so are the summaries.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.