How to query a Supabase table with AI agent?

Hi there !

I’m on a personal portoflio project trying to set a AI-powered chatbot (Claude) able to answer question about my musical habits. I have a Supabase postgresql table named ‘tracks’ with all my spotify musical data history (more than 100k lines).

I’ve set up the workflow has you can see in the screenshot.
When I ask the agent to tell me which is the most listened artist for July 2025, the answer is totally out of context.
It seems the Agent doesn’t query the table and provide a randow answers.

As n8n no longer offers SQL Agent, can someone explain to me how to set an Agent which will query a table to make a precise answer ?

Thanks a lot !
William


(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.)

Information on your n8n setup

  • n8n version: 1.104.1
  • Database (default: SQLite): Supabase POSTGREsql
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Cloud
  • Operating system: Windows and Mac

Hey WLP - Do you have any visibility into the Claude interactions with the database? I’d be curious if the DB logs could help you figure out where it’s going wrong.
I’m not sure this is a good idea, but you could add some complexity with a workflow like this:

  1. Chat message
  2. Agent decides if chat request requires DB, writes new prompt to generate SQL Query.
  3. Agent generates SQL query.
  4. Code/set node to clean
  5. SQL query runs
  6. Data is returned to Agent to inform response to original chat.
    That’s problematic if the SQL query is messed up, but I’d wager Claude will be pretty reliable with that.
    I’m hoping someone else will have an idea with more brevity, but that’s what I could think of.

Thanks John, I’ll try your suggestion. DB logs don’t seem very useful from what I read. I’ll get back to you.
Cheers.

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