Problem with Google Calendar and Postgres Memory

Hi, I’m building an AI that book clients for a barbershop. I have tools that check available time slots in a calendar, make bookings, modify them, and delete them. I also use a Postgres chat Memory

Now, here are the problems I’m facing:

  1. A client selects a time, for example, 12:00. Then they change it to 14:00, and later to 18:00. But when they want book 12:00, the AI remembers it from the chat history and says that 12:00 is already booked, even though it’s actually free on Google Calendar. AI check Postgres not the Google Calendar tools.
  2. Two clients ask if 12:00 is available. The bot replies that it is. Then, within about 5 minutes, both clients say “Book me for 12:00,” and the bot ends up booking both of them at the same time, without doing a double-check.

For 1st question. I think the prompt can be optimized to force them check the calendar first then use the memory.

For 2nd question. That’s kind of business and race condition issue.

You might need to take a time field to Millisecond to determine who book it first.

Maybe someone already solve this kind of situaion and glad to know how you solve this!

1 Like
  • Booking rules:

  • A client can only schedule an appointment once every three weeks.

  • Ask for the client’s full name and phone number when booking, and add this information to the calendar

  • If the client asks about a time that is already booked, simply inform them whether the time is available or not. Do not provide any additional information like: name phone number etc

  • If the client asks about rescheduling or changing or request/suggests a time for booking then you must use tool “Get Events” to check the availability of the requested time and inform the client if the time is available or not.

  • Before answer to client you must double-check Calendar, use tool “Get Events” for it and do not use for it the memory “Postgres Chat Memory”

  • Use “Find Events” to check Google Calendar for available booking times or slots.
    Before confirming any booking, always perform a fresh check of the current availability using “Find Events”.
    Do not rely on earlier availability checks in the conversation.
    Only confirm a booking if the time is still available at the moment of confirmation.
    Do not allow double-booking. Each time slot can only be assigned to one client.
    If a client requests a time that is already booked by someone else, politely inform them that the time is no longer available and suggest alternative available slots.

  • Calendar Management Tools :

    • Use “Create Event” for solo events.
    • Use “Find Events” to search for available booking times or time slots."
    • Use “Delete Event” to delete an event. You must use “Get Events” first to get the ID of the event to delete.
    • Use “Update Event” to update an event. You must use “Get Events” first to get the ID of the event to update.

my promt