{
  "name": "Content requests from a form or a webhook, in one list",
  "nodes": [
    {
      "id": "a6e71a4a-3ba0-4ae6-b557-529e674eddfb",
      "name": "Read me first",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -688,
        -120
      ],
      "parameters": {
        "content": "## Content requests from a form or a webhook, in one list\nRequests from an n8n form or any app that can call a webhook land in one sheet, in one shape. Bad or repeat requests get a plain answer. You get a message for each new one.\n\n### You need\n- A Google Sheets login and a Content Requests tab with: Request ID, Received At, Source, Title, Brief, Links, Requested By, Wanted By, Status\n- A Telegram bot and your chat ID\n- A user name and password for the form (n8n Basic Auth)\n\n### Set it up\n1. Pick your sheet in **Read requests** and **Add the request**. Add your chat ID in **Settings**.\n2. In **Request form**, add a Basic Auth login so only your team can use it.\n3. Turn the workflow on. Share the form link, or send JSON to the Production URL of **Request by webhook** (title, brief, links, requester, wantedBy).\n4. Failure alert: put your chat ID in **Write the failure alert** and your bot in **Send the failure alert**. Then in Workflow settings, set Error workflow to this workflow.\n\n### Test it\n- Open the form and send a request. It shows in the sheet with Status New, and you get a message.\n- Send the same request again. The form says it is already in the list.",
        "height": 832,
        "width": 560,
        "color": 4
      }
    },
    {
      "id": "e3667236-15d4-417c-b537-41d7096398ea",
      "name": "Note: shape",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -48,
        -120
      ],
      "parameters": {
        "content": "## One shape\nForm and webhook requests become the same row. The same title and brief twice count as one request.",
        "height": 760,
        "width": 1240,
        "color": 7
      }
    },
    {
      "id": "151be12a-8e8b-429f-b06b-c504831255fc",
      "name": "Note: answer",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1272,
        -120
      ],
      "parameters": {
        "content": "## Answer the sender\nThe form shows a thank you or the problem. The webhook gets ok and the message back.",
        "height": 960,
        "width": 1240,
        "color": 7
      }
    },
    {
      "id": "dd5d5233-edab-4df9-9655-02606874351d",
      "name": "Request by webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ],
      "parameters": {
        "path": "content-request",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "webhookId": "100a6894-0c01-45c0-966b-1bfdb441ed47"
    },
    {
      "id": "15d4e182-0a5e-4a10-8e56-8e19f1aae41c",
      "name": "Request form",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.5,
      "position": [
        0,
        240
      ],
      "parameters": {
        "authentication": "basicAuth",
        "formTitle": "Ask for content",
        "formDescription": "Tell us what you need. We reply in the team chat.",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Title",
              "fieldName": "title",
              "fieldType": "text",
              "requiredField": true
            },
            {
              "fieldLabel": "What do you need?",
              "fieldName": "brief",
              "fieldType": "textarea",
              "requiredField": true
            },
            {
              "fieldLabel": "Your name",
              "fieldName": "requester",
              "fieldType": "text"
            },
            {
              "fieldLabel": "Wanted by",
              "fieldName": "wantedBy",
              "fieldType": "date"
            },
            {
              "fieldLabel": "Links, one per line",
              "fieldName": "links",
              "fieldType": "textarea"
            }
          ]
        },
        "options": {
          "buttonLabel": "Send"
        }
      }
    },
    {
      "id": "e9a4b1ae-e54c-4612-bd03-925e831f972b",
      "name": "Settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        240,
        120
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f1",
              "name": "telegramChatId",
              "type": "string",
              "value": "YOUR_CHAT_ID"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      }
    },
    {
      "id": "d0cb9585-3ebb-4769-b448-8ee758a429a1",
      "name": "Read requests",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        480,
        120
      ],
      "parameters": {
        "operation": "read",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "Content Requests",
          "mode": "name"
        },
        "options": {}
      },
      "executeOnce": true,
      "alwaysOutputData": true
    },
    {
      "id": "e1c21a81-c604-41f1-bbef-784d94db2078",
      "name": "Put it in one shape",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        720,
        120
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const fromForm = $('Request form').isExecuted;\nconst r = fromForm ? $('Request form').first().json : (($('Request by webhook').first().json || {}).body || {});\nconst text = v => Array.isArray(v) ? v.join('\\n').trim() : String(v ?? '').trim();\nconst title = text(r.title || r.Title || r.subject || r.name);\nconst brief = text(r.brief || r.description || r.body || r.text || r.message);\nconst links = [].concat(r.links || r.attachments || r.files || []).flatMap(v => String(v).split(/[\\s,]+/)).map(v => v.trim()).filter(Boolean);\nconst requester = text(r.requester || r.owner || r.from);\nconst wantedRaw = text(r.wantedBy || r.due || r.deadline);\nconst wanted = wantedRaw ? DateTime.fromISO(wantedRaw) : null;\nlet h = 5381;\nfor (const ch of (title + '|' + brief).toLowerCase()) h = ((h << 5) + h + ch.charCodeAt(0)) >>> 0;\nconst requestId = 'req-' + h.toString(36);\nconst known = new Set($('Read requests').all().map(i => String(i.json['Request ID'] || '')));\nconst problems = [];\nif (!title) problems.push('A title is needed.');\nif (!brief) problems.push('Say what you need.');\nfor (const l of links) if (!/^https?:\\/\\//i.test(l)) problems.push('This link does not start with http: ' + l.slice(0, 40));\nif (wanted && !wanted.isValid) problems.push('Wanted by is not a date. Write it like 2026-12-01.');\nconst duplicate = known.has(requestId);\nreturn [{ json: {\n  ok: problems.length === 0 && !duplicate, problem: duplicate ? 'This request is already in the list.' : problems.join(' '),\n  requestId, source: fromForm ? 'form' : 'webhook', title, brief, links: links.join('\\n'), requester,\n  wantedBy: wanted && wanted.isValid ? wanted.toISODate() : '', receivedAt: $now.toISO(),\n} }];"
      }
    },
    {
      "id": "d23e562c-1c6e-4f91-abe8-e2e83cd16eed",
      "name": "Good request?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        960,
        120
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $json.ok === true }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      }
    },
    {
      "id": "610292cf-9b5f-4501-9b7c-5efd06edcac7",
      "name": "Add the request",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1200,
        0
      ],
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "Content Requests",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Request ID": "={{ $json.requestId }}",
            "Received At": "={{ $json.receivedAt }}",
            "Source": "={{ $json.source }}",
            "Title": "={{ $json.title }}",
            "Brief": "={{ $json.brief }}",
            "Links": "={{ $json.links }}",
            "Requested By": "={{ $json.requester }}",
            "Wanted By": "={{ $json.wantedBy }}",
            "Status": "New"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Request ID",
              "displayName": "Request ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Received At",
              "displayName": "Received At",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Source",
              "displayName": "Source",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Title",
              "displayName": "Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Brief",
              "displayName": "Brief",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Links",
              "displayName": "Links",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Requested By",
              "displayName": "Requested By",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Wanted By",
              "displayName": "Wanted By",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "96634a55-6972-46eb-85a7-10a783e2eeac",
      "name": "Tell you about it",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1440,
        0
      ],
      "parameters": {
        "chatId": "={{ $('Settings').first().json.telegramChatId }}",
        "text": "={{ 'New content request: ' + $('Put it in one shape').first().json.title + '\\nFrom: ' + ($('Put it in one shape').first().json.requester || 'no name') + ($('Put it in one shape').first().json.wantedBy ? '\\nWanted by: ' + $('Put it in one shape').first().json.wantedBy : '') + '\\n\\n' + $('Put it in one shape').first().json.brief.slice(0, 500) }}",
        "additionalFields": {
          "appendAttribution": false
        }
      }
    },
    {
      "id": "d61a6caf-85bb-49ec-ab59-5fb057a983a6",
      "name": "Write the answer",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1680,
        120
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f1",
              "name": "ok",
              "type": "boolean",
              "value": "={{ $('Put it in one shape').first().json.ok }}"
            },
            {
              "id": "f2",
              "name": "title",
              "type": "string",
              "value": "={{ $('Put it in one shape').first().json.ok ? 'Thank you' : 'Not sent' }}"
            },
            {
              "id": "f3",
              "name": "message",
              "type": "string",
              "value": "={{ $('Put it in one shape').first().json.ok ? 'We have your request. Its number is ' + $('Put it in one shape').first().json.requestId + '.' : $('Put it in one shape').first().json.problem }}"
            }
          ]
        },
        "includeOtherFields": false,
        "options": {}
      },
      "executeOnce": true
    },
    {
      "id": "4d3c253e-bb1f-4a16-9ce9-d483599653a2",
      "name": "From the form?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1920,
        120
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $('Request form').isExecuted }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      }
    },
    {
      "id": "e3b6bdb0-9a85-4349-9eda-477c891a371c",
      "name": "Show the answer",
      "type": "n8n-nodes-base.form",
      "typeVersion": 2.5,
      "position": [
        2160,
        0
      ],
      "parameters": {
        "operation": "completion",
        "completionTitle": "={{ $json.title }}",
        "completionMessage": "={{ $json.message }}",
        "options": {}
      }
    },
    {
      "id": "8d6c12bd-1829-44d4-a407-7b5831d0f7b8",
      "name": "Answer the webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        2160,
        240
      ],
      "parameters": {
        "options": {
          "responseCode": 200,
          "responseHeaders": {
            "entries": [
              {
                "name": "Content-Type",
                "value": "application/json"
              }
            ]
          }
        },
        "respondWith": "json",
        "responseBody": "={{ { ok: $json.ok, message: $json.message } }}"
      }
    },
    {
      "id": "7a10ab92-3128-4b2b-bc36-eb41c26ef56f",
      "name": "When this workflow fails",
      "type": "n8n-nodes-base.errorTrigger",
      "typeVersion": 1,
      "position": [
        -648,
        792
      ],
      "parameters": {}
    },
    {
      "id": "540f553e-a9c3-4b40-961a-2d5c725ee430",
      "name": "Write the failure alert",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -428,
        792
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f1",
              "name": "telegramChatId",
              "type": "string",
              "value": "YOUR_TELEGRAM_CHAT_ID"
            },
            {
              "id": "f2",
              "name": "message",
              "type": "string",
              "value": "={{ 'A workflow stopped.\\n\\nWorkflow: ' + (($json.workflow || {}).name || 'unknown') + '\\nFailed step: ' + (($json.execution || {}).lastNodeExecuted || 'unknown') + '\\nWhy: ' + String((($json.execution || {}).error || {}).message || 'n8n did not give a reason.').slice(0, 300) + (($json.execution || {}).url ? '\\nOpen the run: ' + $json.execution.url : '') }}"
            }
          ]
        },
        "includeOtherFields": false,
        "options": {}
      }
    },
    {
      "id": "746d6ea4-8e42-4daa-82a9-a040336c46ee",
      "name": "Send the failure alert",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -208,
        792
      ],
      "parameters": {
        "chatId": "={{ $json.telegramChatId }}",
        "text": "={{ $json.message }}",
        "additionalFields": {
          "appendAttribution": false
        }
      }
    }
  ],
  "connections": {
    "Request by webhook": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Request form": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings": {
      "main": [
        [
          {
            "node": "Read requests",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read requests": {
      "main": [
        [
          {
            "node": "Put it in one shape",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Put it in one shape": {
      "main": [
        [
          {
            "node": "Good request?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Good request?": {
      "main": [
        [
          {
            "node": "Add the request",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Write the answer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add the request": {
      "main": [
        [
          {
            "node": "Tell you about it",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tell you about it": {
      "main": [
        [
          {
            "node": "Write the answer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write the answer": {
      "main": [
        [
          {
            "node": "From the form?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "From the form?": {
      "main": [
        [
          {
            "node": "Show the answer",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Answer the webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When this workflow fails": {
      "main": [
        [
          {
            "node": "Write the failure alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write the failure alert": {
      "main": [
        [
          {
            "node": "Send the failure alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "tags": []
}
