Insert or update data in Postgres by AI agent

Hello everyone,

I’m trying to insert and update data on Postgres tables automatically using Postgres tools by AI agent, but I can’t set the input.

I wrote the prompt described my DB schema and asked the AI agent use tools to update, insert and select data in my DB. It works great for select operations, but for other operations the output from AI agent contents only parameters that determined as " Defined automatically by the model", for example:

{
“Table”: “employees”,
“Output_Columns”: “id, first_name, last_name, surname, telegram_id, telegram_url, phone, email, created_at, updated_at”,
“Skip_on_Conflict”: false,
“Replace_Empty_Strings_with_NULL”: false
}

And of course I have an error “Column ‘Table’ does not exist in selected table”. Other words it doesn’t contain the data that have to be insert or update.

Here’s my pipeline:

What I have to set up else to solve the problem?

  • n8n version: 1.80.3
  • Database (default: SQLite): Postgres
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Linux

From the system prompt you must teach the agent how to use the tools and what structure to send, for example:

Prompt:
I need you to directly generate a JSON like this to insert into the employees table:
{
“id”: 1,
“first_name”: “Juan”,
“last_name”: “Pérez”,
“surname”: “López”,
“telegram_id”: “123456”,
“telegram_url”: “Telegram: Contact @juan”,
“phone”: “123456789”,
“email”: “[email protected]”,
“created_at”: “2024-01-01T00:00:00.000Z”,
“updated_at”: “2024-01-01T00:00:00.000Z”
}

If you like, you can share the system and user prompt with me so I can help you.