AutomationFlowsData & Sheets › Text-to-sql: Receive Question

Text-to-sql: Receive Question

Text-to-SQL: Receive Question. Uses postgres. Webhook trigger; 5 nodes.

Webhook trigger★★★★☆ complexity5 nodesPostgres
Data & Sheets Trigger: Webhook Nodes: 5 Complexity: ★★★★☆ Added:

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "Text-to-SQL: Receive Question",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "nl-query",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "webhook1",
      "name": "Webhook - Receive Question",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "// Detect language (Hebrew vs English)\nconst question = $input.item.json.body.question;\nconst hebrewRegex = /[\\u0590-\\u05FF]/;\nconst language = hebrewRegex.test(question) ? 'he' : 'en';\n\n// Get environment from environment variable or default to devtest\nconst environment = $env.DEPLOYMENT_ENVIRONMENT || 'devtest';\n\n// Extract user info\nconst user_id = $input.item.json.body.user_id || 'anonymous';\n\nreturn {\n  question: question,\n  language: language,\n  environment: environment,\n  user_id: user_id\n};"
      },
      "id": "code1",
      "name": "Detect Language & Environment",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "-- Get schema information from target database\nSELECT jsonb_build_object(\n  'tables', json_agg(\n    jsonb_build_object(\n      'name', table_name,\n      'schema', table_schema\n    )\n  )\n) as schema_info\nFROM information_schema.tables\nWHERE table_schema = 'public'\n  AND table_type = 'BASE TABLE';",
        "options": {}
      },
      "id": "postgres1",
      "name": "Get Schema Info",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.4,
      "position": [
        650,
        300
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "insert",
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "sql_queue"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "question": "={{ $('Detect Language & Environment').item.json.question }}",
            "schema_info": "={{ $json.schema_info }}",
            "environment": "={{ $('Detect Language & Environment').item.json.environment }}",
            "language": "={{ $('Detect Language & Environment').item.json.language }}",
            "user_id": "={{ $('Detect Language & Environment').item.json.user_id }}",
            "status": "pending"
          }
        },
        "options": {
          "queryBatching": "independently"
        }
      },
      "id": "postgres2",
      "name": "Insert to Queue",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.4,
      "position": [
        850,
        300
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ {\n  \"job_id\": $json.job_id,\n  \"status\": \"pending\",\n  \"message\": $('Detect Language & Environment').item.json.language === 'he' \n    ? '\u05d1\u05e7\u05e9\u05ea\u05da \u05d4\u05ea\u05e7\u05d1\u05dc\u05d4 \u05d5\u05de\u05d5\u05e2\u05d1\u05e8\u05ea \u05dc\u05e2\u05d9\u05d1\u05d5\u05d3' \n    : 'Your request has been received and is being processed',\n  \"estimated_wait_seconds\": 300,\n  \"status_url\": `http://localhost:5678/webhook/nl-status/${$json.job_id}`\n} }}",
        "options": {}
      },
      "id": "respond1",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1050,
        300
      ]
    }
  ],
  "connections": {
    "Webhook - Receive Question": {
      "main": [
        [
          {
            "node": "Detect Language & Environment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Detect Language & Environment": {
      "main": [
        [
          {
            "node": "Get Schema Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Schema Info": {
      "main": [
        [
          {
            "node": "Insert to Queue",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert to Queue": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1",
  "id": "text-to-sql-receive",
  "tags": [
    {
      "createdAt": "2025-01-23T00:00:00.000Z",
      "updatedAt": "2025-01-23T00:00:00.000Z",
      "id": "1",
      "name": "text-to-sql"
    }
  ]
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Text-to-SQL: Receive Question. Uses postgres. Webhook trigger; 5 nodes.

Source: https://github.com/GalSened/text-to-sql-teams-bot/blob/2850aece4e7c0fd2ef2ca9211c0830ffffc51414/n8n-workflows/receive_question.json — original creator credit. Request a take-down →

More Data & Sheets workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Data & Sheets

CMM. Uses httpRequest, postgres, redis. Webhook trigger; 90 nodes.

HTTP Request, Postgres, Redis
Data & Sheets

Scraping. Uses httpRequest, postgres, @apify/n8n-nodes-apify, respondToWebhook. Webhook trigger; 61 nodes.

HTTP Request, Postgres, @Apify/N8N Nodes Apify
Data & Sheets

Workflow B — AI Listing Engine. Uses httpRequest, postgres, errorTrigger. Webhook trigger; 47 nodes.

HTTP Request, Postgres, Error Trigger
Data & Sheets

How it works

Postgres, Email Send
Data & Sheets

LogSentinel Workflow. Uses postgres, emailSend, httpRequest. Webhook trigger; 44 nodes.

Postgres, Email Send, HTTP Request