Help with n8n AI Agent + Notion: "Tomorrow" bug, update issue

Hey everyone,

I’ve built a pretty simple AI Agent in n8n using GPT-4 as the LLM, with basic memory and Notion Tools integrated.

The setup is:

  • Trigger: A message in a chat
  • Agent: Connects to GPT-4 ( brain )
    *** Basic memory
  • Tools:
    • Notion Search Tool (to access all databases)
    • Notion Write/Create Tool

Issue 1: The “Tomorrow” Bug

When I send a message like “Set up a meeting for tomorrow”, the AI creates an entry in Notion, but the date ends up being randomly set in October 2023 instead of the actual “tomorrow” from today. It’s super inconsistent and I can’t figure out why.

Anyone know why this is happening or how to make the agent or GPT correctly interpret relative dates?


Issue 2: Can’t Update Existing Entries

I want the agent to update entries in Notion, not just create new ones. When I add another Notion Tool to handle updates, the agent seems to ignore it and just creates a new entry instead. I’ve tried different configurations, but can’t get it to modify an existing one.

How do you configure the Notion update function correctly so that the AI knows which entry to update and doesn’t default to creating a new one?


Bonus Question: Leveling Up with n8n

Are there any good tutorials, guides, or workflows you recommend to take my n8n experience to the next level? Especially for working with AI Agents and integrations like Notion, Airtable, Emails ( not only gmail ) etc


If you’ve solved anything similar, I’d love your input. Even better if you’ve got a working example of an AI Agent using Notion for both creating and updating entries properly.

Thanks in advance! :pray:

1 Like

Hi @Ivy_Andersen,

You can use a code block to tell your ai agent what day it is. See the workflow below.

Best,
Robert

I’ve tried that approach, but the AI agent still gets lost after creating the entry. :frowning:

1 Like

Can you upload your workflow so I can take a look?

1 Like

@Ivy_Andersen

You need to include the date in the system message.

Hi @Ivy_Andersen,

Did this solution help you solve your issue?

Robert

I cracked it with a little help of AI after all. Here is the code that helped.

const input = $json.chatInput || “”;
const sessionId = $json.sessionId || ‘test-session’;

// Check if the input is intended to view meetings rather than create one.
// If the input contains keywords like “what”, “show”, or “list” followed by “meeting”
const viewMeetingPattern = /(what|show|list).*meeting/i;
if (viewMeetingPattern.test(input)) {
// For a view query, simply forward the original input to be handled downstream.
return [
{
json: {
chatInput: input, // Pass along the original query.
sessionId: sessionId,
intent: ‘view’
}
}
];
}

// Otherwise, assume the input is a command to create a meeting.

// Initialize days offset (relative to today)
let daysOffset = 0;
if (/in\s+(\d+)\s+days/i.test(input)) {
daysOffset = parseInt(input.match(/in\s+(\d+)\s+days/i)[1]);
} else if (/tomorrow/i.test(input)) {
daysOffset = 1;
}

// Calculate the meeting date.
const today = new Date();
let meetingDate = new Date(today);
if (daysOffset > 0) {
meetingDate.setDate(today.getDate() + daysOffset);
}
const dateString = meetingDate.toISOString().split(“T”)[0];

// Extract the meeting time (e.g., “at 19:00”)
const timeMatch = input.match(/at\s+(\d{1,2}:\d{2})/i);
const time = timeMatch ? timeMatch[1] : ‘09:00’;

// Extract the person’s name (assumes the word following “with”)
const personMatch = input.match(/with\s+(\w+)/i);
const person = personMatch ? personMatch[1] : ‘Unknown’;

// Build a structured message for meeting creation
const outputMessage = `Please create a meeting in Notion with the following details:

  • Person: ${person}
  • Date: ${dateString}
  • Time: ${time}
  • Location: Not specified
  • Topic: Not specified

Make sure the meeting is saved and confirmed. Do not ask for suggestions.`;

// Return the structured output for meeting creation.
return [
{
json: {
chatInput: outputMessage,
sessionId: sessionId,
intent: ‘create’
}
}
];

1 Like

yes and no at the same time. It helped me understand where the problem lays which was a good start. Thank you!

1 Like

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