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, orequalson theMeeting Datefield - Apply optional filters like
customer_idandproject_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_idis 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.




