How to update a table with fresh data on a fixed interval

Describe the problem/error/question

I am managing a self-service indoor tennis club. I have a booking platform which I use to manage the courts and the users. My club has two courts. I want to implement an AI chatbot on the website that answers users questions (from FAQ section) and also provides availability information for the courts without the need for users to login in the booking platform.
The AI agent for the chatbot is already configured to work with a Pinecone DB that have all the FAQs but I am struggling to make the Agent connect to the Booking API and properly get that free/busy information. That is why I decided to first make another flow that updates on a fixed interval a local n8n database with this information and then the agent to consume that information.

I am struggling with configuring this updates. The database should be very simple:
Column A: Time - 6:00, 6:30, 7:00, 7:30 …. until 21:30. (Our club works from 6 until 22 with possibility to book 30 minutes interval).
Column B: Court 1 - Fields should contain only Free/Busy information
Column C: Court 2 - Same as court 1

The upsert node should always update only the Free/Busy information and always start from the top (6:00 o`clock). One option is to overwrite the previous value another is to overwrite only if there is a change in the value. I am fine with both but the second option can be a problem because of the next note…

Note:
The data from API about the court booking should be normalized. Currently, the API return 0 if the court is free or an ID of the booking (anything different than 0) if the court is booked.
I tried to without normalization and to instruct the AI agent about what is what but it still very often return values from the table which can be very much confusing for the users.

So I will be grateful to hear from you how can I accomplish my goal. I am attaching a screenshot from my current workflow but note that at some point yesterday evening I was already frustrated and made some weird implementations :smiley:

What is the error message (if any)?

Please share your workflow

The spilt node is to separate the slots from 6 to 22.

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version: Latest docker image on Hostinger Provider
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker image on Hostinger Provider
  • Operating system: ubuntu 24.04

Hi @OgnyanGuglev and welcome to the forums. Is it possible to share your main workflow in a code block so we can see what your prompt looks like. By the sounds of it, it might be a lot simpler to just fix the tool calling to the http request instead of trying to sync data into yet another table.

Here is the code block. I also think it might be solved without db but I could find a way to attach HTTP request node to AI agent.

Thank you for your reply :slight_smile:

I meant, please can you share the workflow where your AI agent is?

Oh right ok, so your prompt is nowhere near complex and long enough to instruct the ai agent on how to work and which tools to call. Can you give me a few rules and behaviours you want your ai agent to do, then I can help you improve the prompt. You need a 1 to 2 page prompt to make this work well.

No, its not complex at all.

For now there are these two separation - if the user asks questions about the club (rules, registrations, and anything about how to play the agent should use Pinecone DB with information from the FAQ. For questions about courts availability (free/busy) registrations it should call the API and get the latest information about the courts bookings. I am not sure how to structure my prompts but I couldnt find HTTPrequest node that works with the AI agent. Therefor I cannot make the agent to authenticate and use the API. That is why I decided to split into two workflow and put the availability information in table which will be consumed by the AI agent

If you need to make more complex rest calls which might have some special auth requirement, simply create a sub workflow which does all this and then use the sub workflow in the agent. However you’ll need to create a prompt which instructs to agents in more detail. Rememer that these agents dont know what you want and how you want them to behave, so you need to give it instructions just like you would give a human who would be doing the same task. I can create a sample workflow if you need which you can then use as a template and just replace the parts you need from your side.

I would love to see how you would do it.