Automation library · Content

Email assistant: convert natural language to SQL queries

Started by someone opening a chat with it, and works across Postgres. It hands the judgement calls to a local model. 23 steps, 4 branches: large, and worth reading before you trust it with anything live.

LargeCalls a model: a local model

23 stepsLarge: read it before trusting it with anything live
4Branches: places the flow splits
0Loops or waits
1Service it connects to

The flow

Starts it 3Model 2Logic 11Service 7

The steps in the order they run, from what starts it.

  1. 1Chat TriggerChat triggerStarts it
  2. 2When clicking "Test workflow"Manual triggerStarts it
  3. 3Ollama Chat ModelLm Chat OllamaModel
  4. 4WorkflowTriggerExecute Workflow triggerStarts it
  5. 5Load the schema from the local fileRead Write FileService
  6. 6List all tables in a databasePostgresService
  7. 7AI AgentAgentModel
  8. 8If file exists or already retried generating itIfLogic
  9. 9List all columns in a tablePostgresService
  10. 10Extract SQL querySetLogic
  11. 11Extract data from fileExtract From FileService
  12. 12Add table name to outputSetLogic
  13. 13Check for trailing semicolonIfLogic
  14. 14Combine schema data and chat inputSetLogic
  15. 15Convert data to binaryConvert To FileService
  16. 16Add trailing semicolonSetLogic
  17. 17Check if query existsIfLogic
  18. 18Save file locallyRead Write FileService
  19. 19Combine query result and chat answerMergeLogic
  20. 20PostgresPostgresService
  21. 21Format empty outputSetLogic
  22. 22If ran manuallyIfLogic
  23. 23Format query resultsSetLogic

How it's built

Starts on
Someone opening a chat with it
Steps
23, with 4 branches
Size
Large: read it before trusting it with anything live
Connects to
Postgres
Model
a local model

Questions

What does it need to run?

An n8n account, plus your own Postgres account, and a key for a local model. You connect your own accounts after importing it; none are included.

What starts it?

It starts on someone opening a chat with it.

Does it use AI?

Yes. It calls a local model. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Take your time. At 23 steps it is large: read it before trusting it with anything live.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

Before you run it

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 23 steps before you point it at anything that matters.