AutomationFlowsData & Sheets › Webhook - Mysql Logger

Webhook - Mysql Logger

Webhook - MySQL Logger. Uses mySql. Webhook trigger; 7 nodes.

Webhook trigger★★★★☆ complexity7 nodesMySQL
Data & Sheets Trigger: Webhook Nodes: 7 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": "Webhook - MySQL Logger",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "webhook-mysql-logger",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "02-webhook-trigger",
      "name": "Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -700,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "const body = $json.body || $json;\nconst missing = ['source', 'event_type', 'payload'].filter((field) => body[field] === undefined || body[field] === null || body[field] === '');\nif (missing.length) {\n  return [{ json: { ok: false, statusCode: 400, error: `Missing required fields: ${missing.join(', ')}` } }];\n}\nreturn [{ json: { ok: true, body } }];"
      },
      "id": "02-validate-payload",
      "name": "Validate Payload",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -460,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{$json.ok}}",
              "value2": true
            }
          ]
        }
      },
      "id": "02-payload-valid",
      "name": "Payload Valid?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        -220,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "const body = $json.body;\nreturn [{ json: { source: String(body.source).slice(0, 120), event_type: String(body.event_type).slice(0, 120), payload_json: JSON.stringify({ payload: body.payload, timestamp: body.timestamp || new Date().toISOString() }), status: 'received' } }];"
      },
      "id": "02-normalize-payload",
      "name": "Normalize Payload",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        20,
        -120
      ]
    },
    {
      "parameters": {
        "operation": "insert",
        "table": "webhook_logs",
        "columns": "source,event_type,payload_json,status",
        "options": {}
      },
      "id": "02-mysql-insert",
      "name": "MySQL Insert",
      "type": "n8n-nodes-base.mySql",
      "typeVersion": 2.4,
      "position": [
        260,
        -120
      ],
      "credentials": {
        "mySql": {
          "name": "<your credential>"
        }
      },
      "continueOnFail": true
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { ok: true, status: 'logged' } }}",
        "options": {
          "responseCode": 201
        }
      },
      "id": "02-success-response",
      "name": "Success Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        520,
        -120
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { ok: false, error: $json.error || 'Failed to log webhook payload' } }}",
        "options": {
          "responseCode": "={{$json.statusCode || 500}}"
        }
      },
      "id": "02-error-response",
      "name": "Error Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        40,
        160
      ]
    }
  ],
  "connections": {
    "Webhook Trigger": {
      "main": [
        [
          {
            "node": "Validate Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Payload": {
      "main": [
        [
          {
            "node": "Payload Valid?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Payload Valid?": {
      "main": [
        [
          {
            "node": "Normalize Payload",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Payload": {
      "main": [
        [
          {
            "node": "MySQL Insert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "MySQL Insert": {
      "main": [
        [
          {
            "node": "Success Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "placeholder-02"
}

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

Webhook - MySQL Logger. Uses mySql. Webhook trigger; 7 nodes.

Source: https://github.com/gharisj3/n8n-workflow-library/blob/main/workflows/02-webhook-mysql-logger/workflow.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

BP_check. Uses googleSheets, @n-octo-n/n8n-nodes-json-database, httpRequest, itemLists. Webhook trigger; 99 nodes.

Google Sheets, @N Octo N/N8N Nodes Json Database, HTTP Request +2
Data & Sheets

v25.1.3. Uses httpRequest, mySql, n8n-nodes-zohozeptomail. Webhook trigger; 98 nodes.

HTTP Request, MySQL, N8N Nodes Zohozeptomail
Data & Sheets

InsertDB. Uses mySql, httpRequest. Webhook trigger; 29 nodes.

MySQL, HTTP Request
Data & Sheets

N8Nworkflow. Uses stopAndError, httpRequest, mySql. Webhook trigger; 22 nodes.

Stop And Error, HTTP Request, MySQL
Data & Sheets

This workflow demonstrates how to export SQL to XML and present the data nicely formatted using an XSL Template.

MySQL, Item Lists, XML +2