Automation library · Documents and files

Local document question answering with Ollama AI

Started by someone opening a chat with it, and works across Postgres. It puts OpenAI behind a retrieval step, so answers are drawn from documents you supply rather than from the model alone. 35 steps, 1 branch, 1 loop or waits: large, and worth reading before you trust it with anything live.

LargeCalls a model: OpenAIRetrieval

35 stepsLarge: read it before trusting it with anything live
1Branch: places the flow splits
1Loop or waits
1Service it connects to

The flow

Starts it 4Model 9Logic 6Service 16

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

  1. 1Postgres Chat MemoryMemory Postgres ChatModel
  2. 2When chat message receivedChat triggerStarts it
  3. 3WebhookWebhookStarts it
  4. 4Create Document Metadata TablePostgresService
  5. 5Create Document Rows Table (for Tabular Data)PostgresService
  6. 6List DocumentsPostgres ToolService
  7. 7Get File ContentsPostgres ToolService
  8. 8Query Document RowsPostgres ToolService
  9. 9Local File TriggerLocal File triggerStarts it
  10. 10Embeddings OllamaEmbeddings OllamaModel
  11. 11Embeddings Ollama1Embeddings OllamaModel
  12. 12Recursive Character Text SplitterText Splitter Recursive Character Text SplitterModel
  13. 13Ollama (Change Base URL)Lm Chat Open AiModel
  14. 14RAG AI AgentAgentModel
  15. 15Edit FieldsSetLogic
  16. 16Loop Over ItemsSplit In BatchesLogic
  17. 17Postgres PGVector StoreVector Store PGVectorModel
  18. 18Postgres PGVector Store1Vector Store PGVectorModel
  19. 19Default Data LoaderDocument Default Data LoaderModel
  20. 20Respond to WebhookRespond To WebhookStarts it
  21. 21Set File IDSetLogic
  22. 22Delete Old Doc RecordsPostgresService
  23. 23Delete Old Data RecordsPostgresService
  24. 24Insert Document MetadataPostgresService
  25. 25Read/Write Files from DiskRead Write FileService
  26. 26SwitchSwitchLogic
  27. 27Extract PDF TextExtract From FileService
  28. 28Extract from ExcelExtract From FileService
  29. 29Extract from CSVExtract From FileService
  30. 30Extract Document TextExtract From FileService
  31. 31AggregateAggregateLogic
  32. 32Insert Table RowsPostgresService
  33. 33SummarizeSummarizeService
  34. 34Set SchemaSetLogic
  35. 35Update Schema for Document MetadataPostgresService

How it's built

Starts on
Someone opening a chat with it
Steps
35, with 1 branch, 1 loop or waits
Size
Large: read it before trusting it with anything live
Connects to
Postgres
Model
OpenAI
Retrieval
Answers are drawn from documents you supply, not from the model alone

Questions

What does it need to run?

An n8n account, plus your own Postgres account, and a key for OpenAI. 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 OpenAI. Its answers draw on documents you give it, not on the model alone. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Take your time. At 35 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 35 steps before you point it at anything that matters.