← All N8N workflows
AI & researchAgentChat TriggerConvert To FileExecute Workflow TriggerExtract From File

Translate questions about e-mails into SQL queries and run them

Configured with Agent, Chat Trigger, Convert To File, Execute Workflow Trigger, and additional nodes. Review the connections and setup before adapting this template.

Workflow preview
TransformAdd table name tooutputEdit FieldsTransformConvert data to binaryConvert To FileFiles / mediaSave file locallyRead Write FileTransformExtract data from fileExtract From FileTriggerChat TriggerChat TriggerTriggerWhen clicking "Testworkflow"Manual TriggerTransformCombine schema data andchat inputEdit FieldsFiles / mediaLoad the schema fromthe local fileRead Write FileTransformExtract SQL queryEdit FieldsRoutingCheck if query existsIfTransformFormat query resultsEdit FieldsTransformCombine query resultand chat answerMergeData storeList all columns in atablePostgresData storeList all tables in adatabasePostgresAI & modelsOllama Chat ModelLM Chat OllamaData storePostgresPostgresTransformAdd trailing semicolonEdit FieldsRoutingCheck for trailingsemicolonIfTriggerWorkflowTriggerExecute Workflow TriggerRoutingIf ran manuallyIfRoutingIf file exists oralready retried…IfAI & modelsAI AgentAgentTransformFormat empty outputEdit Fields

Node categories in this workflow

  • Transform
  • Files / media
  • Trigger
  • Routing
  • Data store
  • AI & models

Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.

Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.

How it works

The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.

Workflow node names, types, and operations
NodeCategoryTypeOperation
Add table name to outputTransformEdit FieldsSee node parameters
Convert data to binaryTransformConvert To FiletoJson
Save file locallyFiles / mediaRead Write Filewrite
Extract data from fileTransformExtract From FilefromJson
Chat TriggerTriggerChat TriggerSee node parameters
When clicking "Test workflow"TriggerManual TriggerSee node parameters
Combine schema data and chat inputTransformEdit FieldsSee node parameters
Load the schema from the local fileFiles / mediaRead Write FileSee node parameters
Extract SQL queryTransformEdit FieldsSee node parameters
Check if query existsRoutingIfSee node parameters
Format query resultsTransformEdit FieldsSee node parameters
Combine query result and chat answerTransformMergeSee node parameters
List all columns in a tableData storePostgresexecuteQuery
List all tables in a databaseData storePostgresexecuteQuery
Ollama Chat ModelAI & modelsLM Chat OllamaSee node parameters
PostgresData storePostgresexecuteQuery
Add trailing semicolonTransformEdit FieldsSee node parameters
Check for trailing semicolonRoutingIfSee node parameters
WorkflowTriggerTriggerExecute Workflow TriggerSee node parameters
If ran manuallyRoutingIfSee node parameters
If file exists or already retried generating itRoutingIfSee node parameters
AI AgentAI & modelsAgentSee node parameters
Format empty outputTransformEdit FieldsSee node parameters

Setup

  1. Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
  2. Connect your own credentials through n8n’s credential store. Replace REPLACE_WITH_* values with your resource identifiers.
  3. Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
  4. Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.

Requirements

An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.

Credential types declared in the source

None declared. HTTP requests and Code nodes may still need configuration.

Workflow notes

This can run manually

This can run manually

This section:

  • loads a list of all tables from the database
  • extracts the database schema for each table and adds the table name
  • converts the schema into a binary JSON format
  • saves the schema file locally
This is triggered by chat or as a sub-workflow

This is triggered by chat or as a sub-workflow

Natural language requests can be asked, and a SQL query as well as its results will be returned.

Quite the prompt 😅

Quite the prompt 😅

Some refined prompt engineering work here.

It may or may not been done aided by Kagi's Assistant and Claude 3.7 Sonnet 👀

Translate questions about e-mails into SQL queries and run them

Translate questions about e-mails into SQL queries and run them

Purpose and structure

This folder contains the Translate questions about e-mails into SQL queries and run them workflow. Its executable nodes use agent, chatTrigger, convertToFile, executeWorkflowTrigger, extractFromFile, if, lmChatOllama, manualTrigger, merge, postgres, readWriteFile, set. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.

Setup

Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.

Entry points

Chat Trigger, When clicking "Test workflow", WorkflowTrigger

Verification

Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.

Attribution

https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Postgres/1245_Postgres_Extractfromfile_Automation_Triggered.json MIT; preserve source notices.

More in AI & research