# workflow_versions

workflow_id: ThD7S9hN0K1P5AZi
workflow_name: GET /chat/messages - List Messages
trigger: partial_update
created_at: 2025-10-24 12:10:33
workflow_snapshot:
  {"createdAt":"2025-10-24T12:06:35.080Z","updatedAt":"2025-10-24T12:08:56.996Z","id":"ThD7S9hN0K1P5AZi","name":"GET /chat/messages - List Messages","active":false,"isArchived":false,"nodes":[{"id":"webhook-trigger","name":"GET /chat/messages","type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[180,360],"parameters":{"httpMethod":"GET","path":"chat/messages","responseMode":"responseNode","options":{"allowedOrigins":"*"}},"webhookId":"chat-messages-list","onError":"continueRegularOutput"},{"id":"jwt-validation","name":"JWT Validation","type":"n8n-nodes-base.executeWorkflow","typeVersion":1.3,"position":[400,360],"parameters":{"source":"database","workflowId":"dL4gKHrO0Mtdhpmo"}},{"id":"auth-check","name":"Auth Failed?","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[620,360],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"auth-error-check","leftValue":"={{ $('JWT Validation').item.json.error }}","rightValue":"","operator":{"type":"object","operation":"notEmpty"}}]}}},{"id":"response-401","name":"401 Unauthorized","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[820,240],"parameters":{"respondWith":"json","responseCode":401,"responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"UNAUTHORIZED\",\n    \"message\": \"Invalid or expired access token\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"parse-validate-params","name":"Parse & Validate Query Params","type":"n8n-nodes-base.code","typeVersion":2,"position":[840,440],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get query parameters from webhook\nconst queryParams = $('GET /chat/messages').item.json.query || {};\nconst user_id = $('JWT Validation').item.json.user_id;\n\n// Extract parameters\nconst approach_id = queryParams.approach_id;\nconst patient_id = queryParams.patient_id || null;\nconst limit = parseInt(queryParams.limit) || 50;\nconst offset = parseInt(queryParams.offset) || 0;\nconst order = queryParams.order || 'asc';\n\n// Validation errors array\nconst errors = [];\n\n// Validate approach_id (required)\nif (!approach_id) {\n  errors.push({ field: 'approach_id', message: 'Missing required field: approach_id' });\n} else {\n  // UUID format validation\n  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n  if (!uuidRegex.test(approach_id)) {\n    errors.push({ field: 'approach_id', message: 'Invalid UUID format: approach_id' });\n  }\n}\n\n// Validate patient_id if provided\nif (patient_id) {\n  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n  if (!uuidRegex.test(patient_id)) {\n    errors.push({ field: 'patient_id', message: 'Invalid UUID format: patient_id' });\n  }\n}\n\n// Validate limit\nif (limit < 1 || limit > 100) {\n  errors.push({ field: 'limit', message: 'Limit must be between 1 and 100' });\n}\n\n// Validate offset\nif (offset < 0) {\n  errors.push({ field: 'offset', message: 'Offset must be >= 0' });\n}\n\n// Validate order\nif (order !== 'asc' && order !== 'desc') {\n  errors.push({ field: 'order', message: 'Order must be \"asc\" or \"desc\"' });\n}\n\n// Return validation result\nreturn [{\n  json: {\n    valid: errors.length === 0,\n    errors,\n    user_id,\n    approach_id,\n    patient_id,\n    limit,\n    offset,\n    order\n  }\n}];"}},{"id":"validation-check","name":"Validation Check","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1060,440],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"validation-failed","leftValue":"={{ $json.valid }}","rightValue":false,"operator":{"type":"boolean","operation":"equals"}}]}}},{"id":"response-400","name":"400 Bad Request","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1260,320],"parameters":{"respondWith":"json","responseCode":400,"responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"VALIDATION_ERROR\",\n    \"message\": $json.errors[0].message,\n    \"details\": $json.errors\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"lookup-thread-http","name":"Lookup Thread (HTTP)","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1460,520],"parameters":{"method":"GET","url":"https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_threads","authentication":"predefinedCredentialType","nodeCredentialType":"supabaseApi","sendQuery":true,"queryParameters":{"parameters":[{"name":"select","value":"id,user_id,patient_id,approach_id"},{"name":"user_id","value":"={{ 'eq.' + $('Parse & Validate Query Params').item.json.user_id }}"},{"name":"approach_id","value":"={{ 'eq.' + $('Parse & Validate Query Params').item.json.approach_id }}"},{"name":"patient_id","value":"={{ $('Parse & Validate Query Params').item.json.patient_id ? 'eq.' + $('Parse & Validate Query Params').item.json.patient_id : 'is.null' }}"},{"name":"status","value":"eq.active"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ 'Bearer ' + $('JWT Validation').item.json.access_token }}"}]},"options":{"response":{"response":{"responseFormat":"json"}},"timeout":10000}},"credentials":{"supabaseApi":{"id":"mdlcQ90gqxko069t","name":"Supabase Anon"}}},{"id":"thread-found-check","name":"Thread Found?","type":"n8n-nodes-base.if","typeVersion":2,"position":[1700,520],"parameters":{"conditions":{"conditions":[{"leftValue":"={{ $json.length }}","rightValue":0,"operator":{"type":"number","operation":"equals"}}]}}},{"id":"404-thread-not-found","name":"404 Thread Not Found","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[1900,400],"parameters":{"responseCode":404,"respondWith":"json","responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"NOT_FOUND\",\n    \"message\": \"Conversation thread not found. Please assign an approach to the patient first.\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"extract-thread-data","name":"Extract Thread Data","type":"n8n-nodes-base.code","typeVersion":2,"position":[1900,620],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get thread data from lookup result\nconst threadData = $input.first().json[0];\nconst queryParams = $('Parse & Validate Query Params').item.json;\n\n// Return thread info combined with query params\nreturn {\n  json: {\n    thread_id: threadData.id,\n    user_id: threadData.user_id,\n    patient_id: threadData.patient_id,\n    approach_id: threadData.approach_id,\n    limit: queryParams.limit,\n    offset: queryParams.offset,\n    order: queryParams.order\n  }\n};"}}],"connections":{"GET /chat/messages":{"main":[[{"node":"JWT Validation","type":"main","index":0}]]},"JWT Validation":{"main":[[{"node":"Auth Failed?","type":"main","index":0}]]},"Auth Failed?":{"main":[[{"node":"401 Unauthorized","type":"main","index":0}],[{"node":"Parse & Validate Query Params","type":"main","index":0}]]},"Parse & Validate Query Params":{"main":[[{"node":"Validation Check","type":"main","index":0}]]},"Validation Check":{"main":[[{"node":"400 Bad Request","type":"main","index":0}],[{"node":"Lookup Thread (HTTP)","type":"main","index":0}]]},"Lookup Thread (HTTP)":{"main":[[{"node":"Thread Found?","type":"main","index":0}]]},"Thread Found?":{"main":[[{"node":"404 Thread Not Found","type":"main","index":0}],[{"node":"Extract Thread Data","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"53c69626-1f4f-4a7d-82cf-79f25e989901","triggerCount":0,"shared":[{"createdAt":"2025-10-24T12:06:35.084Z","updatedAt":"2025-10-24T12:06:35.084Z","role":"workflow:owner","workflowId":"ThD7S9hN0K1P5AZi","projectId":"sVGwG1Ss6aXKNorC","project":{"createdAt":"2025-07-30T12:18:11.485Z","updatedAt":"2025-07-30T12:20:06.951Z","id":"sVGwG1Ss6aXKNorC","name":"Rafał Dębski <rdebski90@gmail.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-07-30T12:18:11.486Z","updatedAt":"2025-07-30T12:18:11.486Z","userId":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","projectId":"sVGwG1Ss6aXKNorC","user":{"createdAt":"2025-07-30T12:18:10.851Z","updatedAt":"2025-10-23T22:43:16.000Z","id":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","email":"rdebski90@gmail.com","firstName":"Rafał","lastName":"Dębski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-07-30T12:20:09.619Z","personalization_survey_n8n_version":"1.104.1"},"settings":{"userActivated":true,"easyAIWorkflowOnboarded":true,"firstSuccessfulWorkflowId":"gp796pP6j8IFZodb","userActivatedAt":1753881412699,"npsSurvey":{"responded":true,"lastShownAt":1755785806897},"dismissedCallouts":{"ragStarterCallout":true}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"id":"node-12-get-messages","name":"Get Messages (HTTP)","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2140,620],"parameters":{"method":"GET","url":"https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/messages","authentication":"predefinedCredentialType","nodeCredentialType":"supabaseApi","sendQuery":true,"queryParameters":{"parameters":[{"name":"select","value":"id,message,created_at"},{"name":"thread_id","value":"={{ 'eq.' + $('Extract Thread Data').item.json.thread_id }}"},{"name":"order","value":"={{ 'created_at.' + $('Extract Thread Data').item.json.order }}"},{"name":"limit","value":"={{ $('Extract Thread Data').item.json.limit }}"},{"name":"offset","value":"={{ $('Extract Thread Data').item.json.offset }}"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ 'Bearer ' + $('JWT Validation').item.json.access_token }}"},{"name":"Prefer","value":"count=exact"}]},"options":{"response":{"response":{"responseFormat":"json"}},"timeout":10000}},"credentials":{"supabaseApi":{"id":"mdlcQ90gqxko069t","name":"Supabase Anon"}}}},{"type":"addNode","node":{"id":"node-13-format-response","name":"Format Response","type":"n8n-nodes-base.code","typeVersion":2,"position":[2380,620],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get all messages from the database query\nconst messagesData = $input.all();\nconst threadData = $('Extract Thread Data').item.json;\n\n// Extract total count from Content-Range header\n// Format: \"0-49/150\" means showing items 0-49 out of 150 total\nconst contentRange = $('Get Messages (HTTP)').item.json.$response?.headers?.['content-range'];\nlet total = messagesData.length;\nif (contentRange) {\n  const match = contentRange.match(/\\/(\\d+)/);\n  if (match) {\n    total = parseInt(match[1]);\n  }\n}\n\n// Parse JSONB message field and format each message\nconst messages = messagesData.map(item => {\n  const msg = item.json.message || {};\n  return {\n    id: item.json.id,\n    role: msg.role || 'user',\n    content: msg.content || '',\n    tool_id: msg.tool_id || null,\n    metadata: msg.metadata || {},\n    created_at: item.json.created_at\n  };\n});\n\n// Calculate pagination metadata\nconst hasMore = (threadData.offset + messages.length) < total;\n\n// Build final response following API_RESPONSE_STANDARDS.md\nreturn {\n  json: {\n    success: true,\n    data: {\n      thread_id: threadData.thread_id,\n      patient_id: threadData.patient_id,\n      approach_id: threadData.approach_id,\n      messages: messages,\n      pagination: {\n        limit: threadData.limit,\n        offset: threadData.offset,\n        total: total,\n        hasMore: hasMore\n      }\n    },\n    metadata: {\n      timestamp: new Date().toISOString()\n    }\n  }\n};"}}},{"type":"addConnection"},{"type":"addConnection"},{"type":"addNode","node":{"id":"sticky-milestone-3","name":"Note4","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2060,-80],"parameters":{"content":"## 📬 Load Messages & Format\n\n**Milestone 3**: Query messages with pagination and format JSONB fields\n\n- Get messages from Supabase with filters\n- Parse JSONB message structure\n- Calculate pagination metadata\n- Format according to API standards","height":240,"width":360,"color":4}}}]


workflow_id: ThD7S9hN0K1P5AZi
workflow_name: GET /chat/messages - List Messages
trigger: partial_update
created_at: 2025-10-24 12:11:08
workflow_snapshot:
  {"createdAt":"2025-10-24T12:06:35.080Z","updatedAt":"2025-10-24T12:08:56.996Z","id":"ThD7S9hN0K1P5AZi","name":"GET /chat/messages - List Messages","active":false,"isArchived":false,"nodes":[{"id":"webhook-trigger","name":"GET /chat/messages","type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[180,360],"parameters":{"httpMethod":"GET","path":"chat/messages","responseMode":"responseNode","options":{"allowedOrigins":"*"}},"webhookId":"chat-messages-list","onError":"continueRegularOutput"},{"id":"jwt-validation","name":"JWT Validation","type":"n8n-nodes-base.executeWorkflow","typeVersion":1.3,"position":[400,360],"parameters":{"source":"database","workflowId":"dL4gKHrO0Mtdhpmo"}},{"id":"auth-check","name":"Auth Failed?","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[620,360],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"auth-error-check","leftValue":"={{ $('JWT Validation').item.json.error }}","rightValue":"","operator":{"type":"object","operation":"notEmpty"}}]}}},{"id":"response-401","name":"401 Unauthorized","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[820,240],"parameters":{"respondWith":"json","responseCode":401,"responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"UNAUTHORIZED\",\n    \"message\": \"Invalid or expired access token\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"parse-validate-params","name":"Parse & Validate Query Params","type":"n8n-nodes-base.code","typeVersion":2,"position":[840,440],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get query parameters from webhook\nconst queryParams = $('GET /chat/messages').item.json.query || {};\nconst user_id = $('JWT Validation').item.json.user_id;\n\n// Extract parameters\nconst approach_id = queryParams.approach_id;\nconst patient_id = queryParams.patient_id || null;\nconst limit = parseInt(queryParams.limit) || 50;\nconst offset = parseInt(queryParams.offset) || 0;\nconst order = queryParams.order || 'asc';\n\n// Validation errors array\nconst errors = [];\n\n// Validate approach_id (required)\nif (!approach_id) {\n  errors.push({ field: 'approach_id', message: 'Missing required field: approach_id' });\n} else {\n  // UUID format validation\n  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n  if (!uuidRegex.test(approach_id)) {\n    errors.push({ field: 'approach_id', message: 'Invalid UUID format: approach_id' });\n  }\n}\n\n// Validate patient_id if provided\nif (patient_id) {\n  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n  if (!uuidRegex.test(patient_id)) {\n    errors.push({ field: 'patient_id', message: 'Invalid UUID format: patient_id' });\n  }\n}\n\n// Validate limit\nif (limit < 1 || limit > 100) {\n  errors.push({ field: 'limit', message: 'Limit must be between 1 and 100' });\n}\n\n// Validate offset\nif (offset < 0) {\n  errors.push({ field: 'offset', message: 'Offset must be >= 0' });\n}\n\n// Validate order\nif (order !== 'asc' && order !== 'desc') {\n  errors.push({ field: 'order', message: 'Order must be \"asc\" or \"desc\"' });\n}\n\n// Return validation result\nreturn [{\n  json: {\n    valid: errors.length === 0,\n    errors,\n    user_id,\n    approach_id,\n    patient_id,\n    limit,\n    offset,\n    order\n  }\n}];"}},{"id":"validation-check","name":"Validation Check","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1060,440],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"validation-failed","leftValue":"={{ $json.valid }}","rightValue":false,"operator":{"type":"boolean","operation":"equals"}}]}}},{"id":"response-400","name":"400 Bad Request","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1260,320],"parameters":{"respondWith":"json","responseCode":400,"responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"VALIDATION_ERROR\",\n    \"message\": $json.errors[0].message,\n    \"details\": $json.errors\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"lookup-thread-http","name":"Lookup Thread (HTTP)","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1460,520],"parameters":{"method":"GET","url":"https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_threads","authentication":"predefinedCredentialType","nodeCredentialType":"supabaseApi","sendQuery":true,"queryParameters":{"parameters":[{"name":"select","value":"id,user_id,patient_id,approach_id"},{"name":"user_id","value":"={{ 'eq.' + $('Parse & Validate Query Params').item.json.user_id }}"},{"name":"approach_id","value":"={{ 'eq.' + $('Parse & Validate Query Params').item.json.approach_id }}"},{"name":"patient_id","value":"={{ $('Parse & Validate Query Params').item.json.patient_id ? 'eq.' + $('Parse & Validate Query Params').item.json.patient_id : 'is.null' }}"},{"name":"status","value":"eq.active"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ 'Bearer ' + $('JWT Validation').item.json.access_token }}"}]},"options":{"response":{"response":{"responseFormat":"json"}},"timeout":10000}},"credentials":{"supabaseApi":{"id":"mdlcQ90gqxko069t","name":"Supabase Anon"}}},{"id":"thread-found-check","name":"Thread Found?","type":"n8n-nodes-base.if","typeVersion":2,"position":[1700,520],"parameters":{"conditions":{"conditions":[{"leftValue":"={{ $json.length }}","rightValue":0,"operator":{"type":"number","operation":"equals"}}]}}},{"id":"404-thread-not-found","name":"404 Thread Not Found","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[1900,400],"parameters":{"responseCode":404,"respondWith":"json","responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"NOT_FOUND\",\n    \"message\": \"Conversation thread not found. Please assign an approach to the patient first.\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"extract-thread-data","name":"Extract Thread Data","type":"n8n-nodes-base.code","typeVersion":2,"position":[1900,620],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get thread data from lookup result\nconst threadData = $input.first().json[0];\nconst queryParams = $('Parse & Validate Query Params').item.json;\n\n// Return thread info combined with query params\nreturn {\n  json: {\n    thread_id: threadData.id,\n    user_id: threadData.user_id,\n    patient_id: threadData.patient_id,\n    approach_id: threadData.approach_id,\n    limit: queryParams.limit,\n    offset: queryParams.offset,\n    order: queryParams.order\n  }\n};"}}],"connections":{"GET /chat/messages":{"main":[[{"node":"JWT Validation","type":"main","index":0}]]},"JWT Validation":{"main":[[{"node":"Auth Failed?","type":"main","index":0}]]},"Auth Failed?":{"main":[[{"node":"401 Unauthorized","type":"main","index":0}],[{"node":"Parse & Validate Query Params","type":"main","index":0}]]},"Parse & Validate Query Params":{"main":[[{"node":"Validation Check","type":"main","index":0}]]},"Validation Check":{"main":[[{"node":"400 Bad Request","type":"main","index":0}],[{"node":"Lookup Thread (HTTP)","type":"main","index":0}]]},"Lookup Thread (HTTP)":{"main":[[{"node":"Thread Found?","type":"main","index":0}]]},"Thread Found?":{"main":[[{"node":"404 Thread Not Found","type":"main","index":0}],[{"node":"Extract Thread Data","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"53c69626-1f4f-4a7d-82cf-79f25e989901","triggerCount":0,"shared":[{"createdAt":"2025-10-24T12:06:35.084Z","updatedAt":"2025-10-24T12:06:35.084Z","role":"workflow:owner","workflowId":"ThD7S9hN0K1P5AZi","projectId":"sVGwG1Ss6aXKNorC","project":{"createdAt":"2025-07-30T12:18:11.485Z","updatedAt":"2025-07-30T12:20:06.951Z","id":"sVGwG1Ss6aXKNorC","name":"Rafał Dębski <rdebski90@gmail.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-07-30T12:18:11.486Z","updatedAt":"2025-07-30T12:18:11.486Z","userId":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","projectId":"sVGwG1Ss6aXKNorC","user":{"createdAt":"2025-07-30T12:18:10.851Z","updatedAt":"2025-10-23T22:43:16.000Z","id":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","email":"rdebski90@gmail.com","firstName":"Rafał","lastName":"Dębski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-07-30T12:20:09.619Z","personalization_survey_n8n_version":"1.104.1"},"settings":{"userActivated":true,"easyAIWorkflowOnboarded":true,"firstSuccessfulWorkflowId":"gp796pP6j8IFZodb","userActivatedAt":1753881412699,"npsSurvey":{"responded":true,"lastShownAt":1755785806897},"dismissedCallouts":{"ragStarterCallout":true}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"id":"get-messages-http","name":"Get Messages (HTTP)","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2140,620],"parameters":{"method":"GET","url":"https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/messages","authentication":"predefinedCredentialType","nodeCredentialType":"supabaseApi","sendQuery":true,"queryParameters":{"parameters":[{"name":"select","value":"id,message,created_at"},{"name":"thread_id","value":"={{ 'eq.' + $('Extract Thread Data').item.json.thread_id }}"},{"name":"order","value":"={{ 'created_at.' + $('Extract Thread Data').item.json.order }}"},{"name":"limit","value":"={{ $('Extract Thread Data').item.json.limit }}"},{"name":"offset","value":"={{ $('Extract Thread Data').item.json.offset }}"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ 'Bearer ' + $('JWT Validation').item.json.access_token }}"},{"name":"Prefer","value":"count=exact"}]},"options":{"response":{"response":{"responseFormat":"json"}},"timeout":10000}},"credentials":{"supabaseApi":{"id":"mdlcQ90gqxko069t","name":"Supabase Anon"}}}},{"type":"addNode","node":{"id":"format-response","name":"Format Response","type":"n8n-nodes-base.code","typeVersion":2,"position":[2380,620],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get all messages from the database query\nconst messagesData = $input.all();\nconst threadData = $('Extract Thread Data').item.json;\n\n// Extract total count from Content-Range header\n// Format: \"0-49/150\" means showing items 0-49 out of 150 total\nconst contentRange = $('Get Messages (HTTP)').item.json.$response?.headers?.['content-range'];\nlet total = messagesData.length;\nif (contentRange) {\n  const match = contentRange.match(/\\/(\\d+)/);\n  if (match) {\n    total = parseInt(match[1]);\n  }\n}\n\n// Parse JSONB message field and format each message\nconst messages = messagesData.map(item => {\n  const msg = item.json.message || {};\n  return {\n    id: item.json.id,\n    role: msg.role || 'user',\n    content: msg.content || '',\n    tool_id: msg.tool_id || null,\n    metadata: msg.metadata || {},\n    created_at: item.json.created_at\n  };\n});\n\n// Calculate pagination metadata\nconst hasMore = (threadData.offset + messages.length) < total;\n\n// Build final response following API_RESPONSE_STANDARDS.md\nreturn {\n  json: {\n    success: true,\n    data: {\n      thread_id: threadData.thread_id,\n      patient_id: threadData.patient_id,\n      approach_id: threadData.approach_id,\n      messages: messages,\n      pagination: {\n        limit: threadData.limit,\n        offset: threadData.offset,\n        total: total,\n        hasMore: hasMore\n      }\n    },\n    metadata: {\n      timestamp: new Date().toISOString()\n    }\n  }\n};"}}},{"type":"addConnection","source":"Extract Thread Data","target":"Get Messages (HTTP)"},{"type":"addConnection","source":"Get Messages (HTTP)","target":"Format Response"},{"type":"addNode","node":{"id":"sticky-milestone-3","name":"Note4","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2060,-80],"parameters":{"content":"## 📬 Load Messages & Format\n\n**Milestone 3**: Query messages with pagination and format JSONB fields\n\n- Get messages from Supabase with filters\n- Parse JSONB message structure\n- Calculate pagination metadata\n- Format according to API standards","height":240,"width":360,"color":4}}}]


workflow_id: ThD7S9hN0K1P5AZi
workflow_name: GET /chat/messages - List Messages
trigger: partial_update
created_at: 2025-10-24 12:12:43
workflow_snapshot:
  {"createdAt":"2025-10-24T12:06:35.080Z","updatedAt":"2025-10-24T12:11:22.000Z","id":"ThD7S9hN0K1P5AZi","name":"GET /chat/messages - List Messages","active":false,"isArchived":false,"nodes":[{"id":"webhook-trigger","name":"GET /chat/messages","type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[180,360],"parameters":{"httpMethod":"GET","path":"chat/messages","responseMode":"responseNode","options":{"allowedOrigins":"*"}},"webhookId":"chat-messages-list","onError":"continueRegularOutput"},{"id":"jwt-validation","name":"JWT Validation","type":"n8n-nodes-base.executeWorkflow","typeVersion":1.3,"position":[400,360],"parameters":{"source":"database","workflowId":"dL4gKHrO0Mtdhpmo"}},{"id":"auth-check","name":"Auth Failed?","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[620,360],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"auth-error-check","leftValue":"={{ $('JWT Validation').item.json.error }}","rightValue":"","operator":{"type":"object","operation":"notEmpty"}}]}}},{"id":"response-401","name":"401 Unauthorized","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[820,240],"parameters":{"respondWith":"json","responseCode":401,"responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"UNAUTHORIZED\",\n    \"message\": \"Invalid or expired access token\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"parse-validate-params","name":"Parse & Validate Query Params","type":"n8n-nodes-base.code","typeVersion":2,"position":[840,440],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get query parameters from webhook\nconst queryParams = $('GET /chat/messages').item.json.query || {};\nconst user_id = $('JWT Validation').item.json.user_id;\n\n// Extract parameters\nconst approach_id = queryParams.approach_id;\nconst patient_id = queryParams.patient_id || null;\nconst limit = parseInt(queryParams.limit) || 50;\nconst offset = parseInt(queryParams.offset) || 0;\nconst order = queryParams.order || 'asc';\n\n// Validation errors array\nconst errors = [];\n\n// Validate approach_id (required)\nif (!approach_id) {\n  errors.push({ field: 'approach_id', message: 'Missing required field: approach_id' });\n} else {\n  // UUID format validation\n  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n  if (!uuidRegex.test(approach_id)) {\n    errors.push({ field: 'approach_id', message: 'Invalid UUID format: approach_id' });\n  }\n}\n\n// Validate patient_id if provided\nif (patient_id) {\n  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n  if (!uuidRegex.test(patient_id)) {\n    errors.push({ field: 'patient_id', message: 'Invalid UUID format: patient_id' });\n  }\n}\n\n// Validate limit\nif (limit < 1 || limit > 100) {\n  errors.push({ field: 'limit', message: 'Limit must be between 1 and 100' });\n}\n\n// Validate offset\nif (offset < 0) {\n  errors.push({ field: 'offset', message: 'Offset must be >= 0' });\n}\n\n// Validate order\nif (order !== 'asc' && order !== 'desc') {\n  errors.push({ field: 'order', message: 'Order must be \"asc\" or \"desc\"' });\n}\n\n// Return validation result\nreturn [{\n  json: {\n    valid: errors.length === 0,\n    errors,\n    user_id,\n    approach_id,\n    patient_id,\n    limit,\n    offset,\n    order\n  }\n}];"}},{"id":"validation-check","name":"Validation Check","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1060,440],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"validation-failed","leftValue":"={{ $json.valid }}","rightValue":false,"operator":{"type":"boolean","operation":"equals"}}]}}},{"id":"response-400","name":"400 Bad Request","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1260,320],"parameters":{"respondWith":"json","responseCode":400,"responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"VALIDATION_ERROR\",\n    \"message\": $json.errors[0].message,\n    \"details\": $json.errors\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"lookup-thread-http","name":"Lookup Thread (HTTP)","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1460,520],"parameters":{"method":"GET","url":"https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_threads","authentication":"predefinedCredentialType","nodeCredentialType":"supabaseApi","sendQuery":true,"queryParameters":{"parameters":[{"name":"select","value":"id,user_id,patient_id,approach_id"},{"name":"user_id","value":"={{ 'eq.' + $('Parse & Validate Query Params').item.json.user_id }}"},{"name":"approach_id","value":"={{ 'eq.' + $('Parse & Validate Query Params').item.json.approach_id }}"},{"name":"patient_id","value":"={{ $('Parse & Validate Query Params').item.json.patient_id ? 'eq.' + $('Parse & Validate Query Params').item.json.patient_id : 'is.null' }}"},{"name":"status","value":"eq.active"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ 'Bearer ' + $('JWT Validation').item.json.access_token }}"}]},"options":{"response":{"response":{"responseFormat":"json"}},"timeout":10000}},"credentials":{"supabaseApi":{"id":"mdlcQ90gqxko069t","name":"Supabase Anon"}}},{"id":"thread-found-check","name":"Thread Found?","type":"n8n-nodes-base.if","typeVersion":2,"position":[1700,520],"parameters":{"conditions":{"conditions":[{"leftValue":"={{ $json.length }}","rightValue":0,"operator":{"type":"number","operation":"equals"}}]}}},{"id":"404-thread-not-found","name":"404 Thread Not Found","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[1900,400],"parameters":{"responseCode":404,"respondWith":"json","responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"NOT_FOUND\",\n    \"message\": \"Conversation thread not found. Please assign an approach to the patient first.\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"extract-thread-data","name":"Extract Thread Data","type":"n8n-nodes-base.code","typeVersion":2,"position":[1900,620],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get thread data from lookup result\nconst threadData = $input.first().json[0];\nconst queryParams = $('Parse & Validate Query Params').item.json;\n\n// Return thread info combined with query params\nreturn {\n  json: {\n    thread_id: threadData.id,\n    user_id: threadData.user_id,\n    patient_id: threadData.patient_id,\n    approach_id: threadData.approach_id,\n    limit: queryParams.limit,\n    offset: queryParams.offset,\n    order: queryParams.order\n  }\n};"}},{"id":"get-messages-http","name":"Get Messages (HTTP)","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2140,620],"parameters":{"method":"GET","url":"https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/messages","authentication":"predefinedCredentialType","nodeCredentialType":"supabaseApi","sendQuery":true,"queryParameters":{"parameters":[{"name":"select","value":"id,message,created_at"},{"name":"thread_id","value":"={{ 'eq.' + $('Extract Thread Data').item.json.thread_id }}"},{"name":"order","value":"={{ 'created_at.' + $('Extract Thread Data').item.json.order }}"},{"name":"limit","value":"={{ $('Extract Thread Data').item.json.limit }}"},{"name":"offset","value":"={{ $('Extract Thread Data').item.json.offset }}"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ 'Bearer ' + $('JWT Validation').item.json.access_token }}"},{"name":"Prefer","value":"count=exact"}]},"options":{"response":{"response":{"responseFormat":"json"}},"timeout":10000}},"credentials":{"supabaseApi":{"id":"mdlcQ90gqxko069t","name":"Supabase Anon"}}},{"id":"format-response","name":"Format Response","type":"n8n-nodes-base.code","typeVersion":2,"position":[2380,620],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get all messages from the database query\nconst messagesData = $input.all();\nconst threadData = $('Extract Thread Data').item.json;\n\n// Extract total count from Content-Range header\n// Format: \"0-49/150\" means showing items 0-49 out of 150 total\nconst contentRange = $('Get Messages (HTTP)').item.json.$response?.headers?.['content-range'];\nlet total = messagesData.length;\nif (contentRange) {\n  const match = contentRange.match(/\\/(\\d+)/);\n  if (match) {\n    total = parseInt(match[1]);\n  }\n}\n\n// Parse JSONB message field and format each message\nconst messages = messagesData.map(item => {\n  const msg = item.json.message || {};\n  return {\n    id: item.json.id,\n    role: msg.role || 'user',\n    content: msg.content || '',\n    tool_id: msg.tool_id || null,\n    metadata: msg.metadata || {},\n    created_at: item.json.created_at\n  };\n});\n\n// Calculate pagination metadata\nconst hasMore = (threadData.offset + messages.length) < total;\n\n// Build final response following API_RESPONSE_STANDARDS.md\nreturn {\n  json: {\n    success: true,\n    data: {\n      thread_id: threadData.thread_id,\n      patient_id: threadData.patient_id,\n      approach_id: threadData.approach_id,\n      messages: messages,\n      pagination: {\n        limit: threadData.limit,\n        offset: threadData.offset,\n        total: total,\n        hasMore: hasMore\n      }\n    },\n    metadata: {\n      timestamp: new Date().toISOString()\n    }\n  }\n};"}},{"id":"sticky-milestone-3","name":"Note4","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2060,-80],"parameters":{"content":"## 📬 Load Messages & Format\n\n**Milestone 3**: Query messages with pagination and format JSONB fields\n\n- Get messages from Supabase with filters\n- Parse JSONB message structure\n- Calculate pagination metadata\n- Format according to API standards","height":240,"width":360,"color":4}}],"connections":{"GET /chat/messages":{"main":[[{"node":"JWT Validation","type":"main","index":0}]]},"JWT Validation":{"main":[[{"node":"Auth Failed?","type":"main","index":0}]]},"Auth Failed?":{"main":[[{"node":"401 Unauthorized","type":"main","index":0}],[{"node":"Parse & Validate Query Params","type":"main","index":0}]]},"Parse & Validate Query Params":{"main":[[{"node":"Validation Check","type":"main","index":0}]]},"Validation Check":{"main":[[{"node":"400 Bad Request","type":"main","index":0}],[{"node":"Lookup Thread (HTTP)","type":"main","index":0}]]},"Lookup Thread (HTTP)":{"main":[[{"node":"Thread Found?","type":"main","index":0}]]},"Thread Found?":{"main":[[{"node":"404 Thread Not Found","type":"main","index":0}],[{"node":"Extract Thread Data","type":"main","index":0}]]},"Extract Thread Data":{"main":[[{"node":"Get Messages (HTTP)","type":"main","index":0}]]},"Get Messages (HTTP)":{"main":[[{"node":"Format Response","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"7e811ad9-3ad3-4694-91d1-0da3d16feb35","triggerCount":0,"shared":[{"createdAt":"2025-10-24T12:06:35.084Z","updatedAt":"2025-10-24T12:06:35.084Z","role":"workflow:owner","workflowId":"ThD7S9hN0K1P5AZi","projectId":"sVGwG1Ss6aXKNorC","project":{"createdAt":"2025-07-30T12:18:11.485Z","updatedAt":"2025-07-30T12:20:06.951Z","id":"sVGwG1Ss6aXKNorC","name":"Rafał Dębski <rdebski90@gmail.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-07-30T12:18:11.486Z","updatedAt":"2025-07-30T12:18:11.486Z","userId":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","projectId":"sVGwG1Ss6aXKNorC","user":{"createdAt":"2025-07-30T12:18:10.851Z","updatedAt":"2025-10-23T22:43:16.000Z","id":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","email":"rdebski90@gmail.com","firstName":"Rafał","lastName":"Dębski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-07-30T12:20:09.619Z","personalization_survey_n8n_version":"1.104.1"},"settings":{"userActivated":true,"easyAIWorkflowOnboarded":true,"firstSuccessfulWorkflowId":"gp796pP6j8IFZodb","userActivatedAt":1753881412699,"npsSurvey":{"responded":true,"lastShownAt":1755785806897},"dismissedCallouts":{"ragStarterCallout":true}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"id":"8cbfa0d4-2a39-427e-bd66-2ea3f7b52e14","name":"200 Success","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[2620,620],"parameters":{"responseCode":200,"respondWith":"json","responseBody":"={{ $json }}"}}},{"type":"addNode","node":{"id":"9dbeaf15-3b4c-428f-cf77-3fb4c8a53f15","name":"500 Internal Error","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[2380,780],"parameters":{"responseCode":500,"respondWith":"json","responseBody":"={\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INTERNAL_ERROR\",\n    \"message\": \"An unexpected error occurred. Please try again later.\"\n  },\n  \"metadata\": {\n    \"timestamp\": \"{{ new Date().toISOString() }}\"\n  }\n}"}}},{"type":"addConnection"},{"type":"addConnection"},{"type":"addConnection"},{"type":"addNode","node":{"id":"sticky-success-response","name":"Note12","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2540,-80],"parameters":{"content":"## ✨ Success Response\n\nMilestone 4: Final responses following API_RESPONSE_STANDARDS.md","height":160,"width":320,"color":5}}},{"type":"addNode","node":{"id":"sticky-error-handling","name":"Note13","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2300,880],"parameters":{"content":"## ⚠️ Error Handling\n\n500 errors for database failures and unexpected issues","height":140,"width":300,"color":2}}}]


workflow_id: ThD7S9hN0K1P5AZi
workflow_name: GET /chat/messages - List Messages
trigger: partial_update
created_at: 2025-10-24 12:13:06
workflow_snapshot:
  {"createdAt":"2025-10-24T12:06:35.080Z","updatedAt":"2025-10-24T12:11:22.000Z","id":"ThD7S9hN0K1P5AZi","name":"GET /chat/messages - List Messages","active":false,"isArchived":false,"nodes":[{"id":"webhook-trigger","name":"GET /chat/messages","type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[180,360],"parameters":{"httpMethod":"GET","path":"chat/messages","responseMode":"responseNode","options":{"allowedOrigins":"*"}},"webhookId":"chat-messages-list","onError":"continueRegularOutput"},{"id":"jwt-validation","name":"JWT Validation","type":"n8n-nodes-base.executeWorkflow","typeVersion":1.3,"position":[400,360],"parameters":{"source":"database","workflowId":"dL4gKHrO0Mtdhpmo"}},{"id":"auth-check","name":"Auth Failed?","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[620,360],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"auth-error-check","leftValue":"={{ $('JWT Validation').item.json.error }}","rightValue":"","operator":{"type":"object","operation":"notEmpty"}}]}}},{"id":"response-401","name":"401 Unauthorized","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[820,240],"parameters":{"respondWith":"json","responseCode":401,"responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"UNAUTHORIZED\",\n    \"message\": \"Invalid or expired access token\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"parse-validate-params","name":"Parse & Validate Query Params","type":"n8n-nodes-base.code","typeVersion":2,"position":[840,440],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get query parameters from webhook\nconst queryParams = $('GET /chat/messages').item.json.query || {};\nconst user_id = $('JWT Validation').item.json.user_id;\n\n// Extract parameters\nconst approach_id = queryParams.approach_id;\nconst patient_id = queryParams.patient_id || null;\nconst limit = parseInt(queryParams.limit) || 50;\nconst offset = parseInt(queryParams.offset) || 0;\nconst order = queryParams.order || 'asc';\n\n// Validation errors array\nconst errors = [];\n\n// Validate approach_id (required)\nif (!approach_id) {\n  errors.push({ field: 'approach_id', message: 'Missing required field: approach_id' });\n} else {\n  // UUID format validation\n  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n  if (!uuidRegex.test(approach_id)) {\n    errors.push({ field: 'approach_id', message: 'Invalid UUID format: approach_id' });\n  }\n}\n\n// Validate patient_id if provided\nif (patient_id) {\n  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n  if (!uuidRegex.test(patient_id)) {\n    errors.push({ field: 'patient_id', message: 'Invalid UUID format: patient_id' });\n  }\n}\n\n// Validate limit\nif (limit < 1 || limit > 100) {\n  errors.push({ field: 'limit', message: 'Limit must be between 1 and 100' });\n}\n\n// Validate offset\nif (offset < 0) {\n  errors.push({ field: 'offset', message: 'Offset must be >= 0' });\n}\n\n// Validate order\nif (order !== 'asc' && order !== 'desc') {\n  errors.push({ field: 'order', message: 'Order must be \"asc\" or \"desc\"' });\n}\n\n// Return validation result\nreturn [{\n  json: {\n    valid: errors.length === 0,\n    errors,\n    user_id,\n    approach_id,\n    patient_id,\n    limit,\n    offset,\n    order\n  }\n}];"}},{"id":"validation-check","name":"Validation Check","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1060,440],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"validation-failed","leftValue":"={{ $json.valid }}","rightValue":false,"operator":{"type":"boolean","operation":"equals"}}]}}},{"id":"response-400","name":"400 Bad Request","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1260,320],"parameters":{"respondWith":"json","responseCode":400,"responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"VALIDATION_ERROR\",\n    \"message\": $json.errors[0].message,\n    \"details\": $json.errors\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"lookup-thread-http","name":"Lookup Thread (HTTP)","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1460,520],"parameters":{"method":"GET","url":"https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_threads","authentication":"predefinedCredentialType","nodeCredentialType":"supabaseApi","sendQuery":true,"queryParameters":{"parameters":[{"name":"select","value":"id,user_id,patient_id,approach_id"},{"name":"user_id","value":"={{ 'eq.' + $('Parse & Validate Query Params').item.json.user_id }}"},{"name":"approach_id","value":"={{ 'eq.' + $('Parse & Validate Query Params').item.json.approach_id }}"},{"name":"patient_id","value":"={{ $('Parse & Validate Query Params').item.json.patient_id ? 'eq.' + $('Parse & Validate Query Params').item.json.patient_id : 'is.null' }}"},{"name":"status","value":"eq.active"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ 'Bearer ' + $('JWT Validation').item.json.access_token }}"}]},"options":{"response":{"response":{"responseFormat":"json"}},"timeout":10000}},"credentials":{"supabaseApi":{"id":"mdlcQ90gqxko069t","name":"Supabase Anon"}}},{"id":"thread-found-check","name":"Thread Found?","type":"n8n-nodes-base.if","typeVersion":2,"position":[1700,520],"parameters":{"conditions":{"conditions":[{"leftValue":"={{ $json.length }}","rightValue":0,"operator":{"type":"number","operation":"equals"}}]}}},{"id":"404-thread-not-found","name":"404 Thread Not Found","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[1900,400],"parameters":{"responseCode":404,"respondWith":"json","responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"NOT_FOUND\",\n    \"message\": \"Conversation thread not found. Please assign an approach to the patient first.\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"extract-thread-data","name":"Extract Thread Data","type":"n8n-nodes-base.code","typeVersion":2,"position":[1900,620],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get thread data from lookup result\nconst threadData = $input.first().json[0];\nconst queryParams = $('Parse & Validate Query Params').item.json;\n\n// Return thread info combined with query params\nreturn {\n  json: {\n    thread_id: threadData.id,\n    user_id: threadData.user_id,\n    patient_id: threadData.patient_id,\n    approach_id: threadData.approach_id,\n    limit: queryParams.limit,\n    offset: queryParams.offset,\n    order: queryParams.order\n  }\n};"}},{"id":"get-messages-http","name":"Get Messages (HTTP)","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2140,620],"parameters":{"method":"GET","url":"https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/messages","authentication":"predefinedCredentialType","nodeCredentialType":"supabaseApi","sendQuery":true,"queryParameters":{"parameters":[{"name":"select","value":"id,message,created_at"},{"name":"thread_id","value":"={{ 'eq.' + $('Extract Thread Data').item.json.thread_id }}"},{"name":"order","value":"={{ 'created_at.' + $('Extract Thread Data').item.json.order }}"},{"name":"limit","value":"={{ $('Extract Thread Data').item.json.limit }}"},{"name":"offset","value":"={{ $('Extract Thread Data').item.json.offset }}"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ 'Bearer ' + $('JWT Validation').item.json.access_token }}"},{"name":"Prefer","value":"count=exact"}]},"options":{"response":{"response":{"responseFormat":"json"}},"timeout":10000}},"credentials":{"supabaseApi":{"id":"mdlcQ90gqxko069t","name":"Supabase Anon"}}},{"id":"format-response","name":"Format Response","type":"n8n-nodes-base.code","typeVersion":2,"position":[2380,620],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get all messages from the database query\nconst messagesData = $input.all();\nconst threadData = $('Extract Thread Data').item.json;\n\n// Extract total count from Content-Range header\n// Format: \"0-49/150\" means showing items 0-49 out of 150 total\nconst contentRange = $('Get Messages (HTTP)').item.json.$response?.headers?.['content-range'];\nlet total = messagesData.length;\nif (contentRange) {\n  const match = contentRange.match(/\\/(\\d+)/);\n  if (match) {\n    total = parseInt(match[1]);\n  }\n}\n\n// Parse JSONB message field and format each message\nconst messages = messagesData.map(item => {\n  const msg = item.json.message || {};\n  return {\n    id: item.json.id,\n    role: msg.role || 'user',\n    content: msg.content || '',\n    tool_id: msg.tool_id || null,\n    metadata: msg.metadata || {},\n    created_at: item.json.created_at\n  };\n});\n\n// Calculate pagination metadata\nconst hasMore = (threadData.offset + messages.length) < total;\n\n// Build final response following API_RESPONSE_STANDARDS.md\nreturn {\n  json: {\n    success: true,\n    data: {\n      thread_id: threadData.thread_id,\n      patient_id: threadData.patient_id,\n      approach_id: threadData.approach_id,\n      messages: messages,\n      pagination: {\n        limit: threadData.limit,\n        offset: threadData.offset,\n        total: total,\n        hasMore: hasMore\n      }\n    },\n    metadata: {\n      timestamp: new Date().toISOString()\n    }\n  }\n};"}},{"id":"sticky-milestone-3","name":"Note4","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2060,-80],"parameters":{"content":"## 📬 Load Messages & Format\n\n**Milestone 3**: Query messages with pagination and format JSONB fields\n\n- Get messages from Supabase with filters\n- Parse JSONB message structure\n- Calculate pagination metadata\n- Format according to API standards","height":240,"width":360,"color":4}}],"connections":{"GET /chat/messages":{"main":[[{"node":"JWT Validation","type":"main","index":0}]]},"JWT Validation":{"main":[[{"node":"Auth Failed?","type":"main","index":0}]]},"Auth Failed?":{"main":[[{"node":"401 Unauthorized","type":"main","index":0}],[{"node":"Parse & Validate Query Params","type":"main","index":0}]]},"Parse & Validate Query Params":{"main":[[{"node":"Validation Check","type":"main","index":0}]]},"Validation Check":{"main":[[{"node":"400 Bad Request","type":"main","index":0}],[{"node":"Lookup Thread (HTTP)","type":"main","index":0}]]},"Lookup Thread (HTTP)":{"main":[[{"node":"Thread Found?","type":"main","index":0}]]},"Thread Found?":{"main":[[{"node":"404 Thread Not Found","type":"main","index":0}],[{"node":"Extract Thread Data","type":"main","index":0}]]},"Extract Thread Data":{"main":[[{"node":"Get Messages (HTTP)","type":"main","index":0}]]},"Get Messages (HTTP)":{"main":[[{"node":"Format Response","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"7e811ad9-3ad3-4694-91d1-0da3d16feb35","triggerCount":0,"shared":[{"createdAt":"2025-10-24T12:06:35.084Z","updatedAt":"2025-10-24T12:06:35.084Z","role":"workflow:owner","workflowId":"ThD7S9hN0K1P5AZi","projectId":"sVGwG1Ss6aXKNorC","project":{"createdAt":"2025-07-30T12:18:11.485Z","updatedAt":"2025-07-30T12:20:06.951Z","id":"sVGwG1Ss6aXKNorC","name":"Rafał Dębski <rdebski90@gmail.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-07-30T12:18:11.486Z","updatedAt":"2025-07-30T12:18:11.486Z","userId":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","projectId":"sVGwG1Ss6aXKNorC","user":{"createdAt":"2025-07-30T12:18:10.851Z","updatedAt":"2025-10-23T22:43:16.000Z","id":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","email":"rdebski90@gmail.com","firstName":"Rafał","lastName":"Dębski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-07-30T12:20:09.619Z","personalization_survey_n8n_version":"1.104.1"},"settings":{"userActivated":true,"easyAIWorkflowOnboarded":true,"firstSuccessfulWorkflowId":"gp796pP6j8IFZodb","userActivatedAt":1753881412699,"npsSurvey":{"responded":true,"lastShownAt":1755785806897},"dismissedCallouts":{"ragStarterCallout":true}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"id":"8cbfa0d4-2a39-427e-bd66-2ea3f7b52e14","name":"200 Success","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[2620,620],"parameters":{"responseCode":200,"respondWith":"json","responseBody":"={{ $json }}"}}},{"type":"addNode","node":{"id":"9dbeaf15-3b4c-428f-cf77-3fb4c8a53f15","name":"500 Internal Error","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[2380,780],"parameters":{"responseCode":500,"respondWith":"json","responseBody":"={\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INTERNAL_ERROR\",\n    \"message\": \"An unexpected error occurred. Please try again later.\"\n  },\n  \"metadata\": {\n    \"timestamp\": \"{{ new Date().toISOString() }}\"\n  }\n}"}}},{"type":"addConnection","source":"Format Response","target":"200 Success"},{"type":"addConnection","source":"Get Messages (HTTP)","target":"500 Internal Error","sourceOutput":"error"},{"type":"addConnection","source":"Lookup Thread (HTTP)","target":"500 Internal Error","sourceOutput":"error"},{"type":"addNode","node":{"id":"sticky-success-response","name":"Note12","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2540,-80],"parameters":{"content":"## ✨ Success Response\n\nMilestone 4: Final responses following API_RESPONSE_STANDARDS.md","height":160,"width":320,"color":5}}},{"type":"addNode","node":{"id":"sticky-error-handling","name":"Note13","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2300,880],"parameters":{"content":"## ⚠️ Error Handling\n\n500 errors for database failures and unexpected issues","height":140,"width":300,"color":2}}}]


workflow_id: ThD7S9hN0K1P5AZi
workflow_name: GET /chat/messages - List Messages
trigger: partial_update
created_at: 2025-10-24 12:13:19
workflow_snapshot:
  {"createdAt":"2025-10-24T12:06:35.080Z","updatedAt":"2025-10-24T12:11:22.000Z","id":"ThD7S9hN0K1P5AZi","name":"GET /chat/messages - List Messages","active":false,"isArchived":false,"nodes":[{"id":"webhook-trigger","name":"GET /chat/messages","type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[180,360],"parameters":{"httpMethod":"GET","path":"chat/messages","responseMode":"responseNode","options":{"allowedOrigins":"*"}},"webhookId":"chat-messages-list","onError":"continueRegularOutput"},{"id":"jwt-validation","name":"JWT Validation","type":"n8n-nodes-base.executeWorkflow","typeVersion":1.3,"position":[400,360],"parameters":{"source":"database","workflowId":"dL4gKHrO0Mtdhpmo"}},{"id":"auth-check","name":"Auth Failed?","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[620,360],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"auth-error-check","leftValue":"={{ $('JWT Validation').item.json.error }}","rightValue":"","operator":{"type":"object","operation":"notEmpty"}}]}}},{"id":"response-401","name":"401 Unauthorized","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[820,240],"parameters":{"respondWith":"json","responseCode":401,"responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"UNAUTHORIZED\",\n    \"message\": \"Invalid or expired access token\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"parse-validate-params","name":"Parse & Validate Query Params","type":"n8n-nodes-base.code","typeVersion":2,"position":[840,440],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get query parameters from webhook\nconst queryParams = $('GET /chat/messages').item.json.query || {};\nconst user_id = $('JWT Validation').item.json.user_id;\n\n// Extract parameters\nconst approach_id = queryParams.approach_id;\nconst patient_id = queryParams.patient_id || null;\nconst limit = parseInt(queryParams.limit) || 50;\nconst offset = parseInt(queryParams.offset) || 0;\nconst order = queryParams.order || 'asc';\n\n// Validation errors array\nconst errors = [];\n\n// Validate approach_id (required)\nif (!approach_id) {\n  errors.push({ field: 'approach_id', message: 'Missing required field: approach_id' });\n} else {\n  // UUID format validation\n  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n  if (!uuidRegex.test(approach_id)) {\n    errors.push({ field: 'approach_id', message: 'Invalid UUID format: approach_id' });\n  }\n}\n\n// Validate patient_id if provided\nif (patient_id) {\n  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n  if (!uuidRegex.test(patient_id)) {\n    errors.push({ field: 'patient_id', message: 'Invalid UUID format: patient_id' });\n  }\n}\n\n// Validate limit\nif (limit < 1 || limit > 100) {\n  errors.push({ field: 'limit', message: 'Limit must be between 1 and 100' });\n}\n\n// Validate offset\nif (offset < 0) {\n  errors.push({ field: 'offset', message: 'Offset must be >= 0' });\n}\n\n// Validate order\nif (order !== 'asc' && order !== 'desc') {\n  errors.push({ field: 'order', message: 'Order must be \"asc\" or \"desc\"' });\n}\n\n// Return validation result\nreturn [{\n  json: {\n    valid: errors.length === 0,\n    errors,\n    user_id,\n    approach_id,\n    patient_id,\n    limit,\n    offset,\n    order\n  }\n}];"}},{"id":"validation-check","name":"Validation Check","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1060,440],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"validation-failed","leftValue":"={{ $json.valid }}","rightValue":false,"operator":{"type":"boolean","operation":"equals"}}]}}},{"id":"response-400","name":"400 Bad Request","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1260,320],"parameters":{"respondWith":"json","responseCode":400,"responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"VALIDATION_ERROR\",\n    \"message\": $json.errors[0].message,\n    \"details\": $json.errors\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"lookup-thread-http","name":"Lookup Thread (HTTP)","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1460,520],"parameters":{"method":"GET","url":"https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_threads","authentication":"predefinedCredentialType","nodeCredentialType":"supabaseApi","sendQuery":true,"queryParameters":{"parameters":[{"name":"select","value":"id,user_id,patient_id,approach_id"},{"name":"user_id","value":"={{ 'eq.' + $('Parse & Validate Query Params').item.json.user_id }}"},{"name":"approach_id","value":"={{ 'eq.' + $('Parse & Validate Query Params').item.json.approach_id }}"},{"name":"patient_id","value":"={{ $('Parse & Validate Query Params').item.json.patient_id ? 'eq.' + $('Parse & Validate Query Params').item.json.patient_id : 'is.null' }}"},{"name":"status","value":"eq.active"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ 'Bearer ' + $('JWT Validation').item.json.access_token }}"}]},"options":{"response":{"response":{"responseFormat":"json"}},"timeout":10000}},"credentials":{"supabaseApi":{"id":"mdlcQ90gqxko069t","name":"Supabase Anon"}}},{"id":"thread-found-check","name":"Thread Found?","type":"n8n-nodes-base.if","typeVersion":2,"position":[1700,520],"parameters":{"conditions":{"conditions":[{"leftValue":"={{ $json.length }}","rightValue":0,"operator":{"type":"number","operation":"equals"}}]}}},{"id":"404-thread-not-found","name":"404 Thread Not Found","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[1900,400],"parameters":{"responseCode":404,"respondWith":"json","responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"NOT_FOUND\",\n    \"message\": \"Conversation thread not found. Please assign an approach to the patient first.\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"extract-thread-data","name":"Extract Thread Data","type":"n8n-nodes-base.code","typeVersion":2,"position":[1900,620],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get thread data from lookup result\nconst threadData = $input.first().json[0];\nconst queryParams = $('Parse & Validate Query Params').item.json;\n\n// Return thread info combined with query params\nreturn {\n  json: {\n    thread_id: threadData.id,\n    user_id: threadData.user_id,\n    patient_id: threadData.patient_id,\n    approach_id: threadData.approach_id,\n    limit: queryParams.limit,\n    offset: queryParams.offset,\n    order: queryParams.order\n  }\n};"}},{"id":"get-messages-http","name":"Get Messages (HTTP)","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2140,620],"parameters":{"method":"GET","url":"https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/messages","authentication":"predefinedCredentialType","nodeCredentialType":"supabaseApi","sendQuery":true,"queryParameters":{"parameters":[{"name":"select","value":"id,message,created_at"},{"name":"thread_id","value":"={{ 'eq.' + $('Extract Thread Data').item.json.thread_id }}"},{"name":"order","value":"={{ 'created_at.' + $('Extract Thread Data').item.json.order }}"},{"name":"limit","value":"={{ $('Extract Thread Data').item.json.limit }}"},{"name":"offset","value":"={{ $('Extract Thread Data').item.json.offset }}"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ 'Bearer ' + $('JWT Validation').item.json.access_token }}"},{"name":"Prefer","value":"count=exact"}]},"options":{"response":{"response":{"responseFormat":"json"}},"timeout":10000}},"credentials":{"supabaseApi":{"id":"mdlcQ90gqxko069t","name":"Supabase Anon"}}},{"id":"format-response","name":"Format Response","type":"n8n-nodes-base.code","typeVersion":2,"position":[2380,620],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get all messages from the database query\nconst messagesData = $input.all();\nconst threadData = $('Extract Thread Data').item.json;\n\n// Extract total count from Content-Range header\n// Format: \"0-49/150\" means showing items 0-49 out of 150 total\nconst contentRange = $('Get Messages (HTTP)').item.json.$response?.headers?.['content-range'];\nlet total = messagesData.length;\nif (contentRange) {\n  const match = contentRange.match(/\\/(\\d+)/);\n  if (match) {\n    total = parseInt(match[1]);\n  }\n}\n\n// Parse JSONB message field and format each message\nconst messages = messagesData.map(item => {\n  const msg = item.json.message || {};\n  return {\n    id: item.json.id,\n    role: msg.role || 'user',\n    content: msg.content || '',\n    tool_id: msg.tool_id || null,\n    metadata: msg.metadata || {},\n    created_at: item.json.created_at\n  };\n});\n\n// Calculate pagination metadata\nconst hasMore = (threadData.offset + messages.length) < total;\n\n// Build final response following API_RESPONSE_STANDARDS.md\nreturn {\n  json: {\n    success: true,\n    data: {\n      thread_id: threadData.thread_id,\n      patient_id: threadData.patient_id,\n      approach_id: threadData.approach_id,\n      messages: messages,\n      pagination: {\n        limit: threadData.limit,\n        offset: threadData.offset,\n        total: total,\n        hasMore: hasMore\n      }\n    },\n    metadata: {\n      timestamp: new Date().toISOString()\n    }\n  }\n};"}},{"id":"sticky-milestone-3","name":"Note4","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2060,-80],"parameters":{"content":"## 📬 Load Messages & Format\n\n**Milestone 3**: Query messages with pagination and format JSONB fields\n\n- Get messages from Supabase with filters\n- Parse JSONB message structure\n- Calculate pagination metadata\n- Format according to API standards","height":240,"width":360,"color":4}}],"connections":{"GET /chat/messages":{"main":[[{"node":"JWT Validation","type":"main","index":0}]]},"JWT Validation":{"main":[[{"node":"Auth Failed?","type":"main","index":0}]]},"Auth Failed?":{"main":[[{"node":"401 Unauthorized","type":"main","index":0}],[{"node":"Parse & Validate Query Params","type":"main","index":0}]]},"Parse & Validate Query Params":{"main":[[{"node":"Validation Check","type":"main","index":0}]]},"Validation Check":{"main":[[{"node":"400 Bad Request","type":"main","index":0}],[{"node":"Lookup Thread (HTTP)","type":"main","index":0}]]},"Lookup Thread (HTTP)":{"main":[[{"node":"Thread Found?","type":"main","index":0}]]},"Thread Found?":{"main":[[{"node":"404 Thread Not Found","type":"main","index":0}],[{"node":"Extract Thread Data","type":"main","index":0}]]},"Extract Thread Data":{"main":[[{"node":"Get Messages (HTTP)","type":"main","index":0}]]},"Get Messages (HTTP)":{"main":[[{"node":"Format Response","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"7e811ad9-3ad3-4694-91d1-0da3d16feb35","triggerCount":0,"shared":[{"createdAt":"2025-10-24T12:06:35.084Z","updatedAt":"2025-10-24T12:06:35.084Z","role":"workflow:owner","workflowId":"ThD7S9hN0K1P5AZi","projectId":"sVGwG1Ss6aXKNorC","project":{"createdAt":"2025-07-30T12:18:11.485Z","updatedAt":"2025-07-30T12:20:06.951Z","id":"sVGwG1Ss6aXKNorC","name":"Rafał Dębski <rdebski90@gmail.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-07-30T12:18:11.486Z","updatedAt":"2025-07-30T12:18:11.486Z","userId":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","projectId":"sVGwG1Ss6aXKNorC","user":{"createdAt":"2025-07-30T12:18:10.851Z","updatedAt":"2025-10-23T22:43:16.000Z","id":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","email":"rdebski90@gmail.com","firstName":"Rafał","lastName":"Dębski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-07-30T12:20:09.619Z","personalization_survey_n8n_version":"1.104.1"},"settings":{"userActivated":true,"easyAIWorkflowOnboarded":true,"firstSuccessfulWorkflowId":"gp796pP6j8IFZodb","userActivatedAt":1753881412699,"npsSurvey":{"responded":true,"lastShownAt":1755785806897},"dismissedCallouts":{"ragStarterCallout":true}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"id":"8cbfa0d4-2a39-427e-bd66-2ea3f7b52e14","name":"200 Success","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[2620,620],"parameters":{"responseCode":200,"respondWith":"json","responseBody":"={{ $json }}"}}},{"type":"addConnection","source":"Format Response","target":"200 Success"},{"type":"addNode","node":{"id":"sticky-success-response","name":"Note12","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2540,-80],"parameters":{"content":"## ✨ Success Response\n\nMilestone 4: Final responses following API_RESPONSE_STANDARDS.md","height":160,"width":320,"color":5}}}]


workflow_id: ThD7S9hN0K1P5AZi
workflow_name: GET /chat/messages - List Messages
trigger: partial_update
created_at: 2025-10-24 12:13:30
workflow_snapshot:
  {"createdAt":"2025-10-24T12:06:35.080Z","updatedAt":"2025-10-24T12:13:20.065Z","id":"ThD7S9hN0K1P5AZi","name":"GET /chat/messages - List Messages","active":false,"isArchived":false,"nodes":[{"id":"webhook-trigger","name":"GET /chat/messages","type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[180,360],"parameters":{"httpMethod":"GET","path":"chat/messages","responseMode":"responseNode","options":{"allowedOrigins":"*"}},"webhookId":"chat-messages-list","onError":"continueRegularOutput"},{"id":"jwt-validation","name":"JWT Validation","type":"n8n-nodes-base.executeWorkflow","typeVersion":1.3,"position":[400,360],"parameters":{"source":"database","workflowId":"dL4gKHrO0Mtdhpmo"}},{"id":"auth-check","name":"Auth Failed?","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[620,360],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"auth-error-check","leftValue":"={{ $('JWT Validation').item.json.error }}","rightValue":"","operator":{"type":"object","operation":"notEmpty"}}]}}},{"id":"response-401","name":"401 Unauthorized","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[820,240],"parameters":{"respondWith":"json","responseCode":401,"responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"UNAUTHORIZED\",\n    \"message\": \"Invalid or expired access token\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"parse-validate-params","name":"Parse & Validate Query Params","type":"n8n-nodes-base.code","typeVersion":2,"position":[840,440],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get query parameters from webhook\nconst queryParams = $('GET /chat/messages').item.json.query || {};\nconst user_id = $('JWT Validation').item.json.user_id;\n\n// Extract parameters\nconst approach_id = queryParams.approach_id;\nconst patient_id = queryParams.patient_id || null;\nconst limit = parseInt(queryParams.limit) || 50;\nconst offset = parseInt(queryParams.offset) || 0;\nconst order = queryParams.order || 'asc';\n\n// Validation errors array\nconst errors = [];\n\n// Validate approach_id (required)\nif (!approach_id) {\n  errors.push({ field: 'approach_id', message: 'Missing required field: approach_id' });\n} else {\n  // UUID format validation\n  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n  if (!uuidRegex.test(approach_id)) {\n    errors.push({ field: 'approach_id', message: 'Invalid UUID format: approach_id' });\n  }\n}\n\n// Validate patient_id if provided\nif (patient_id) {\n  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n  if (!uuidRegex.test(patient_id)) {\n    errors.push({ field: 'patient_id', message: 'Invalid UUID format: patient_id' });\n  }\n}\n\n// Validate limit\nif (limit < 1 || limit > 100) {\n  errors.push({ field: 'limit', message: 'Limit must be between 1 and 100' });\n}\n\n// Validate offset\nif (offset < 0) {\n  errors.push({ field: 'offset', message: 'Offset must be >= 0' });\n}\n\n// Validate order\nif (order !== 'asc' && order !== 'desc') {\n  errors.push({ field: 'order', message: 'Order must be \"asc\" or \"desc\"' });\n}\n\n// Return validation result\nreturn [{\n  json: {\n    valid: errors.length === 0,\n    errors,\n    user_id,\n    approach_id,\n    patient_id,\n    limit,\n    offset,\n    order\n  }\n}];"}},{"id":"validation-check","name":"Validation Check","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1060,440],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"validation-failed","leftValue":"={{ $json.valid }}","rightValue":false,"operator":{"type":"boolean","operation":"equals"}}]}}},{"id":"response-400","name":"400 Bad Request","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1260,320],"parameters":{"respondWith":"json","responseCode":400,"responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"VALIDATION_ERROR\",\n    \"message\": $json.errors[0].message,\n    \"details\": $json.errors\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"lookup-thread-http","name":"Lookup Thread (HTTP)","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1460,520],"parameters":{"method":"GET","url":"https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_threads","authentication":"predefinedCredentialType","nodeCredentialType":"supabaseApi","sendQuery":true,"queryParameters":{"parameters":[{"name":"select","value":"id,user_id,patient_id,approach_id"},{"name":"user_id","value":"={{ 'eq.' + $('Parse & Validate Query Params').item.json.user_id }}"},{"name":"approach_id","value":"={{ 'eq.' + $('Parse & Validate Query Params').item.json.approach_id }}"},{"name":"patient_id","value":"={{ $('Parse & Validate Query Params').item.json.patient_id ? 'eq.' + $('Parse & Validate Query Params').item.json.patient_id : 'is.null' }}"},{"name":"status","value":"eq.active"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ 'Bearer ' + $('JWT Validation').item.json.access_token }}"}]},"options":{"response":{"response":{"responseFormat":"json"}},"timeout":10000}},"credentials":{"supabaseApi":{"id":"mdlcQ90gqxko069t","name":"Supabase Anon"}}},{"id":"thread-found-check","name":"Thread Found?","type":"n8n-nodes-base.if","typeVersion":2,"position":[1700,520],"parameters":{"conditions":{"conditions":[{"leftValue":"={{ $json.length }}","rightValue":0,"operator":{"type":"number","operation":"equals"}}]}}},{"id":"404-thread-not-found","name":"404 Thread Not Found","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[1900,400],"parameters":{"responseCode":404,"respondWith":"json","responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"NOT_FOUND\",\n    \"message\": \"Conversation thread not found. Please assign an approach to the patient first.\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"extract-thread-data","name":"Extract Thread Data","type":"n8n-nodes-base.code","typeVersion":2,"position":[1900,620],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get thread data from lookup result\nconst threadData = $input.first().json[0];\nconst queryParams = $('Parse & Validate Query Params').item.json;\n\n// Return thread info combined with query params\nreturn {\n  json: {\n    thread_id: threadData.id,\n    user_id: threadData.user_id,\n    patient_id: threadData.patient_id,\n    approach_id: threadData.approach_id,\n    limit: queryParams.limit,\n    offset: queryParams.offset,\n    order: queryParams.order\n  }\n};"}},{"id":"get-messages-http","name":"Get Messages (HTTP)","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2140,620],"parameters":{"method":"GET","url":"https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/messages","authentication":"predefinedCredentialType","nodeCredentialType":"supabaseApi","sendQuery":true,"queryParameters":{"parameters":[{"name":"select","value":"id,message,created_at"},{"name":"thread_id","value":"={{ 'eq.' + $('Extract Thread Data').item.json.thread_id }}"},{"name":"order","value":"={{ 'created_at.' + $('Extract Thread Data').item.json.order }}"},{"name":"limit","value":"={{ $('Extract Thread Data').item.json.limit }}"},{"name":"offset","value":"={{ $('Extract Thread Data').item.json.offset }}"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ 'Bearer ' + $('JWT Validation').item.json.access_token }}"},{"name":"Prefer","value":"count=exact"}]},"options":{"response":{"response":{"responseFormat":"json"}},"timeout":10000}},"credentials":{"supabaseApi":{"id":"mdlcQ90gqxko069t","name":"Supabase Anon"}}},{"id":"format-response","name":"Format Response","type":"n8n-nodes-base.code","typeVersion":2,"position":[2380,620],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get all messages from the database query\nconst messagesData = $input.all();\nconst threadData = $('Extract Thread Data').item.json;\n\n// Extract total count from Content-Range header\n// Format: \"0-49/150\" means showing items 0-49 out of 150 total\nconst contentRange = $('Get Messages (HTTP)').item.json.$response?.headers?.['content-range'];\nlet total = messagesData.length;\nif (contentRange) {\n  const match = contentRange.match(/\\/(\\d+)/);\n  if (match) {\n    total = parseInt(match[1]);\n  }\n}\n\n// Parse JSONB message field and format each message\nconst messages = messagesData.map(item => {\n  const msg = item.json.message || {};\n  return {\n    id: item.json.id,\n    role: msg.role || 'user',\n    content: msg.content || '',\n    tool_id: msg.tool_id || null,\n    metadata: msg.metadata || {},\n    created_at: item.json.created_at\n  };\n});\n\n// Calculate pagination metadata\nconst hasMore = (threadData.offset + messages.length) < total;\n\n// Build final response following API_RESPONSE_STANDARDS.md\nreturn {\n  json: {\n    success: true,\n    data: {\n      thread_id: threadData.thread_id,\n      patient_id: threadData.patient_id,\n      approach_id: threadData.approach_id,\n      messages: messages,\n      pagination: {\n        limit: threadData.limit,\n        offset: threadData.offset,\n        total: total,\n        hasMore: hasMore\n      }\n    },\n    metadata: {\n      timestamp: new Date().toISOString()\n    }\n  }\n};"}},{"id":"sticky-milestone-3","name":"Note4","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2060,-80],"parameters":{"content":"## 📬 Load Messages & Format\n\n**Milestone 3**: Query messages with pagination and format JSONB fields\n\n- Get messages from Supabase with filters\n- Parse JSONB message structure\n- Calculate pagination metadata\n- Format according to API standards","height":240,"width":360,"color":4}},{"id":"8cbfa0d4-2a39-427e-bd66-2ea3f7b52e14","name":"200 Success","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[2620,620],"parameters":{"responseCode":200,"respondWith":"json","responseBody":"={{ $json }}"}},{"id":"sticky-success-response","name":"Note12","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2540,-80],"parameters":{"content":"## ✨ Success Response\n\nMilestone 4: Final responses following API_RESPONSE_STANDARDS.md","height":160,"width":320,"color":5}}],"connections":{"GET /chat/messages":{"main":[[{"node":"JWT Validation","type":"main","index":0}]]},"JWT Validation":{"main":[[{"node":"Auth Failed?","type":"main","index":0}]]},"Auth Failed?":{"main":[[{"node":"401 Unauthorized","type":"main","index":0}],[{"node":"Parse & Validate Query Params","type":"main","index":0}]]},"Parse & Validate Query Params":{"main":[[{"node":"Validation Check","type":"main","index":0}]]},"Validation Check":{"main":[[{"node":"400 Bad Request","type":"main","index":0}],[{"node":"Lookup Thread (HTTP)","type":"main","index":0}]]},"Lookup Thread (HTTP)":{"main":[[{"node":"Thread Found?","type":"main","index":0}]]},"Thread Found?":{"main":[[{"node":"404 Thread Not Found","type":"main","index":0}],[{"node":"Extract Thread Data","type":"main","index":0}]]},"Extract Thread Data":{"main":[[{"node":"Get Messages (HTTP)","type":"main","index":0}]]},"Get Messages (HTTP)":{"main":[[{"node":"Format Response","type":"main","index":0}]]},"Format Response":{"main":[[{"node":"200 Success","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"c6108b20-4a3d-4cfb-8879-b2d7c9fbf2d7","triggerCount":0,"shared":[{"createdAt":"2025-10-24T12:06:35.084Z","updatedAt":"2025-10-24T12:06:35.084Z","role":"workflow:owner","workflowId":"ThD7S9hN0K1P5AZi","projectId":"sVGwG1Ss6aXKNorC","project":{"createdAt":"2025-07-30T12:18:11.485Z","updatedAt":"2025-07-30T12:20:06.951Z","id":"sVGwG1Ss6aXKNorC","name":"Rafał Dębski <rdebski90@gmail.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-07-30T12:18:11.486Z","updatedAt":"2025-07-30T12:18:11.486Z","userId":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","projectId":"sVGwG1Ss6aXKNorC","user":{"createdAt":"2025-07-30T12:18:10.851Z","updatedAt":"2025-10-23T22:43:16.000Z","id":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","email":"rdebski90@gmail.com","firstName":"Rafał","lastName":"Dębski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-07-30T12:20:09.619Z","personalization_survey_n8n_version":"1.104.1"},"settings":{"userActivated":true,"easyAIWorkflowOnboarded":true,"firstSuccessfulWorkflowId":"gp796pP6j8IFZodb","userActivatedAt":1753881412699,"npsSurvey":{"responded":true,"lastShownAt":1755785806897},"dismissedCallouts":{"ragStarterCallout":true}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"id":"9dbeaf15-3b4c-428f-cf77-3fb4c8a53f15","name":"500 Internal Error","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[2140,800],"parameters":{"responseCode":500,"respondWith":"json","responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INTERNAL_ERROR\",\n    \"message\": \"An unexpected error occurred. Please try again later.\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}}},{"type":"addNode","node":{"id":"sticky-error-handling","name":"Note13","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2060,900],"parameters":{"content":"## ⚠️ Error Handling\n\n500 errors for database failures and unexpected issues","height":140,"width":300,"color":2}}}]


workflow_id: ThD7S9hN0K1P5AZi
workflow_name: GET /chat/messages - List Messages
trigger: partial_update
created_at: 2025-10-24 12:13:38
workflow_snapshot:
  {"createdAt":"2025-10-24T12:06:35.080Z","updatedAt":"2025-10-24T12:13:20.065Z","id":"ThD7S9hN0K1P5AZi","name":"GET /chat/messages - List Messages","active":false,"isArchived":false,"nodes":[{"id":"webhook-trigger","name":"GET /chat/messages","type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[180,360],"parameters":{"httpMethod":"GET","path":"chat/messages","responseMode":"responseNode","options":{"allowedOrigins":"*"}},"webhookId":"chat-messages-list","onError":"continueRegularOutput"},{"id":"jwt-validation","name":"JWT Validation","type":"n8n-nodes-base.executeWorkflow","typeVersion":1.3,"position":[400,360],"parameters":{"source":"database","workflowId":"dL4gKHrO0Mtdhpmo"}},{"id":"auth-check","name":"Auth Failed?","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[620,360],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"auth-error-check","leftValue":"={{ $('JWT Validation').item.json.error }}","rightValue":"","operator":{"type":"object","operation":"notEmpty"}}]}}},{"id":"response-401","name":"401 Unauthorized","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[820,240],"parameters":{"respondWith":"json","responseCode":401,"responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"UNAUTHORIZED\",\n    \"message\": \"Invalid or expired access token\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"parse-validate-params","name":"Parse & Validate Query Params","type":"n8n-nodes-base.code","typeVersion":2,"position":[840,440],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get query parameters from webhook\nconst queryParams = $('GET /chat/messages').item.json.query || {};\nconst user_id = $('JWT Validation').item.json.user_id;\n\n// Extract parameters\nconst approach_id = queryParams.approach_id;\nconst patient_id = queryParams.patient_id || null;\nconst limit = parseInt(queryParams.limit) || 50;\nconst offset = parseInt(queryParams.offset) || 0;\nconst order = queryParams.order || 'asc';\n\n// Validation errors array\nconst errors = [];\n\n// Validate approach_id (required)\nif (!approach_id) {\n  errors.push({ field: 'approach_id', message: 'Missing required field: approach_id' });\n} else {\n  // UUID format validation\n  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n  if (!uuidRegex.test(approach_id)) {\n    errors.push({ field: 'approach_id', message: 'Invalid UUID format: approach_id' });\n  }\n}\n\n// Validate patient_id if provided\nif (patient_id) {\n  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n  if (!uuidRegex.test(patient_id)) {\n    errors.push({ field: 'patient_id', message: 'Invalid UUID format: patient_id' });\n  }\n}\n\n// Validate limit\nif (limit < 1 || limit > 100) {\n  errors.push({ field: 'limit', message: 'Limit must be between 1 and 100' });\n}\n\n// Validate offset\nif (offset < 0) {\n  errors.push({ field: 'offset', message: 'Offset must be >= 0' });\n}\n\n// Validate order\nif (order !== 'asc' && order !== 'desc') {\n  errors.push({ field: 'order', message: 'Order must be \"asc\" or \"desc\"' });\n}\n\n// Return validation result\nreturn [{\n  json: {\n    valid: errors.length === 0,\n    errors,\n    user_id,\n    approach_id,\n    patient_id,\n    limit,\n    offset,\n    order\n  }\n}];"}},{"id":"validation-check","name":"Validation Check","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1060,440],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"validation-failed","leftValue":"={{ $json.valid }}","rightValue":false,"operator":{"type":"boolean","operation":"equals"}}]}}},{"id":"response-400","name":"400 Bad Request","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1260,320],"parameters":{"respondWith":"json","responseCode":400,"responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"VALIDATION_ERROR\",\n    \"message\": $json.errors[0].message,\n    \"details\": $json.errors\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"lookup-thread-http","name":"Lookup Thread (HTTP)","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1460,520],"parameters":{"method":"GET","url":"https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_threads","authentication":"predefinedCredentialType","nodeCredentialType":"supabaseApi","sendQuery":true,"queryParameters":{"parameters":[{"name":"select","value":"id,user_id,patient_id,approach_id"},{"name":"user_id","value":"={{ 'eq.' + $('Parse & Validate Query Params').item.json.user_id }}"},{"name":"approach_id","value":"={{ 'eq.' + $('Parse & Validate Query Params').item.json.approach_id }}"},{"name":"patient_id","value":"={{ $('Parse & Validate Query Params').item.json.patient_id ? 'eq.' + $('Parse & Validate Query Params').item.json.patient_id : 'is.null' }}"},{"name":"status","value":"eq.active"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ 'Bearer ' + $('JWT Validation').item.json.access_token }}"}]},"options":{"response":{"response":{"responseFormat":"json"}},"timeout":10000}},"credentials":{"supabaseApi":{"id":"mdlcQ90gqxko069t","name":"Supabase Anon"}}},{"id":"thread-found-check","name":"Thread Found?","type":"n8n-nodes-base.if","typeVersion":2,"position":[1700,520],"parameters":{"conditions":{"conditions":[{"leftValue":"={{ $json.length }}","rightValue":0,"operator":{"type":"number","operation":"equals"}}]}}},{"id":"404-thread-not-found","name":"404 Thread Not Found","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[1900,400],"parameters":{"responseCode":404,"respondWith":"json","responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"NOT_FOUND\",\n    \"message\": \"Conversation thread not found. Please assign an approach to the patient first.\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"extract-thread-data","name":"Extract Thread Data","type":"n8n-nodes-base.code","typeVersion":2,"position":[1900,620],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get thread data from lookup result\nconst threadData = $input.first().json[0];\nconst queryParams = $('Parse & Validate Query Params').item.json;\n\n// Return thread info combined with query params\nreturn {\n  json: {\n    thread_id: threadData.id,\n    user_id: threadData.user_id,\n    patient_id: threadData.patient_id,\n    approach_id: threadData.approach_id,\n    limit: queryParams.limit,\n    offset: queryParams.offset,\n    order: queryParams.order\n  }\n};"}},{"id":"get-messages-http","name":"Get Messages (HTTP)","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2140,620],"parameters":{"method":"GET","url":"https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/messages","authentication":"predefinedCredentialType","nodeCredentialType":"supabaseApi","sendQuery":true,"queryParameters":{"parameters":[{"name":"select","value":"id,message,created_at"},{"name":"thread_id","value":"={{ 'eq.' + $('Extract Thread Data').item.json.thread_id }}"},{"name":"order","value":"={{ 'created_at.' + $('Extract Thread Data').item.json.order }}"},{"name":"limit","value":"={{ $('Extract Thread Data').item.json.limit }}"},{"name":"offset","value":"={{ $('Extract Thread Data').item.json.offset }}"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ 'Bearer ' + $('JWT Validation').item.json.access_token }}"},{"name":"Prefer","value":"count=exact"}]},"options":{"response":{"response":{"responseFormat":"json"}},"timeout":10000}},"credentials":{"supabaseApi":{"id":"mdlcQ90gqxko069t","name":"Supabase Anon"}}},{"id":"format-response","name":"Format Response","type":"n8n-nodes-base.code","typeVersion":2,"position":[2380,620],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get all messages from the database query\nconst messagesData = $input.all();\nconst threadData = $('Extract Thread Data').item.json;\n\n// Extract total count from Content-Range header\n// Format: \"0-49/150\" means showing items 0-49 out of 150 total\nconst contentRange = $('Get Messages (HTTP)').item.json.$response?.headers?.['content-range'];\nlet total = messagesData.length;\nif (contentRange) {\n  const match = contentRange.match(/\\/(\\d+)/);\n  if (match) {\n    total = parseInt(match[1]);\n  }\n}\n\n// Parse JSONB message field and format each message\nconst messages = messagesData.map(item => {\n  const msg = item.json.message || {};\n  return {\n    id: item.json.id,\n    role: msg.role || 'user',\n    content: msg.content || '',\n    tool_id: msg.tool_id || null,\n    metadata: msg.metadata || {},\n    created_at: item.json.created_at\n  };\n});\n\n// Calculate pagination metadata\nconst hasMore = (threadData.offset + messages.length) < total;\n\n// Build final response following API_RESPONSE_STANDARDS.md\nreturn {\n  json: {\n    success: true,\n    data: {\n      thread_id: threadData.thread_id,\n      patient_id: threadData.patient_id,\n      approach_id: threadData.approach_id,\n      messages: messages,\n      pagination: {\n        limit: threadData.limit,\n        offset: threadData.offset,\n        total: total,\n        hasMore: hasMore\n      }\n    },\n    metadata: {\n      timestamp: new Date().toISOString()\n    }\n  }\n};"}},{"id":"sticky-milestone-3","name":"Note4","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2060,-80],"parameters":{"content":"## 📬 Load Messages & Format\n\n**Milestone 3**: Query messages with pagination and format JSONB fields\n\n- Get messages from Supabase with filters\n- Parse JSONB message structure\n- Calculate pagination metadata\n- Format according to API standards","height":240,"width":360,"color":4}},{"id":"8cbfa0d4-2a39-427e-bd66-2ea3f7b52e14","name":"200 Success","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[2620,620],"parameters":{"responseCode":200,"respondWith":"json","responseBody":"={{ $json }}"}},{"id":"sticky-success-response","name":"Note12","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2540,-80],"parameters":{"content":"## ✨ Success Response\n\nMilestone 4: Final responses following API_RESPONSE_STANDARDS.md","height":160,"width":320,"color":5}}],"connections":{"GET /chat/messages":{"main":[[{"node":"JWT Validation","type":"main","index":0}]]},"JWT Validation":{"main":[[{"node":"Auth Failed?","type":"main","index":0}]]},"Auth Failed?":{"main":[[{"node":"401 Unauthorized","type":"main","index":0}],[{"node":"Parse & Validate Query Params","type":"main","index":0}]]},"Parse & Validate Query Params":{"main":[[{"node":"Validation Check","type":"main","index":0}]]},"Validation Check":{"main":[[{"node":"400 Bad Request","type":"main","index":0}],[{"node":"Lookup Thread (HTTP)","type":"main","index":0}]]},"Lookup Thread (HTTP)":{"main":[[{"node":"Thread Found?","type":"main","index":0}]]},"Thread Found?":{"main":[[{"node":"404 Thread Not Found","type":"main","index":0}],[{"node":"Extract Thread Data","type":"main","index":0}]]},"Extract Thread Data":{"main":[[{"node":"Get Messages (HTTP)","type":"main","index":0}]]},"Get Messages (HTTP)":{"main":[[{"node":"Format Response","type":"main","index":0}]]},"Format Response":{"main":[[{"node":"200 Success","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"c6108b20-4a3d-4cfb-8879-b2d7c9fbf2d7","triggerCount":0,"shared":[{"createdAt":"2025-10-24T12:06:35.084Z","updatedAt":"2025-10-24T12:06:35.084Z","role":"workflow:owner","workflowId":"ThD7S9hN0K1P5AZi","projectId":"sVGwG1Ss6aXKNorC","project":{"createdAt":"2025-07-30T12:18:11.485Z","updatedAt":"2025-07-30T12:20:06.951Z","id":"sVGwG1Ss6aXKNorC","name":"Rafał Dębski <rdebski90@gmail.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-07-30T12:18:11.486Z","updatedAt":"2025-07-30T12:18:11.486Z","userId":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","projectId":"sVGwG1Ss6aXKNorC","user":{"createdAt":"2025-07-30T12:18:10.851Z","updatedAt":"2025-10-23T22:43:16.000Z","id":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","email":"rdebski90@gmail.com","firstName":"Rafał","lastName":"Dębski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-07-30T12:20:09.619Z","personalization_survey_n8n_version":"1.104.1"},"settings":{"userActivated":true,"easyAIWorkflowOnboarded":true,"firstSuccessfulWorkflowId":"gp796pP6j8IFZodb","userActivatedAt":1753881412699,"npsSurvey":{"responded":true,"lastShownAt":1755785806897},"dismissedCallouts":{"ragStarterCallout":true}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"id":"9dbeaf15-3b4c-428f-cf77-3fb4c8a53f15","name":"500 Internal Error","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[2140,800],"parameters":{"responseCode":500,"respondWith":"json","responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INTERNAL_ERROR\",\n    \"message\": \"An unexpected error occurred. Please try again later.\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}}},{"type":"addConnection","source":"Get Messages (HTTP)","target":"500 Internal Error","sourceOutput":"error"},{"type":"addConnection","source":"Lookup Thread (HTTP)","target":"500 Internal Error","sourceOutput":"error"},{"type":"addNode","node":{"id":"sticky-error-handling","name":"Note13","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2060,900],"parameters":{"content":"## ⚠️ Error Handling\n\n500 errors for database failures and unexpected issues","height":140,"width":300,"color":2}}}]


workflow_id: ThD7S9hN0K1P5AZi
workflow_name: GET /chat/messages - List Messages
trigger: partial_update
created_at: 2025-10-24 12:13:56
workflow_snapshot:
  {"createdAt":"2025-10-24T12:06:35.080Z","updatedAt":"2025-10-24T12:13:20.065Z","id":"ThD7S9hN0K1P5AZi","name":"GET /chat/messages - List Messages","active":false,"isArchived":false,"nodes":[{"id":"webhook-trigger","name":"GET /chat/messages","type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[180,360],"parameters":{"httpMethod":"GET","path":"chat/messages","responseMode":"responseNode","options":{"allowedOrigins":"*"}},"webhookId":"chat-messages-list","onError":"continueRegularOutput"},{"id":"jwt-validation","name":"JWT Validation","type":"n8n-nodes-base.executeWorkflow","typeVersion":1.3,"position":[400,360],"parameters":{"source":"database","workflowId":"dL4gKHrO0Mtdhpmo"}},{"id":"auth-check","name":"Auth Failed?","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[620,360],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"auth-error-check","leftValue":"={{ $('JWT Validation').item.json.error }}","rightValue":"","operator":{"type":"object","operation":"notEmpty"}}]}}},{"id":"response-401","name":"401 Unauthorized","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[820,240],"parameters":{"respondWith":"json","responseCode":401,"responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"UNAUTHORIZED\",\n    \"message\": \"Invalid or expired access token\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"parse-validate-params","name":"Parse & Validate Query Params","type":"n8n-nodes-base.code","typeVersion":2,"position":[840,440],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get query parameters from webhook\nconst queryParams = $('GET /chat/messages').item.json.query || {};\nconst user_id = $('JWT Validation').item.json.user_id;\n\n// Extract parameters\nconst approach_id = queryParams.approach_id;\nconst patient_id = queryParams.patient_id || null;\nconst limit = parseInt(queryParams.limit) || 50;\nconst offset = parseInt(queryParams.offset) || 0;\nconst order = queryParams.order || 'asc';\n\n// Validation errors array\nconst errors = [];\n\n// Validate approach_id (required)\nif (!approach_id) {\n  errors.push({ field: 'approach_id', message: 'Missing required field: approach_id' });\n} else {\n  // UUID format validation\n  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n  if (!uuidRegex.test(approach_id)) {\n    errors.push({ field: 'approach_id', message: 'Invalid UUID format: approach_id' });\n  }\n}\n\n// Validate patient_id if provided\nif (patient_id) {\n  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n  if (!uuidRegex.test(patient_id)) {\n    errors.push({ field: 'patient_id', message: 'Invalid UUID format: patient_id' });\n  }\n}\n\n// Validate limit\nif (limit < 1 || limit > 100) {\n  errors.push({ field: 'limit', message: 'Limit must be between 1 and 100' });\n}\n\n// Validate offset\nif (offset < 0) {\n  errors.push({ field: 'offset', message: 'Offset must be >= 0' });\n}\n\n// Validate order\nif (order !== 'asc' && order !== 'desc') {\n  errors.push({ field: 'order', message: 'Order must be \"asc\" or \"desc\"' });\n}\n\n// Return validation result\nreturn [{\n  json: {\n    valid: errors.length === 0,\n    errors,\n    user_id,\n    approach_id,\n    patient_id,\n    limit,\n    offset,\n    order\n  }\n}];"}},{"id":"validation-check","name":"Validation Check","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1060,440],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"validation-failed","leftValue":"={{ $json.valid }}","rightValue":false,"operator":{"type":"boolean","operation":"equals"}}]}}},{"id":"response-400","name":"400 Bad Request","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1260,320],"parameters":{"respondWith":"json","responseCode":400,"responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"VALIDATION_ERROR\",\n    \"message\": $json.errors[0].message,\n    \"details\": $json.errors\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"lookup-thread-http","name":"Lookup Thread (HTTP)","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1460,520],"parameters":{"method":"GET","url":"https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_threads","authentication":"predefinedCredentialType","nodeCredentialType":"supabaseApi","sendQuery":true,"queryParameters":{"parameters":[{"name":"select","value":"id,user_id,patient_id,approach_id"},{"name":"user_id","value":"={{ 'eq.' + $('Parse & Validate Query Params').item.json.user_id }}"},{"name":"approach_id","value":"={{ 'eq.' + $('Parse & Validate Query Params').item.json.approach_id }}"},{"name":"patient_id","value":"={{ $('Parse & Validate Query Params').item.json.patient_id ? 'eq.' + $('Parse & Validate Query Params').item.json.patient_id : 'is.null' }}"},{"name":"status","value":"eq.active"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ 'Bearer ' + $('JWT Validation').item.json.access_token }}"}]},"options":{"response":{"response":{"responseFormat":"json"}},"timeout":10000}},"credentials":{"supabaseApi":{"id":"mdlcQ90gqxko069t","name":"Supabase Anon"}}},{"id":"thread-found-check","name":"Thread Found?","type":"n8n-nodes-base.if","typeVersion":2,"position":[1700,520],"parameters":{"conditions":{"conditions":[{"leftValue":"={{ $json.length }}","rightValue":0,"operator":{"type":"number","operation":"equals"}}]}}},{"id":"404-thread-not-found","name":"404 Thread Not Found","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[1900,400],"parameters":{"responseCode":404,"respondWith":"json","responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"NOT_FOUND\",\n    \"message\": \"Conversation thread not found. Please assign an approach to the patient first.\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}},{"id":"extract-thread-data","name":"Extract Thread Data","type":"n8n-nodes-base.code","typeVersion":2,"position":[1900,620],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get thread data from lookup result\nconst threadData = $input.first().json[0];\nconst queryParams = $('Parse & Validate Query Params').item.json;\n\n// Return thread info combined with query params\nreturn {\n  json: {\n    thread_id: threadData.id,\n    user_id: threadData.user_id,\n    patient_id: threadData.patient_id,\n    approach_id: threadData.approach_id,\n    limit: queryParams.limit,\n    offset: queryParams.offset,\n    order: queryParams.order\n  }\n};"}},{"id":"get-messages-http","name":"Get Messages (HTTP)","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2140,620],"parameters":{"method":"GET","url":"https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/messages","authentication":"predefinedCredentialType","nodeCredentialType":"supabaseApi","sendQuery":true,"queryParameters":{"parameters":[{"name":"select","value":"id,message,created_at"},{"name":"thread_id","value":"={{ 'eq.' + $('Extract Thread Data').item.json.thread_id }}"},{"name":"order","value":"={{ 'created_at.' + $('Extract Thread Data').item.json.order }}"},{"name":"limit","value":"={{ $('Extract Thread Data').item.json.limit }}"},{"name":"offset","value":"={{ $('Extract Thread Data').item.json.offset }}"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ 'Bearer ' + $('JWT Validation').item.json.access_token }}"},{"name":"Prefer","value":"count=exact"}]},"options":{"response":{"response":{"responseFormat":"json"}},"timeout":10000}},"credentials":{"supabaseApi":{"id":"mdlcQ90gqxko069t","name":"Supabase Anon"}}},{"id":"format-response","name":"Format Response","type":"n8n-nodes-base.code","typeVersion":2,"position":[2380,620],"parameters":{"mode":"runOnceForAllItems","jsCode":"// Get all messages from the database query\nconst messagesData = $input.all();\nconst threadData = $('Extract Thread Data').item.json;\n\n// Extract total count from Content-Range header\n// Format: \"0-49/150\" means showing items 0-49 out of 150 total\nconst contentRange = $('Get Messages (HTTP)').item.json.$response?.headers?.['content-range'];\nlet total = messagesData.length;\nif (contentRange) {\n  const match = contentRange.match(/\\/(\\d+)/);\n  if (match) {\n    total = parseInt(match[1]);\n  }\n}\n\n// Parse JSONB message field and format each message\nconst messages = messagesData.map(item => {\n  const msg = item.json.message || {};\n  return {\n    id: item.json.id,\n    role: msg.role || 'user',\n    content: msg.content || '',\n    tool_id: msg.tool_id || null,\n    metadata: msg.metadata || {},\n    created_at: item.json.created_at\n  };\n});\n\n// Calculate pagination metadata\nconst hasMore = (threadData.offset + messages.length) < total;\n\n// Build final response following API_RESPONSE_STANDARDS.md\nreturn {\n  json: {\n    success: true,\n    data: {\n      thread_id: threadData.thread_id,\n      patient_id: threadData.patient_id,\n      approach_id: threadData.approach_id,\n      messages: messages,\n      pagination: {\n        limit: threadData.limit,\n        offset: threadData.offset,\n        total: total,\n        hasMore: hasMore\n      }\n    },\n    metadata: {\n      timestamp: new Date().toISOString()\n    }\n  }\n};"}},{"id":"sticky-milestone-3","name":"Note4","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2060,-80],"parameters":{"content":"## 📬 Load Messages & Format\n\n**Milestone 3**: Query messages with pagination and format JSONB fields\n\n- Get messages from Supabase with filters\n- Parse JSONB message structure\n- Calculate pagination metadata\n- Format according to API standards","height":240,"width":360,"color":4}},{"id":"8cbfa0d4-2a39-427e-bd66-2ea3f7b52e14","name":"200 Success","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[2620,620],"parameters":{"responseCode":200,"respondWith":"json","responseBody":"={{ $json }}"}},{"id":"sticky-success-response","name":"Note12","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2540,-80],"parameters":{"content":"## ✨ Success Response\n\nMilestone 4: Final responses following API_RESPONSE_STANDARDS.md","height":160,"width":320,"color":5}}],"connections":{"GET /chat/messages":{"main":[[{"node":"JWT Validation","type":"main","index":0}]]},"JWT Validation":{"main":[[{"node":"Auth Failed?","type":"main","index":0}]]},"Auth Failed?":{"main":[[{"node":"401 Unauthorized","type":"main","index":0}],[{"node":"Parse & Validate Query Params","type":"main","index":0}]]},"Parse & Validate Query Params":{"main":[[{"node":"Validation Check","type":"main","index":0}]]},"Validation Check":{"main":[[{"node":"400 Bad Request","type":"main","index":0}],[{"node":"Lookup Thread (HTTP)","type":"main","index":0}]]},"Lookup Thread (HTTP)":{"main":[[{"node":"Thread Found?","type":"main","index":0}]]},"Thread Found?":{"main":[[{"node":"404 Thread Not Found","type":"main","index":0}],[{"node":"Extract Thread Data","type":"main","index":0}]]},"Extract Thread Data":{"main":[[{"node":"Get Messages (HTTP)","type":"main","index":0}]]},"Get Messages (HTTP)":{"main":[[{"node":"Format Response","type":"main","index":0}]]},"Format Response":{"main":[[{"node":"200 Success","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"c6108b20-4a3d-4cfb-8879-b2d7c9fbf2d7","triggerCount":0,"shared":[{"createdAt":"2025-10-24T12:06:35.084Z","updatedAt":"2025-10-24T12:06:35.084Z","role":"workflow:owner","workflowId":"ThD7S9hN0K1P5AZi","projectId":"sVGwG1Ss6aXKNorC","project":{"createdAt":"2025-07-30T12:18:11.485Z","updatedAt":"2025-07-30T12:20:06.951Z","id":"sVGwG1Ss6aXKNorC","name":"Rafał Dębski <rdebski90@gmail.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-07-30T12:18:11.486Z","updatedAt":"2025-07-30T12:18:11.486Z","userId":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","projectId":"sVGwG1Ss6aXKNorC","user":{"createdAt":"2025-07-30T12:18:10.851Z","updatedAt":"2025-10-23T22:43:16.000Z","id":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","email":"rdebski90@gmail.com","firstName":"Rafał","lastName":"Dębski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-07-30T12:20:09.619Z","personalization_survey_n8n_version":"1.104.1"},"settings":{"userActivated":true,"easyAIWorkflowOnboarded":true,"firstSuccessfulWorkflowId":"gp796pP6j8IFZodb","userActivatedAt":1753881412699,"npsSurvey":{"responded":true,"lastShownAt":1755785806897},"dismissedCallouts":{"ragStarterCallout":true}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"updateNode","nodeId":"lookup-thread-http","updates":{"continueOnFail":true}},{"type":"updateNode","nodeId":"get-messages-http","updates":{"continueOnFail":true}},{"type":"addNode","node":{"id":"9dbeaf15-3b4c-428f-cf77-3fb4c8a53f15","name":"500 Internal Error","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[2140,800],"parameters":{"responseCode":500,"respondWith":"json","responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INTERNAL_ERROR\",\n    \"message\": \"An unexpected error occurred. Please try again later.\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}}},{"type":"addConnection","source":"Lookup Thread (HTTP)","target":"500 Internal Error","sourceOutput":"error"},{"type":"addConnection","source":"Get Messages (HTTP)","target":"500 Internal Error","sourceOutput":"error"},{"type":"addNode","node":{"id":"sticky-error-handling","name":"Note13","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2060,900],"parameters":{"content":"## ⚠️ Error Handling\n\n500 errors for database failures and unexpected issues","height":140,"width":300,"color":2}}}]


workflow_id: ThD7S9hN0K1P5AZi
workflow_name: GET /chat/messages - List Messages
trigger: partial_update
created_at: 2025-10-24 12:14:14
workflow_snapshot:
[cell repeats an earlier one in this file: 12974 characters]

operations:
  [{"type":"updateNode","nodeId":"lookup-thread-http","updates":{"onError":"continueErrorOutput"}},{"type":"updateNode","nodeId":"get-messages-http","updates":{"onError":"continueErrorOutput"}},{"type":"addNode","node":{"id":"9dbeaf15-3b4c-428f-cf77-3fb4c8a53f15","name":"500 Internal Error","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[2140,800],"parameters":{"responseCode":500,"respondWith":"json","responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INTERNAL_ERROR\",\n    \"message\": \"An unexpected error occurred. Please try again later.\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}"}}},{"type":"addConnection","source":"Lookup Thread (HTTP)","target":"500 Internal Error","sourceOutput":"error"},{"type":"addConnection","source":"Get Messages (HTTP)","target":"500 Internal Error","sourceOutput":"error"},{"type":"addNode","node":{"id":"sticky-error-handling","name":"Note13","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2060,900],"parameters":{"content":"## ⚠️ Error Handling\n\n500 errors for database failures and unexpected issues","height":140,"width":300,"color":2}}}]


workflow_id: 9fUS5qUygspl44I1
workflow_name: Test Workflow - If/Switch Warnings
trigger: partial_update
created_at: 2025-10-24 12:25:26
workflow_snapshot:
  {"createdAt":"2025-10-24T12:25:11.135Z","updatedAt":"2025-10-24T12:25:11.135Z","id":"9fUS5qUygspl44I1","name":"Test Workflow - If/Switch Warnings","active":false,"isArchived":false,"nodes":[{"id":"webhook-trigger","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"path":"test-warnings","httpMethod":"GET"}},{"id":"if-node","name":"If Node","type":"n8n-nodes-base.if","typeVersion":2,"position":[450,300],"parameters":{}},{"id":"handler1","name":"Handler 1","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[650,200],"parameters":{}},{"id":"handler2","name":"Handler 2","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[650,400],"parameters":{}}],"connections":{"Webhook":{"main":[[{"node":"If Node","type":"main","index":0}]]},"If Node":{"main":[[{"node":"Handler 1","type":"main","index":0}],[{"node":"Handler 2","type":"main","index":0}]]}},"settings":{"executionOrder":"v1","saveDataErrorExecution":"all","saveDataSuccessExecution":"all","saveManualExecutions":true,"saveExecutionProgress":true},"staticData":null,"meta":null,"pinData":null,"versionId":"e21e1cd6-1c44-4786-a496-8c2ebcd15c54","triggerCount":0,"shared":[{"createdAt":"2025-10-24T12:25:11.137Z","updatedAt":"2025-10-24T12:25:11.137Z","role":"workflow:owner","workflowId":"9fUS5qUygspl44I1","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-23T22:00:54.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"removeConnection","source":"If Node","target":"Handler 1"},{"type":"removeConnection","source":"If Node","target":"Handler 2"},{"type":"addConnection","source":"If Node","target":"Handler 1","sourceIndex":0},{"type":"addConnection","source":"If Node","target":"Handler 2","sourceIndex":0}]


workflow_id: 9fUS5qUygspl44I1
workflow_name: Test Workflow - If/Switch Warnings
trigger: partial_update
created_at: 2025-10-24 12:25:44
workflow_snapshot:
  {"createdAt":"2025-10-24T12:25:11.135Z","updatedAt":"2025-10-24T12:25:26.256Z","id":"9fUS5qUygspl44I1","name":"Test Workflow - If/Switch Warnings","active":false,"isArchived":false,"nodes":[{"id":"webhook-trigger","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"path":"test-warnings","httpMethod":"GET"}},{"id":"if-node","name":"If Node","type":"n8n-nodes-base.if","typeVersion":2,"position":[450,300],"parameters":{}},{"id":"handler1","name":"Handler 1","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[650,200],"parameters":{}},{"id":"handler2","name":"Handler 2","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[650,400],"parameters":{}}],"connections":{"Webhook":{"main":[[{"node":"If Node","type":"main","index":0}]]},"If Node":{"main":[[{"node":"Handler 1","type":"main","index":0},{"node":"Handler 2","type":"main","index":0}]]}},"settings":{"saveExecutionProgress":true,"saveManualExecutions":true,"saveDataErrorExecution":"all","saveDataSuccessExecution":"all","executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"bc08f093-2cbb-49c5-b042-d7eb04fbfe88","triggerCount":0,"shared":[{"createdAt":"2025-10-24T12:25:11.137Z","updatedAt":"2025-10-24T12:25:11.137Z","role":"workflow:owner","workflowId":"9fUS5qUygspl44I1","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-23T22:00:54.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"removeConnection","source":"If Node","target":"Handler 1"},{"type":"removeConnection","source":"If Node","target":"Handler 2"},{"type":"addConnection","source":"If Node","target":"Handler 1","branch":"true"},{"type":"addConnection","source":"If Node","target":"Handler 2","branch":"false"}]


workflow_id: pWqhKvI21TdMeggU
workflow_name: Test Scenario 3 - Switch Node
trigger: partial_update
created_at: 2025-10-24 12:26:15
workflow_snapshot:
  {"createdAt":"2025-10-24T12:26:10.711Z","updatedAt":"2025-10-24T12:26:10.711Z","id":"pWqhKvI21TdMeggU","name":"Test Scenario 3 - Switch Node","active":false,"isArchived":false,"nodes":[{"id":"webhook-trigger","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"path":"test-switch","httpMethod":"GET"}},{"id":"switch-node","name":"Switch Node","type":"n8n-nodes-base.switch","typeVersion":3,"position":[450,300],"parameters":{"rules":{"rules":[{"conditions":{"options":{"caseSensitive":true,"leftValue":""},"conditions":[{"leftValue":"={{$json.value}}","rightValue":"1","operator":{"type":"string","operation":"equals"}}],"combinator":"and"}},{"conditions":{"options":{"caseSensitive":true,"leftValue":""},"conditions":[{"leftValue":"={{$json.value}}","rightValue":"2","operator":{"type":"string","operation":"equals"}}],"combinator":"and"}}]}}},{"id":"case-handler1","name":"Case Handler 1","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[650,200],"parameters":{}},{"id":"case-handler2","name":"Case Handler 2","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[650,400],"parameters":{}}],"connections":{"Webhook":{"main":[[{"node":"Switch Node","type":"main","index":0}]]},"Switch Node":{"main":[[{"node":"Case Handler 1","type":"main","index":0}],[{"node":"Case Handler 2","type":"main","index":0}]]}},"settings":{"executionOrder":"v1","saveDataErrorExecution":"all","saveDataSuccessExecution":"all","saveManualExecutions":true,"saveExecutionProgress":true},"staticData":null,"meta":null,"pinData":null,"versionId":"5c87b5a6-bced-4e7a-950a-f2f7318d11c7","triggerCount":0,"shared":[{"createdAt":"2025-10-24T12:26:10.713Z","updatedAt":"2025-10-24T12:26:10.713Z","role":"workflow:owner","workflowId":"pWqhKvI21TdMeggU","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-23T22:00:54.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"id":"case-handler3","name":"Case Handler 3","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[650,600],"parameters":{}}},{"type":"addConnection","source":"Switch Node","target":"Case Handler 3","sourceIndex":1}]


workflow_id: iW1hM84bV15rzqou
workflow_name: Test Warning System - If Node BAD
trigger: partial_update
created_at: 2025-10-24 12:32:00
workflow_snapshot:
  {"createdAt":"2025-10-24T12:31:54.207Z","updatedAt":"2025-10-24T12:31:54.207Z","id":"iW1hM84bV15rzqou","name":"Test Warning System - If Node BAD","active":false,"isArchived":false,"nodes":[{"id":"webhook","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[240,300],"parameters":{"httpMethod":"GET","path":"test-warnings"}},{"id":"if_node","name":"If Node","type":"n8n-nodes-base.if","typeVersion":2,"position":[460,300],"parameters":{"conditions":{"options":{"version":2},"conditions":[{"leftValue":"={{ $json.value }}","rightValue":"10","operator":{"type":"number","operation":"greaterThan"}}]}}}],"connections":{"Webhook":{"main":[[{"node":"If Node","type":"main","index":0}]]}},"settings":{"executionOrder":"v1","saveDataErrorExecution":"all","saveDataSuccessExecution":"all","saveManualExecutions":true,"saveExecutionProgress":true},"staticData":null,"meta":null,"pinData":null,"versionId":"bdf3ec3d-7707-4a50-a2b7-7d249ef14f4a","triggerCount":0,"shared":[{"createdAt":"2025-10-24T12:31:54.208Z","updatedAt":"2025-10-24T12:31:54.208Z","role":"workflow:owner","workflowId":"iW1hM84bV15rzqou","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-23T22:00:54.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"name":"Handler 1","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[680,200],"parameters":{}}},{"type":"addNode","node":{"name":"Handler 2","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[680,400],"parameters":{}}},{"type":"addConnection","source":"If Node","target":"Handler 1","sourceIndex":0},{"type":"addConnection","source":"If Node","target":"Handler 2","sourceIndex":0}]


workflow_id: vTqLIcq9KXKklC6F
workflow_name: Test Warning System - If Node GOOD
trigger: partial_update
created_at: 2025-10-24 12:32:21
workflow_snapshot:
  {"createdAt":"2025-10-24T12:32:15.991Z","updatedAt":"2025-10-24T12:32:15.991Z","id":"vTqLIcq9KXKklC6F","name":"Test Warning System - If Node GOOD","active":false,"isArchived":false,"nodes":[{"id":"webhook","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[240,300],"parameters":{"httpMethod":"GET","path":"test-good"}},{"id":"if_node","name":"If Node","type":"n8n-nodes-base.if","typeVersion":2,"position":[460,300],"parameters":{"conditions":{"options":{"version":2},"conditions":[{"leftValue":"={{ $json.value }}","rightValue":"10","operator":{"type":"number","operation":"greaterThan"}}]}}}],"connections":{"Webhook":{"main":[[{"node":"If Node","type":"main","index":0}]]}},"settings":{"executionOrder":"v1","saveDataErrorExecution":"all","saveDataSuccessExecution":"all","saveManualExecutions":true,"saveExecutionProgress":true},"staticData":null,"meta":null,"pinData":null,"versionId":"e70c1044-1e80-495c-99cf-959a3f142b40","triggerCount":0,"shared":[{"createdAt":"2025-10-24T12:32:15.993Z","updatedAt":"2025-10-24T12:32:15.993Z","role":"workflow:owner","workflowId":"vTqLIcq9KXKklC6F","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-23T22:00:54.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"name":"Success Handler","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[680,200],"parameters":{}}},{"type":"addNode","node":{"name":"Error Handler","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[680,400],"parameters":{}}},{"type":"addConnection","source":"If Node","target":"Success Handler","branch":"true"},{"type":"addConnection","source":"If Node","target":"Error Handler","branch":"false"}]


workflow_id: 6D9b188T96Fm4Pe7
workflow_name: Test Warning System - Switch Node
trigger: partial_update
created_at: 2025-10-24 12:32:41
workflow_snapshot:
  {"createdAt":"2025-10-24T12:32:35.316Z","updatedAt":"2025-10-24T12:32:35.316Z","id":"6D9b188T96Fm4Pe7","name":"Test Warning System - Switch Node","active":false,"isArchived":false,"nodes":[{"id":"webhook","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[240,300],"parameters":{"httpMethod":"GET","path":"test-switch"}},{"id":"switch_node","name":"Switch Node","type":"n8n-nodes-base.switch","typeVersion":3,"position":[460,300],"parameters":{"rules":{"rules":[{"conditions":{"options":{"version":2},"conditions":[{"leftValue":"={{ $json.type }}","rightValue":"A","operator":{"type":"string","operation":"equals"}}]}},{"conditions":{"options":{"version":2},"conditions":[{"leftValue":"={{ $json.type }}","rightValue":"B","operator":{"type":"string","operation":"equals"}}]}}]}}}],"connections":{"Webhook":{"main":[[{"node":"Switch Node","type":"main","index":0}]]}},"settings":{"executionOrder":"v1","saveDataErrorExecution":"all","saveDataSuccessExecution":"all","saveManualExecutions":true,"saveExecutionProgress":true},"staticData":null,"meta":null,"pinData":null,"versionId":"039b203b-e805-449f-bca2-110c86e9a21e","triggerCount":0,"shared":[{"createdAt":"2025-10-24T12:32:35.318Z","updatedAt":"2025-10-24T12:32:35.318Z","role":"workflow:owner","workflowId":"6D9b188T96Fm4Pe7","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-23T22:00:54.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"name":"Case Handler","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[680,300],"parameters":{}}},{"type":"addConnection","source":"Switch Node","target":"Case Handler","sourceIndex":1}]


workflow_id: 6D9b188T96Fm4Pe7
workflow_name: Test Warning System - Switch Node
trigger: partial_update
created_at: 2025-10-24 12:32:45
workflow_snapshot:
  {"createdAt":"2025-10-24T12:32:35.316Z","updatedAt":"2025-10-24T12:32:35.316Z","id":"6D9b188T96Fm4Pe7","name":"Test Warning System - Switch Node","active":false,"isArchived":false,"nodes":[{"id":"webhook","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[240,300],"parameters":{"httpMethod":"GET","path":"test-switch"}},{"id":"switch_node","name":"Switch Node","type":"n8n-nodes-base.switch","typeVersion":3,"position":[460,300],"parameters":{"rules":{"rules":[{"conditions":{"options":{"version":2},"conditions":[{"leftValue":"={{ $json.type }}","rightValue":"A","operator":{"type":"string","operation":"equals"}}]}},{"conditions":{"options":{"version":2},"conditions":[{"leftValue":"={{ $json.type }}","rightValue":"B","operator":{"type":"string","operation":"equals"}}]}}]}}}],"connections":{"Webhook":{"main":[[{"node":"Switch Node","type":"main","index":0}]]}},"settings":{"executionOrder":"v1","saveDataErrorExecution":"all","saveDataSuccessExecution":"all","saveManualExecutions":true,"saveExecutionProgress":true},"staticData":null,"meta":null,"pinData":null,"versionId":"039b203b-e805-449f-bca2-110c86e9a21e","triggerCount":0,"shared":[{"createdAt":"2025-10-24T12:32:35.318Z","updatedAt":"2025-10-24T12:32:35.318Z","role":"workflow:owner","workflowId":"6D9b188T96Fm4Pe7","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-23T22:00:54.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"name":"Case Handler A","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[680,200],"parameters":{}}},{"type":"addNode","node":{"name":"Case Handler B","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[680,400],"parameters":{}}},{"type":"addConnection","source":"Switch Node","target":"Case Handler A","sourceIndex":0},{"type":"addConnection","source":"Switch Node","target":"Case Handler B","sourceIndex":1}]


workflow_id: ThD7S9hN0K1P5AZi
workflow_name: GET /chat/messages - List Messages
trigger: partial_update
created_at: 2025-10-24 12:46:07
workflow_snapshot:
  {"createdAt":"2025-10-24T12:06:35.080Z","updatedAt":"2025-10-24T12:16:25.000Z","id":"ThD7S9hN0K1P5AZi","name":"GET /chat/messages - List Messages","active":true,"isArchived":false,"nodes":[{"parameters":{"path":"chat/messages","responseMode":"responseNode","options":{"allowedOrigins":"*"}},"id":"webhook-trigger","name":"GET /chat/messages","type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[192,368],"webhookId":"chat-messages-list","onError":"continueRegularOutput"},{"parameters":{"workflowId":{"__rl":true,"value":"dL4gKHrO0Mtdhpmo","mode":"list","cachedResultUrl":"/workflow/dL4gKHrO0Mtdhpmo","cachedResultName":"JWT Validation Middleware"},"workflowInputs":{"mappingMode":"defineBelow","value":{},"matchingColumns":[],"schema":[{"id":"headers","displayName":"headers","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true,"type":"object"},{"id":"body","displayName":"body","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true},{"id":"params","displayName":"params","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true,"type":"object"}],"attemptToConvertTypes":false,"convertFieldsToString":true},"options":{}},"id":"jwt-validation","name":"JWT Validation","type":"n8n-nodes-base.executeWorkflow","typeVersion":1.3,"position":[400,368]},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"auth-error-check","leftValue":"={{ $('JWT Validation').item.json.error }}","rightValue":"","operator":{"type":"object","operation":"notEmpty"}}]},"options":{}},"id":"auth-check","name":"Auth Failed?","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[624,368]},{"parameters":{"respondWith":"json","responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"UNAUTHORIZED\",\n    \"message\": \"Invalid or expired access token\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}","options":{}},"id":"response-401","name":"401 Unauthorized","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[832,240]},{"parameters":{"jsCode":"// Get query parameters from webhook\nconst queryParams = $('GET /chat/messages').item.json.query || {};\nconst user_id = $('JWT Validation').item.json.user_id;\n\n// Extract parameters\nconst approach_id = queryParams.approach_id;\nconst patient_id = queryParams.patient_id || null;\nconst limit = parseInt(queryParams.limit) || 50;\nconst offset = parseInt(queryParams.offset) || 0;\nconst order = queryParams.order || 'asc';\n\n// Validation errors array\nconst errors = [];\n\n// Validate approach_id (required)\nif (!approach_id) {\n  errors.push({ field: 'approach_id', message: 'Missing required field: approach_id' });\n} else {\n  // UUID format validation\n  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n  if (!uuidRegex.test(approach_id)) {\n    errors.push({ field: 'approach_id', message: 'Invalid UUID format: approach_id' });\n  }\n}\n\n// Validate patient_id if provided\nif (patient_id) {\n  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n  if (!uuidRegex.test(patient_id)) {\n    errors.push({ field: 'patient_id', message: 'Invalid UUID format: patient_id' });\n  }\n}\n\n// Validate limit\nif (limit < 1 || limit > 100) {\n  errors.push({ field: 'limit', message: 'Limit must be between 1 and 100' });\n}\n\n// Validate offset\nif (offset < 0) {\n  errors.push({ field: 'offset', message: 'Offset must be >= 0' });\n}\n\n// Validate order\nif (order !== 'asc' && order !== 'desc') {\n  errors.push({ field: 'order', message: 'Order must be \"asc\" or \"desc\"' });\n}\n\n// Return validation result\nreturn [{\n  json: {\n    valid: errors.length === 0,\n    errors,\n    user_id,\n    approach_id,\n    patient_id,\n    limit,\n    offset,\n    order\n  }\n}];"},"id":"parse-validate-params","name":"Parse & Validate Query Params","type":"n8n-nodes-base.code","typeVersion":2,"position":[848,448]},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"validation-failed","leftValue":"={{ $json.valid }}","rightValue":false,"operator":{"type":"boolean","operation":"equals"}}]},"options":{}},"id":"validation-check","name":"Validation Check","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1072,448]},{"parameters":{"respondWith":"json","responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"VALIDATION_ERROR\",\n    \"message\": $json.errors[0].message,\n    \"details\": $json.errors\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}","options":{}},"id":"response-400","name":"400 Bad Request","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1264,320]},{"parameters":{"url":"https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_threads","authentication":"predefinedCredentialType","nodeCredentialType":"supabaseApi","sendQuery":true,"queryParameters":{"parameters":[{"name":"select","value":"id,user_id,patient_id,approach_id"},{"name":"user_id","value":"={{ 'eq.' + $('Parse & Validate Query Params').item.json.user_id }}"},{"name":"approach_id","value":"={{ 'eq.' + $('Parse & Validate Query Params').item.json.approach_id }}"},{"name":"patient_id","value":"={{ $('Parse & Validate Query Params').item.json.patient_id ? 'eq.' + $('Parse & Validate Query Params').item.json.patient_id : 'is.null' }}"},{"name":"status","value":"eq.active"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ 'Bearer ' + $('JWT Validation').item.json.access_token }}"}]},"options":{"response":{"response":{"responseFormat":"json"}},"timeout":10000}},"id":"lookup-thread-http","name":"Lookup Thread (HTTP)","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1472,528],"credentials":{"supabaseApi":{"id":"mdlcQ90gqxko069t","name":"Supabase Anon"}}},{"parameters":{"conditions":{"conditions":[{"leftValue":"={{ $json.length }}","rightValue":0,"operator":{"type":"number","operation":"equals"}}]},"options":{}},"id":"thread-found-check","name":"Thread Found?","type":"n8n-nodes-base.if","typeVersion":2,"position":[1712,528]},{"parameters":{"respondWith":"json","responseBody":"={{ {\n  \"success\": false,\n  \"error\": {\n    \"code\": \"NOT_FOUND\",\n    \"message\": \"Conversation thread not found. Please assign an approach to the patient first.\"\n  },\n  \"metadata\": {\n    \"timestamp\": new Date().toISOString()\n  }\n} }}","options":{}},"id":"404-thread-not-found","name":"404 Thread Not Found","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[1904,400]},{"parameters":{"jsCode":"// Get thread data from lookup result\nconst threadData = $input.first().json[0];\nconst queryParams = $('Parse & Validate Query Params').item.json;\n\n// Return thread info combined with query params\nreturn {\n  json: {\n    thread_id: threadData.id,\n    user_id: threadData.user_id,\n    patient_id: threadData.patient_id,\n    approach_id: threadData.approach_id,\n    limit: queryParams.limit,\n    offset: queryParams.offset,\n    order: queryParams.order\n  }\n};"},"id":"extract-thread-data","name":"Extract Thread Data","type":"n8n-nodes-base.code","typeVersion":2,"position":[1904,624]},{"parameters":{"url":"https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/messages","authentication":"predefinedCredentialType","nodeCredentialType":"supabaseApi","sendQuery":true,"queryParameters":{"parameters":[{"name":"select","value":"id,message,created_at"},{"name":"thread_id","value":"={{ 'eq.' + $('Extract Thread Data').item.json.thread_id }}"},{"name":"order","value":"={{ 'created_at.' + $('Extract Thread Data').item.json.order }}"},{"name":"limit","value":"={{ $('Extract Thread Data').item.json.limit }}"},{"name":"offset","value":"={{ $('Extract Thread Data').item.json.offset }}"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ 'Bearer ' + $('JWT Validation').item.json.access_token }}"},{"name":"Prefer","value":"count=exact"}]},"options":{"response":{"response":{"responseFormat":"json"}},"timeout":10000}},"id":"get-messages-http","name":"Get Messages (HTTP)","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2144,624],"credentials":{"supabaseApi":{"id":"mdlcQ90gqxko069t","name":"Supabase Anon"}}},{"parameters":{"jsCode":"// Get all messages from the database query\nconst messagesData = $input.all();\nconst threadData = $('Extract Thread Data').item.json;\n\n// Extract total count from Content-Range header\n// Format: \"0-49/150\" means showing items 0-49 out of 150 total\nconst contentRange = $('Get Messages (HTTP)').item.json.$response?.headers?.['content-range'];\nlet total = messagesData.length;\nif (contentRange) {\n  const match = contentRange.match(/\\/(\\d+)/);\n  if (match) {\n    total = parseInt(match[1]);\n  }\n}\n\n// Parse JSONB message field and format each message\nconst messages = messagesData.map(item => {\n  const msg = item.json.message || {};\n  return {\n    id: item.json.id,\n    role: msg.role || 'user',\n    content: msg.content || '',\n    tool_id: msg.tool_id || null,\n    metadata: msg.metadata || {},\n    created_at: item.json.created_at\n  };\n});\n\n// Calculate pagination metadata\nconst hasMore = (threadData.offset + messages.length) < total;\n\n// Build final response following API_RESPONSE_STANDARDS.md\nreturn {\n  json: {\n    success: true,\n    data: {\n      thread_id: threadData.thread_id,\n      patient_id: threadData.patient_id,\n      approach_id: threadData.approach_id,\n      messages: messages,\n      pagination: {\n        limit: threadData.limit,\n        offset: threadData.offset,\n        total: total,\n        hasMore: hasMore\n      }\n    },\n    metadata: {\n      timestamp: new Date().toISOString()\n    }\n  }\n};"},"id":"format-response","name":"Format Response","type":"n8n-nodes-base.code","typeVersion":2,"position":[2384,624]},{"parameters":{"content":"## 📬 Load Messages & Format\n\n**Milestone 3**: Query messages with pagination and format JSONB fields\n\n- Get messages from Supabase with filters\n- Parse JSONB message structure\n- Calculate pagination metadata\n- Format according to API standards","height":240,"width":360,"color":4},"id":"sticky-milestone-3","name":"Note4","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2064,-80]},{"parameters":{"respondWith":"json","responseBody":"={{ $json }}","options":{}},"id":"8cbfa0d4-2a39-427e-bd66-2ea3f7b52e14","name":"200 Success","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[2624,624]},{"parameters":{"content":"## ✨ Success Response\n\nMilestone 4: Final responses following API_RESPONSE_STANDARDS.md","width":320,"color":5},"id":"sticky-success-response","name":"Note12","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2544,-80]}],"connections":{"GET /chat/messages":{"main":[[{"node":"JWT Validation","type":"main","index":0}]]},"JWT Validation":{"main":[[{"node":"Auth Failed?","type":"main","index":0}]]},"Auth Failed?":{"main":[[{"node":"401 Unauthorized","type":"main","index":0}],[{"node":"Parse & Validate Query Params","type":"main","index":0}]]},"Parse & Validate Query Params":{"main":[[{"node":"Validation Check","type":"main","index":0}]]},"Validation Check":{"main":[[{"node":"400 Bad Request","type":"main","index":0}],[{"node":"Lookup Thread (HTTP)","type":"main","index":0}]]},"Lookup Thread (HTTP)":{"main":[[{"node":"Thread Found?","type":"main","index":0}]]},"Thread Found?":{"main":[[{"node":"404 Thread Not Found","type":"main","index":0}],[{"node":"Extract Thread Data","type":"main","index":0}]]},"Extract Thread Data":{"main":[[{"node":"Get Messages (HTTP)","type":"main","index":0}]]},"Get Messages (HTTP)":{"main":[[{"node":"Format Response","type":"main","index":0}]]},"Format Response":{"main":[[{"node":"200 Success","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":{},"versionId":"59cfba21-f663-4d83-9401-263a6ac7f345","triggerCount":1,"shared":[{"createdAt":"2025-10-24T12:06:35.084Z","updatedAt":"2025-10-24T12:06:35.084Z","role":"workflow:owner","workflowId":"ThD7S9hN0K1P5AZi","projectId":"sVGwG1Ss6aXKNorC","project":{"createdAt":"2025-07-30T12:18:11.485Z","updatedAt":"2025-07-30T12:20:06.951Z","id":"sVGwG1Ss6aXKNorC","name":"Rafał Dębski <rdebski90@gmail.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-07-30T12:18:11.486Z","updatedAt":"2025-07-30T12:18:11.486Z","userId":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","projectId":"sVGwG1Ss6aXKNorC","user":{"createdAt":"2025-07-30T12:18:10.851Z","updatedAt":"2025-10-23T22:43:16.000Z","id":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","email":"rdebski90@gmail.com","firstName":"Rafał","lastName":"Dębski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-07-30T12:20:09.619Z","personalization_survey_n8n_version":"1.104.1"},"settings":{"userActivated":true,"easyAIWorkflowOnboarded":true,"firstSuccessfulWorkflowId":"gp796pP6j8IFZodb","userActivatedAt":1753881412699,"npsSurvey":{"responded":true,"lastShownAt":1755785806897},"dismissedCallouts":{"ragStarterCallout":true}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"updateNode","nodeId":"auth-check","updates":{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"auth-error-check","leftValue":"={{ $('JWT Validation').item.json.error }}","rightValue":true,"operator":{"type":"boolean","operation":"equals"}}]},"options":{}}}}]


workflow_id: 9UqCwmQi2TZ45qm8
workflow_name: Test Rename - IF Node Branches
trigger: partial_update
created_at: 2025-10-24 12:46:30
workflow_snapshot:
  {"createdAt":"2025-10-23T09:32:57.327Z","updatedAt":"2025-10-23T09:33:11.715Z","id":"9UqCwmQi2TZ45qm8","name":"Test Rename - IF Node Branches","active":false,"isArchived":false,"nodes":[{"id":"if-1","name":"IF Condition","type":"n8n-nodes-base.if","typeVersion":2,"position":[0,0],"parameters":{}},{"id":"http-true","name":"HTTP Success","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[200,0],"parameters":{"url":"https://httpbin.org/post","method":"POST"}},{"id":"http-false","name":"HTTP False","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[200,200],"parameters":{"url":"https://httpbin.org/post","method":"POST"}}],"connections":{"IF Condition":{"main":[[{"node":"HTTP Success","type":"main","index":0}],[{"node":"HTTP False","type":"main","index":0}]]}},"settings":{"saveExecutionProgress":true,"saveManualExecutions":true,"saveDataErrorExecution":"all","saveDataSuccessExecution":"all","executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"06baf54c-6216-4cb6-8922-2fcd8b41083f","triggerCount":0,"shared":[{"createdAt":"2025-10-23T09:32:57.329Z","updatedAt":"2025-10-23T09:32:57.329Z","role":"workflow:owner","workflowId":"9UqCwmQi2TZ45qm8","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-23T22:00:54.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"name":"New Handler A","type":"n8n-nodes-base.noOp","position":[400,0],"parameters":{}}},{"type":"addConnection","source":"IF Condition","target":"New Handler A","sourceIndex":0}]


workflow_id: 9UqCwmQi2TZ45qm8
workflow_name: Test Rename - IF Node Branches
trigger: partial_update
created_at: 2025-10-24 12:46:37
workflow_snapshot:
  {"createdAt":"2025-10-23T09:32:57.327Z","updatedAt":"2025-10-24T12:46:30.650Z","id":"9UqCwmQi2TZ45qm8","name":"Test Rename - IF Node Branches","active":false,"isArchived":false,"nodes":[{"id":"if-1","name":"IF Condition","type":"n8n-nodes-base.if","typeVersion":2,"position":[0,0],"parameters":{}},{"id":"http-true","name":"HTTP Success","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[200,0],"parameters":{"url":"https://httpbin.org/post","method":"POST"}},{"id":"http-false","name":"HTTP False","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[200,200],"parameters":{"url":"https://httpbin.org/post","method":"POST"}},{"id":"5c321c39-8743-4959-9b58-d1e87042bb90","name":"New Handler A","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[400,0],"parameters":{}}],"connections":{"IF Condition":{"main":[[{"node":"HTTP Success","type":"main","index":0},{"node":"New Handler A","type":"main","index":0}],[{"node":"HTTP False","type":"main","index":0}]]}},"settings":{"saveExecutionProgress":true,"saveManualExecutions":true,"saveDataErrorExecution":"all","saveDataSuccessExecution":"all","executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"6779aba5-1219-4e6f-ace0-59316189f706","triggerCount":0,"shared":[{"createdAt":"2025-10-23T09:32:57.329Z","updatedAt":"2025-10-23T09:32:57.329Z","role":"workflow:owner","workflowId":"9UqCwmQi2TZ45qm8","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-23T22:00:54.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"name":"New Handler B","type":"n8n-nodes-base.noOp","position":[400,100],"parameters":{}}},{"type":"addConnection","source":"IF Condition","target":"New Handler B","sourceIndex":0}]


workflow_id: 9UqCwmQi2TZ45qm8
workflow_name: Test Rename - IF Node Branches
trigger: partial_update
created_at: 2025-10-24 12:46:45
workflow_snapshot:
  {"createdAt":"2025-10-23T09:32:57.327Z","updatedAt":"2025-10-24T12:46:37.754Z","id":"9UqCwmQi2TZ45qm8","name":"Test Rename - IF Node Branches","active":false,"isArchived":false,"nodes":[{"id":"if-1","name":"IF Condition","type":"n8n-nodes-base.if","typeVersion":2,"position":[0,0],"parameters":{}},{"id":"http-true","name":"HTTP Success","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[200,0],"parameters":{"url":"https://httpbin.org/post","method":"POST"}},{"id":"http-false","name":"HTTP False","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[200,200],"parameters":{"url":"https://httpbin.org/post","method":"POST"}},{"id":"5c321c39-8743-4959-9b58-d1e87042bb90","name":"New Handler A","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[400,0],"parameters":{}},{"id":"d5de2cf9-0280-4886-ac21-9304125ff097","name":"New Handler B","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[400,100],"parameters":{}}],"connections":{"IF Condition":{"main":[[{"node":"HTTP Success","type":"main","index":0},{"node":"New Handler A","type":"main","index":0},{"node":"New Handler B","type":"main","index":0}],[{"node":"HTTP False","type":"main","index":0}]]}},"settings":{"saveExecutionProgress":true,"saveManualExecutions":true,"saveDataErrorExecution":"all","saveDataSuccessExecution":"all","executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"37205781-ad5f-4e86-97f1-6762f64a8b69","triggerCount":0,"shared":[{"createdAt":"2025-10-23T09:32:57.329Z","updatedAt":"2025-10-23T09:32:57.329Z","role":"workflow:owner","workflowId":"9UqCwmQi2TZ45qm8","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-23T22:00:54.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"name":"Success Handler","type":"n8n-nodes-base.noOp","position":[600,0],"parameters":{}}},{"type":"addConnection","source":"IF Condition","target":"Success Handler","branch":"true"}]


workflow_id: 9UqCwmQi2TZ45qm8
workflow_name: Test Rename - IF Node Branches
trigger: partial_update
created_at: 2025-10-24 12:46:51
workflow_snapshot:
  {"createdAt":"2025-10-23T09:32:57.327Z","updatedAt":"2025-10-24T12:46:45.167Z","id":"9UqCwmQi2TZ45qm8","name":"Test Rename - IF Node Branches","active":false,"isArchived":false,"nodes":[{"id":"if-1","name":"IF Condition","type":"n8n-nodes-base.if","typeVersion":2,"position":[0,0],"parameters":{}},{"id":"http-true","name":"HTTP Success","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[200,0],"parameters":{"url":"https://httpbin.org/post","method":"POST"}},{"id":"http-false","name":"HTTP False","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[200,200],"parameters":{"url":"https://httpbin.org/post","method":"POST"}},{"id":"5c321c39-8743-4959-9b58-d1e87042bb90","name":"New Handler A","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[400,0],"parameters":{}},{"id":"d5de2cf9-0280-4886-ac21-9304125ff097","name":"New Handler B","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[400,100],"parameters":{}},{"id":"9b1e9218-cef4-460d-8999-46bf8ff01dcb","name":"Success Handler","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[600,0],"parameters":{}}],"connections":{"IF Condition":{"main":[[{"node":"HTTP Success","type":"main","index":0},{"node":"New Handler A","type":"main","index":0},{"node":"New Handler B","type":"main","index":0},{"node":"Success Handler","type":"main","index":0}],[{"node":"HTTP False","type":"main","index":0}]]}},"settings":{"saveExecutionProgress":true,"saveManualExecutions":true,"saveDataErrorExecution":"all","saveDataSuccessExecution":"all","executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"7b6f1aee-113d-4c7c-a13d-02660056aa41","triggerCount":0,"shared":[{"createdAt":"2025-10-23T09:32:57.329Z","updatedAt":"2025-10-23T09:32:57.329Z","role":"workflow:owner","workflowId":"9UqCwmQi2TZ45qm8","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-23T22:00:54.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"name":"Error Handler","type":"n8n-nodes-base.noOp","position":[600,200],"parameters":{}}},{"type":"addConnection","source":"IF Condition","target":"Error Handler","branch":"false"}]


workflow_id: 6D9b188T96Fm4Pe7
workflow_name: Test Warning System - Switch Node
trigger: partial_update
created_at: 2025-10-24 12:47:02
workflow_snapshot:
  {"createdAt":"2025-10-24T12:32:35.316Z","updatedAt":"2025-10-24T12:32:45.933Z","id":"6D9b188T96Fm4Pe7","name":"Test Warning System - Switch Node","active":false,"isArchived":false,"nodes":[{"id":"webhook","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[240,300],"parameters":{"httpMethod":"GET","path":"test-switch"}},{"id":"switch_node","name":"Switch Node","type":"n8n-nodes-base.switch","typeVersion":3,"position":[460,300],"parameters":{"rules":{"rules":[{"conditions":{"options":{"version":2},"conditions":[{"leftValue":"={{ $json.type }}","rightValue":"A","operator":{"type":"string","operation":"equals"}}]}},{"conditions":{"options":{"version":2},"conditions":[{"leftValue":"={{ $json.type }}","rightValue":"B","operator":{"type":"string","operation":"equals"}}]}}]}}},{"id":"3e0c7a66-5597-443c-88c5-43938fd9115b","name":"Case Handler A","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[680,200],"parameters":{}},{"id":"ed14d4c4-c04c-4f40-b7a4-3ab18e9c3505","name":"Case Handler B","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[680,400],"parameters":{}}],"connections":{"Webhook":{"main":[[{"node":"Switch Node","type":"main","index":0}]]},"Switch Node":{"main":[[{"node":"Case Handler A","type":"main","index":0}],[{"node":"Case Handler B","type":"main","index":0}]]}},"settings":{"saveExecutionProgress":true,"saveManualExecutions":true,"saveDataErrorExecution":"all","saveDataSuccessExecution":"all","executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"7a0e2082-a5db-4c27-a45a-378687def11c","triggerCount":0,"shared":[{"createdAt":"2025-10-24T12:32:35.318Z","updatedAt":"2025-10-24T12:32:35.318Z","role":"workflow:owner","workflowId":"6D9b188T96Fm4Pe7","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-23T22:00:54.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"name":"New Case Handler","type":"n8n-nodes-base.noOp","position":[900,300],"parameters":{}}},{"type":"addConnection","source":"Switch Node","target":"New Case Handler","sourceIndex":1}]


workflow_id: 6D9b188T96Fm4Pe7
workflow_name: Test Warning System - Switch Node
trigger: partial_update
created_at: 2025-10-24 12:47:10
workflow_snapshot:
  {"createdAt":"2025-10-24T12:32:35.316Z","updatedAt":"2025-10-24T12:47:02.125Z","id":"6D9b188T96Fm4Pe7","name":"Test Warning System - Switch Node","active":false,"isArchived":false,"nodes":[{"id":"webhook","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[240,300],"parameters":{"httpMethod":"GET","path":"test-switch"}},{"id":"switch_node","name":"Switch Node","type":"n8n-nodes-base.switch","typeVersion":3,"position":[460,300],"parameters":{"rules":{"rules":[{"conditions":{"options":{"version":2},"conditions":[{"leftValue":"={{ $json.type }}","rightValue":"A","operator":{"type":"string","operation":"equals"}}]}},{"conditions":{"options":{"version":2},"conditions":[{"leftValue":"={{ $json.type }}","rightValue":"B","operator":{"type":"string","operation":"equals"}}]}}]}}},{"id":"3e0c7a66-5597-443c-88c5-43938fd9115b","name":"Case Handler A","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[680,200],"parameters":{}},{"id":"ed14d4c4-c04c-4f40-b7a4-3ab18e9c3505","name":"Case Handler B","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[680,400],"parameters":{}},{"id":"7245a4d0-5f3f-417c-b6b7-f8b7aecbf52d","name":"New Case Handler","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[900,300],"parameters":{}}],"connections":{"Webhook":{"main":[[{"node":"Switch Node","type":"main","index":0}]]},"Switch Node":{"main":[[{"node":"Case Handler A","type":"main","index":0}],[{"node":"Case Handler B","type":"main","index":0},{"node":"New Case Handler","type":"main","index":0}]]}},"settings":{"saveExecutionProgress":true,"saveManualExecutions":true,"saveDataErrorExecution":"all","saveDataSuccessExecution":"all","executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"ec68e77f-85a0-4dca-9911-4b16948d1d98","triggerCount":0,"shared":[{"createdAt":"2025-10-24T12:32:35.318Z","updatedAt":"2025-10-24T12:32:35.318Z","role":"workflow:owner","workflowId":"6D9b188T96Fm4Pe7","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-23T22:00:54.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"name":"Case 0 Handler","type":"n8n-nodes-base.noOp","position":[900,100],"parameters":{}}},{"type":"addConnection","source":"Switch Node","target":"Case 0 Handler","case":0},{"type":"addNode","node":{"name":"Case 1 Handler","type":"n8n-nodes-base.noOp","position":[900,500],"parameters":{}}},{"type":"addConnection","source":"Switch Node","target":"Case 1 Handler","case":1}]


workflow_id: 9UqCwmQi2TZ45qm8
workflow_name: Test Rename - IF Node Branches
trigger: partial_update
created_at: 2025-10-24 12:47:18
workflow_snapshot:
  {"createdAt":"2025-10-23T09:32:57.327Z","updatedAt":"2025-10-24T12:46:51.166Z","id":"9UqCwmQi2TZ45qm8","name":"Test Rename - IF Node Branches","active":false,"isArchived":false,"nodes":[{"id":"if-1","name":"IF Condition","type":"n8n-nodes-base.if","typeVersion":2,"position":[0,0],"parameters":{}},{"id":"http-true","name":"HTTP Success","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[200,0],"parameters":{"url":"https://httpbin.org/post","method":"POST"}},{"id":"http-false","name":"HTTP False","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[200,200],"parameters":{"url":"https://httpbin.org/post","method":"POST"}},{"id":"5c321c39-8743-4959-9b58-d1e87042bb90","name":"New Handler A","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[400,0],"parameters":{}},{"id":"d5de2cf9-0280-4886-ac21-9304125ff097","name":"New Handler B","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[400,100],"parameters":{}},{"id":"9b1e9218-cef4-460d-8999-46bf8ff01dcb","name":"Success Handler","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[600,0],"parameters":{}},{"id":"164a7814-f5d6-4156-a836-4e64634ea368","name":"Error Handler","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[600,200],"parameters":{}}],"connections":{"IF Condition":{"main":[[{"node":"HTTP Success","type":"main","index":0},{"node":"New Handler A","type":"main","index":0},{"node":"New Handler B","type":"main","index":0},{"node":"Success Handler","type":"main","index":0}],[{"node":"HTTP False","type":"main","index":0},{"node":"Error Handler","type":"main","index":0}]]}},"settings":{"saveExecutionProgress":true,"saveManualExecutions":true,"saveDataErrorExecution":"all","saveDataSuccessExecution":"all","executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"ea1f9d5a-9283-424d-9872-e0527527c816","triggerCount":0,"shared":[{"createdAt":"2025-10-23T09:32:57.329Z","updatedAt":"2025-10-23T09:32:57.329Z","role":"workflow:owner","workflowId":"9UqCwmQi2TZ45qm8","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-23T22:00:54.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"rewireConnection","source":"IF Condition","from":"HTTP Success","to":"Success Handler","sourceIndex":0}]


workflow_id: 9UqCwmQi2TZ45qm8
workflow_name: Test Rename - IF Node Branches
trigger: partial_update
created_at: 2025-10-24 12:47:23
workflow_snapshot:
  {"createdAt":"2025-10-23T09:32:57.327Z","updatedAt":"2025-10-24T12:46:51.166Z","id":"9UqCwmQi2TZ45qm8","name":"Test Rename - IF Node Branches","active":false,"isArchived":false,"nodes":[{"id":"if-1","name":"IF Condition","type":"n8n-nodes-base.if","typeVersion":2,"position":[0,0],"parameters":{}},{"id":"http-true","name":"HTTP Success","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[200,0],"parameters":{"url":"https://httpbin.org/post","method":"POST"}},{"id":"http-false","name":"HTTP False","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[200,200],"parameters":{"url":"https://httpbin.org/post","method":"POST"}},{"id":"5c321c39-8743-4959-9b58-d1e87042bb90","name":"New Handler A","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[400,0],"parameters":{}},{"id":"d5de2cf9-0280-4886-ac21-9304125ff097","name":"New Handler B","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[400,100],"parameters":{}},{"id":"9b1e9218-cef4-460d-8999-46bf8ff01dcb","name":"Success Handler","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[600,0],"parameters":{}},{"id":"164a7814-f5d6-4156-a836-4e64634ea368","name":"Error Handler","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[600,200],"parameters":{}}],"connections":{"IF Condition":{"main":[[{"node":"HTTP Success","type":"main","index":0},{"node":"New Handler A","type":"main","index":0},{"node":"New Handler B","type":"main","index":0},{"node":"Success Handler","type":"main","index":0}],[{"node":"HTTP False","type":"main","index":0},{"node":"Error Handler","type":"main","index":0}]]}},"settings":{"saveExecutionProgress":true,"saveManualExecutions":true,"saveDataErrorExecution":"all","saveDataSuccessExecution":"all","executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"ea1f9d5a-9283-424d-9872-e0527527c816","triggerCount":0,"shared":[{"createdAt":"2025-10-23T09:32:57.329Z","updatedAt":"2025-10-23T09:32:57.329Z","role":"workflow:owner","workflowId":"9UqCwmQi2TZ45qm8","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-23T22:00:54.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"name":"Another Handler","type":"n8n-nodes-base.noOp","position":[800,0],"parameters":{}}},{"type":"rewireConnection","source":"IF Condition","from":"New Handler A","to":"Another Handler","sourceIndex":0}]


workflow_id: QMHZ5IAhBvRgyZAc
workflow_name: POST /chat/generate-pdf
trigger: partial_update
created_at: 2025-10-24 12:48:30
workflow_snapshot:
  {"createdAt":"2025-10-23T22:18:56.433Z","updatedAt":"2025-10-24T12:48:16.637Z","id":"QMHZ5IAhBvRgyZAc","name":"POST /chat/generate-pdf","active":true,"isArchived":false,"nodes":[{"parameters":{"httpMethod":"POST","path":"chat/generate-pdf","responseMode":"responseNode","options":{}},"id":"webhook-trigger","name":"POST /chat/generate-pdf","type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[240,304],"webhookId":"67403d18-ee13-4ad3-b9b7-02d012aeaf0e","onError":"continueRegularOutput"},{"parameters":{"workflowId":{"__rl":true,"value":"dL4gKHrO0Mtdhpmo","mode":"list","cachedResultUrl":"/workflow/dL4gKHrO0Mtdhpmo","cachedResultName":"JWT Validation Middleware"},"workflowInputs":{"mappingMode":"defineBelow","value":{},"matchingColumns":[],"schema":[{"id":"headers","displayName":"headers","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true,"type":"object"},{"id":"body","displayName":"body","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true},{"id":"params","displayName":"params","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true,"type":"object"}],"attemptToConvertTypes":false,"convertFieldsToString":true},"options":{}},"id":"jwt-validation","name":"JWT Validation","type":"n8n-nodes-base.executeWorkflow","typeVersion":1.3,"position":[464,304],"notes":"Calls sub-workflow #18 for JWT validation"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"jwt-success-condition","leftValue":"={{ $json.error }}","rightValue":"true","operator":{"type":"boolean","operation":"true","singleValue":true}}],"combinator":"and"},"options":{}},"id":"check-jwt-error","name":"Check JWT Error","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[688,304],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ error: 'Unauthorized', message: $json.message || 'Invalid or expired token' }) }}","options":{"responseCode":401}},"id":"return-jwt-error","name":"Return JWT Error","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[912,208]},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"message-id-condition","leftValue":"={{ $('POST /chat/generate-pdf').first().json.body.message_id }}","rightValue":"","operator":{"type":"string","operation":"notEmpty"}}],"combinator":"and"},"options":{}},"id":"check-message-id","name":"Check Message ID","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[912,384],"onError":"continueErrorOutput"},{"parameters":{"url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_messages?select=id,message,created_at,conversation_threads!inner(user_id)&id=eq.' + $('POST /chat/generate-pdf').first().json.body.message_id + '&conversation_threads.user_id=eq.' + $('JWT Validation').first().json.user_id }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"Prefer","value":"return=representation"}]},"options":{"response":{"response":{"responseFormat":"json"}}}},"id":"query-specific-message","name":"Query Specific Message","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1120,288],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_messages?select=id,message,created_at,conversation_threads!inner(user_id)&conversation_threads.user_id=eq.' + $('JWT Validation').first().json.user_id + '&order=created_at.desc&limit=1' }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"Prefer","value":"return=representation"}]},"options":{"response":{"response":{"responseFormat":"json"}}}},"id":"query-latest-message","name":"Query Latest Message","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1120,480],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"message-exists-condition","leftValue":"={{ $json.id }}","rightValue":"0","operator":{"type":"string","operation":"notEmpty"}}],"combinator":"and"},"options":{}},"id":"check-message-exists","name":"Check Message Exists","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1344,384],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ error: 'Not Found', message: 'Message not found or you do not have access to it' }) }}","options":{"responseCode":404}},"id":"return-not-found","name":"Return Not Found","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1568,288]},{"parameters":{"jsCode":"// Get message data from previous node\nconst messageData = $input.first().json;\n\n// Extract content from JSONB structure\nconst content = messageData.message.content;\n\n// Format date in Polish\nconst date = new Date(messageData.created_at);\nconst formattedDate = date.toLocaleDateString('pl-PL', {\n  year: 'numeric',\n  month: 'long',\n  day: 'numeric',\n  hour: '2-digit',\n  minute: '2-digit'\n});\n\n// Create HTML for PDF with WOO branding\nconst html = `<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <style>\n    body {\n      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n      line-height: 1.6;\n      color: #333;\n      padding: 40px;\n      max-width: 800px;\n      margin: 0 auto;\n    }\n    .header {\n      display: flex;\n      justify-content: space-between;\n      align-items: center;\n      margin-bottom: 40px;\n      padding-bottom: 20px;\n      border-bottom: 3px solid #4b0082;\n    }\n    .logo {\n      width: 120px;\n      height: 120px;\n    }\n    .title {\n      color: #4b0082;\n      font-size: 24px;\n      font-weight: 600;\n    }\n    .date {\n      color: #666;\n      font-size: 14px;\n      margin-bottom: 20px;\n    }\n    .content {\n      background: #f9f9f9;\n      padding: 30px;\n      border-radius: 8px;\n      border-left: 4px solid #4b0082;\n    }\n    .footer {\n      margin-top: 40px;\n      padding-top: 20px;\n      border-top: 1px solid #ddd;\n      text-align: center;\n      color: #888;\n      font-size: 12px;\n    }\n  </style>\n</head>\n<body>\n  <div class=\"header\">\n    <div class=\"title\">WOO PRO - Wiadomość</div>\n    <img src=\"https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/public/public_files/logo-email.png\" \n         class=\"logo\" alt=\"WOO Logo\">\n  </div>\n  \n  <div class=\"date\">${formattedDate}</div>\n  \n  <div class=\"content\">\n    ${content.replace(/\\n/g, '<br>')}\n  </div>\n  \n  <div class=\"footer\">\n    Wygenerowano przez WOO PRO<br>\n    Ten dokument jest poufny i przeznaczony wyłącznie dla odbiorcy.\n  </div>\n</body>\n</html>`;\n\nreturn [{\n  json: {\n    html: html,\n    fileName: `woo-message-${messageData.id}.pdf`,\n    messageId: messageData.id\n  }\n}];"},"id":"prepare-html-template","name":"Prepare HTML Template","type":"n8n-nodes-base.code","typeVersion":2,"position":[1568,480]},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"pdf-success-condition","leftValue":"={{ $json.error }}","rightValue":"false","operator":{"type":"boolean","operation":"false","singleValue":true}}],"combinator":"and"}},"id":"check-pdf-success","name":"Check PDF Success","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[2016,480],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ error: 'PDF Generation Failed', message: $json.message || 'Failed to generate PDF document' }) }}","options":{"responseCode":500}},"id":"return-pdf-error","name":"Return PDF Error","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[2224,384]},{"parameters":{"method":"POST","url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/generated_pdfs/' + $('Prepare HTML Template').first().json.fileName }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Content-Type","value":"application/pdf"}]},"sendBody":true,"contentType":"binaryData","inputDataFieldName":"data","options":{"response":{"response":{"responseFormat":"json"}}}},"id":"upload-pdf-to-storage","name":"Upload PDF to Storage","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2224,592],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"jsonBody":"={{ JSON.stringify({ expiresIn: 86400 }) }}"},"id":"generate-signed-url","name":"Generate Signed URL","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2448,592],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"jsCode":"const signedUrl = $input.first().json.signedURL;\nconst fileName = $('Prepare HTML Template').first().json.fileName;\nconst messageId = $('Prepare HTML Template').first().json.messageId;\n\nreturn [{\n  json: {\n    success: true,\n    message: 'PDF generated successfully',\n    data: {\n      pdfUrl: `https://xxciwnthnnywanbplqwg.supabase.co${signedUrl}`,\n      fileName: fileName,\n      messageId: messageId,\n      expiresIn: '24 hours'\n    }\n  }\n}];"},"id":"format-success-response","name":"Format Success Response","type":"n8n-nodes-base.code","typeVersion":2,"position":[2672,592]},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify($json) }}","options":{"responseCode":200}},"id":"return-success","name":"Return Success","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[2896,592]},{"parameters":{"method":"POST","url":"https://api.pdf.co/v1/pdf/convert/from/html","sendHeaders":true,"headerParameters":{"parameters":[{"name":"x-api-key","value":"reeunlockyourskills@gmail.com_SQcbrlvobSplxYtx2Ed8h2toSbsqenyPfWqLkjpvjc5uj68FXk78S3DNibeAw3v0"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ { \"html\": $json.html, \"name\": $json.fileName } }}","options":{"response":{"response":{"responseFormat":"json"}}}},"type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1552,832],"id":"f2e54550-eb45-4363-930d-c2908ca394ac","name":"call_generate_pdf"},{"id":"download-pdf-from-url","name":"Download PDF from URL","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2240,592],"parameters":{"url":"={{ $json.url }}","options":{"response":{"response":{"responseFormat":"file"}}}}}],"connections":{"POST /chat/generate-pdf":{"main":[[{"node":"JWT Validation","type":"main","index":0}]]},"JWT Validation":{"main":[[{"node":"Check JWT Error","type":"main","index":0}]]},"Query Specific Message":{"main":[[{"node":"Check Message Exists","type":"main","index":0}]]},"Query Latest Message":{"main":[[{"node":"Check Message Exists","type":"main","index":0}]]},"Upload PDF to Storage":{"main":[[{"node":"Generate Signed URL","type":"main","index":0}]]},"Generate Signed URL":{"main":[[{"node":"Format Success Response","type":"main","index":0}]]},"Format Success Response":{"main":[[{"node":"Return Success","type":"main","index":0}]]},"Check JWT Error":{"main":[[{"node":"Return JWT Error","type":"main","index":0}],[{"node":"Check Message ID","type":"main","index":0}]]},"Check Message ID":{"main":[[{"node":"Query Specific Message","type":"main","index":0}],[{"node":"Query Latest Message","type":"main","index":0}]]},"Check Message Exists":{"main":[[{"node":"Prepare HTML Template","type":"main","index":0}],[{"node":"Return Not Found","type":"main","index":0}]]},"Check PDF Success":{"main":[[{"node":"Download PDF from URL","type":"main","index":0}],[{"node":"Return PDF Error","type":"main","index":0}]]},"Prepare HTML Template":{"main":[[{"node":"call_generate_pdf","type":"main","index":0}]]},"call_generate_pdf":{"main":[[{"node":"Check PDF Success","type":"main","index":0}]]},"Download PDF from URL":{"main":[[{"node":"Upload PDF to Storage","type":"main","index":0}]]}},"settings":{"saveManualExecutions":true,"saveDataErrorExecution":"all","saveDataSuccessExecution":"all","errorWorkflow":"","executionOrder":"v1"},"staticData":null,"meta":null,"pinData":{},"versionId":"39c356f3-b98a-460b-83da-e8bb5d29f354","triggerCount":1,"shared":[{"createdAt":"2025-10-23T22:18:56.436Z","updatedAt":"2025-10-23T22:18:56.436Z","role":"workflow:owner","workflowId":"QMHZ5IAhBvRgyZAc","projectId":"sVGwG1Ss6aXKNorC","project":{"createdAt":"2025-07-30T12:18:11.485Z","updatedAt":"2025-07-30T12:20:06.951Z","id":"sVGwG1Ss6aXKNorC","name":"Rafał Dębski <rdebski90@gmail.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-07-30T12:18:11.486Z","updatedAt":"2025-07-30T12:18:11.486Z","userId":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","projectId":"sVGwG1Ss6aXKNorC","user":{"createdAt":"2025-07-30T12:18:10.851Z","updatedAt":"2025-10-23T22:43:16.000Z","id":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","email":"rdebski90@gmail.com","firstName":"Rafał","lastName":"Dębski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-07-30T12:20:09.619Z","personalization_survey_n8n_version":"1.104.1"},"settings":{"userActivated":true,"easyAIWorkflowOnboarded":true,"firstSuccessfulWorkflowId":"gp796pP6j8IFZodb","userActivatedAt":1753881412699,"npsSurvey":{"responded":true,"lastShownAt":1755785806897},"dismissedCallouts":{"ragStarterCallout":true}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"updateNode","nodeId":"generate-signed-url","updates":{"parameters":{"method":"POST","url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/sign/generated_pdfs/' + $('Prepare HTML Template').first().json.fileName }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ { expiresIn: 86400 } }}","options":{"response":{"response":{"responseFormat":"json"}}}}}}]


workflow_id: QMHZ5IAhBvRgyZAc
workflow_name: POST /chat/generate-pdf
trigger: partial_update
created_at: 2025-10-24 14:09:44
workflow_snapshot:
  {"createdAt":"2025-10-23T22:18:56.433Z","updatedAt":"2025-10-24T12:53:35.998Z","id":"QMHZ5IAhBvRgyZAc","name":"POST /chat/generate-pdf","active":true,"isArchived":false,"nodes":[{"parameters":{"httpMethod":"POST","path":"chat/generate-pdf","responseMode":"responseNode","options":{}},"id":"webhook-trigger","name":"POST /chat/generate-pdf","type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[240,312],"webhookId":"67403d18-ee13-4ad3-b9b7-02d012aeaf0e","onError":"continueRegularOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"message-id-condition","leftValue":"={{ $('POST /chat/generate-pdf').first().json.body.message_id }}","rightValue":"","operator":{"type":"string","operation":"notEmpty"}}],"combinator":"and"},"options":{}},"id":"check-message-id","name":"Check Message ID","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[912,400],"onError":"continueErrorOutput"},{"parameters":{"url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_messages?select=id,message,created_at,conversation_threads!inner(user_id)&id=eq.' + $('POST /chat/generate-pdf').first().json.body.message_id + '&conversation_threads.user_id=eq.' + $('JWT Validation').first().json.user_id }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"Prefer","value":"return=representation"}]},"options":{"response":{"response":{"responseFormat":"json"}}}},"id":"query-specific-message","name":"Query Specific Message","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1136,320],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_messages?select=id,message,created_at,conversation_threads!inner(user_id)&conversation_threads.user_id=eq.' + $('JWT Validation').first().json.user_id + '&order=created_at.desc&limit=1' }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"Prefer","value":"return=representation"}]},"options":{"response":{"response":{"responseFormat":"json"}}}},"id":"query-latest-message","name":"Query Latest Message","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1136,512],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"message-exists-condition","leftValue":"={{ $json.id }}","rightValue":"0","operator":{"type":"string","operation":"notEmpty"}}],"combinator":"and"},"options":{}},"id":"check-message-exists","name":"Check Message Exists","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1360,400],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ error: 'Not Found', message: 'Message not found or you do not have access to it' }) }}","options":{"responseCode":404}},"id":"return-not-found","name":"Return Not Found","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1584,320]},{"parameters":{"jsCode":"// Get message data from previous node\nconst messageData = $input.first().json;\n\n// Get user ID from JWT Validation\nconst userId = $('JWT Validation').first().json.user_id;\n\n// Extract content from JSONB structure\nconst content = messageData.message.content;\n\n// Format date in Polish\nconst date = new Date(messageData.created_at);\nconst formattedDate = date.toLocaleDateString('pl-PL', {\n  year: 'numeric',\n  month: 'long',\n  day: 'numeric',\n  hour: '2-digit',\n  minute: '2-digit'\n});\n\n// Create HTML for PDF with WOO branding\nconst html = `<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <style>\n    body {\n      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n      line-height: 1.6;\n      color: #333;\n      padding: 40px;\n      max-width: 800px;\n      margin: 0 auto;\n    }\n    .header {\n      display: flex;\n      justify-content: space-between;\n      align-items: center;\n      margin-bottom: 40px;\n      padding-bottom: 20px;\n      border-bottom: 3px solid #4b0082;\n    }\n    .logo {\n      width: 120px;\n      height: 120px;\n    }\n    .title {\n      color: #4b0082;\n      font-size: 24px;\n      font-weight: 600;\n    }\n    .date {\n      color: #666;\n      font-size: 14px;\n      margin-bottom: 20px;\n    }\n    .content {\n      background: #f9f9f9;\n      padding: 30px;\n      border-radius: 8px;\n      border-left: 4px solid #4b0082;\n    }\n    .footer {\n      margin-top: 40px;\n      padding-top: 20px;\n      border-top: 1px solid #ddd;\n      text-align: center;\n      color: #888;\n      font-size: 12px;\n    }\n  </style>\n</head>\n<body>\n  <div class=\"header\">\n    <div class=\"title\">WOO PRO - Wiadomość</div>\n    <img src=\"https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/public/public_files/logo-email.png\" \n         class=\"logo\" alt=\"WOO Logo\">\n  </div>\n  \n  <div class=\"date\">${formattedDate}</div>\n  \n  <div class=\"content\">\n    ${content.replace(/\\n/g, '<br>')}\n  </div>\n  \n  <div class=\"footer\">\n    Wygenerowano przez WOO PRO<br>\n    Ten dokument jest poufny i przeznaczony wyłącznie dla odbiorcy.\n  </div>\n</body>\n</html>`;\n\nreturn [{\n  json: {\n    html: html,\n    fileName: `${userId}/woo-message-${messageData.id}.pdf`,\n    messageId: messageData.id\n  }\n}];"},"id":"prepare-html-template","name":"Prepare HTML Template","type":"n8n-nodes-base.code","typeVersion":2,"position":[1584,512]},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"pdf-success-condition","leftValue":"={{ $json.error }}","rightValue":"false","operator":{"type":"boolean","operation":"false","singleValue":true}}],"combinator":"and"},"options":{}},"id":"check-pdf-success","name":"Check PDF Success","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[2032,496],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ error: 'PDF Generation Failed', message: $json.message || 'Failed to generate PDF document' }) }}","options":{"responseCode":500}},"id":"return-pdf-error","name":"Return PDF Error","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[2256,416]},{"parameters":{"method":"POST","url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/generated_pdfs/' + $('Prepare HTML Template').first().json.fileName }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Content-Type","value":"application/pdf"}]},"sendBody":true,"contentType":"binaryData","inputDataFieldName":"data","options":{"response":{"response":{"responseFormat":"json"}}}},"id":"upload-pdf-to-storage","name":"Upload PDF to Storage","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2480,608],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"method":"POST","url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/sign/generated_pdfs/' + $('Prepare HTML Template').first().json.fileName }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ { expiresIn: 86400 } }}","options":{"response":{"response":{"responseFormat":"json"}}}},"id":"generate-signed-url","name":"Generate Signed URL","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2704,608],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"jsCode":"const signedUrl = $input.first().json.signedURL;\nconst fileName = $('Prepare HTML Template').first().json.fileName;\nconst messageId = $('Prepare HTML Template').first().json.messageId;\n\nreturn [{\n  json: {\n    success: true,\n    message: 'PDF generated successfully',\n    data: {\n      pdfUrl: `https://xxciwnthnnywanbplqwg.supabase.co${signedUrl}`,\n      fileName: fileName,\n      messageId: messageId,\n      expiresIn: '24 hours'\n    }\n  }\n}];"},"id":"format-success-response","name":"Format Success Response","type":"n8n-nodes-base.code","typeVersion":2,"position":[2928,608]},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify($json) }}","options":{"responseCode":200}},"id":"return-success","name":"Return Success","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[3152,608]},{"parameters":{"method":"POST","url":"https://api.pdf.co/v1/pdf/convert/from/html","sendHeaders":true,"headerParameters":{"parameters":[{"name":"x-api-key","value":"reeunlockyourskills@gmail.com_SQcbrlvobSplxYtx2Ed8h2toSbsqenyPfWqLkjpvjc5uj68FXk78S3DNibeAw3v0"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ { \"html\": $json.html, \"name\": $json.fileName } }}","options":{"response":{"response":{"responseFormat":"json"}}}},"type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1808,512],"id":"f2e54550-eb45-4363-930d-c2908ca394ac","name":"call_generate_pdf"},{"parameters":{"url":"={{ $json.url }}","options":{"response":{"response":{"responseFormat":"file"}}}},"id":"download-pdf-from-url","name":"Download PDF from URL","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2256,608]},{"parameters":{"workflowId":{"__rl":true,"value":"dL4gKHrO0Mtdhpmo","mode":"list","cachedResultUrl":"/workflow/dL4gKHrO0Mtdhpmo","cachedResultName":"JWT Validation Middleware"},"workflowInputs":{"mappingMode":"defineBelow","value":{"headers":"={{ $json.headers }}","body":"={{ $json.body }}"},"matchingColumns":[],"schema":[{"id":"headers","displayName":"headers","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true,"type":"object"},{"id":"body","displayName":"body","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true},{"id":"params","displayName":"params","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true,"type":"object","removed":true}],"attemptToConvertTypes":false,"convertFieldsToString":true},"options":{}},"id":"97fea410-3161-474d-a49e-2dc7804c98db","name":"JWT Validation","type":"n8n-nodes-base.executeWorkflow","typeVersion":1.3,"position":[464,320],"onError":"continueErrorOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"jwt_error_check","leftValue":"={{ $json.is_valid }}","rightValue":"={{ true }}","operator":{"type":"boolean","operation":"false","singleValue":true}}],"combinator":"and"},"options":{}},"id":"1705f618-2fa2-4d37-8ec5-5f117e4df232","name":"Check JWT Error","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[688,320],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ {\n  success: false,\n  data: null,\n  message: 'Unauthorized',\n  metadata: {\n    timestamp: new Date().toISOString()\n  }\n} }}","options":{"responseCode":401}},"id":"dee5bfdc-9a05-4494-80a9-6f36cbcb8d26","name":"JWT Error Response","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[912,192],"onError":"continueRegularOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ {\n  success: false,\n  error: {\n    code: 'UNAUTHORIZED',\n    message: 'Invalid or expired access token'\n  },\n  metadata: {\n    timestamp: new Date().toISOString()\n  }\n} }}","options":{"responseCode":401}},"id":"d0079bd8-15d8-42a8-8418-191fde6dd0f3","name":"Auth Error Response","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[688,512],"onError":"continueRegularOutput"}],"connections":{"POST /chat/generate-pdf":{"main":[[{"node":"JWT Validation","type":"main","index":0}]]},"Query Specific Message":{"main":[[{"node":"Check Message Exists","type":"main","index":0}]]},"Query Latest Message":{"main":[[{"node":"Check Message Exists","type":"main","index":0}]]},"Upload PDF to Storage":{"main":[[{"node":"Generate Signed URL","type":"main","index":0}]]},"Generate Signed URL":{"main":[[{"node":"Format Success Response","type":"main","index":0}]]},"Format Success Response":{"main":[[{"node":"Return Success","type":"main","index":0}]]},"Check Message ID":{"main":[[{"node":"Query Specific Message","type":"main","index":0}],[{"node":"Query Latest Message","type":"main","index":0}]]},"Check Message Exists":{"main":[[{"node":"Prepare HTML Template","type":"main","index":0}],[{"node":"Return Not Found","type":"main","index":0}]]},"Check PDF Success":{"main":[[{"node":"Download PDF from URL","type":"main","index":0}],[{"node":"Return PDF Error","type":"main","index":0}]]},"Prepare HTML Template":{"main":[[{"node":"call_generate_pdf","type":"main","index":0}]]},"call_generate_pdf":{"main":[[{"node":"Check PDF Success","type":"main","index":0}]]},"Download PDF from URL":{"main":[[{"node":"Upload PDF to Storage","type":"main","index":0}]]},"JWT Validation":{"main":[[{"node":"Check JWT Error","type":"main","index":0}],[{"node":"Auth Error Response","type":"main","index":0}]]},"Check JWT Error":{"main":[[{"node":"JWT Error Response","type":"main","index":0}],[{"node":"Check Message ID","type":"main","index":0}]]}},"settings":{"saveManualExecutions":true,"saveDataErrorExecution":"all","saveDataSuccessExecution":"all","errorWorkflow":"","executionOrder":"v1"},"staticData":null,"meta":null,"pinData":{},"versionId":"eabe594e-11d5-4b5c-87ac-783aaf4d99ea","triggerCount":1,"shared":[{"createdAt":"2025-10-23T22:18:56.436Z","updatedAt":"2025-10-23T22:18:56.436Z","role":"workflow:owner","workflowId":"QMHZ5IAhBvRgyZAc","projectId":"sVGwG1Ss6aXKNorC","project":{"createdAt":"2025-07-30T12:18:11.485Z","updatedAt":"2025-07-30T12:20:06.951Z","id":"sVGwG1Ss6aXKNorC","name":"Rafał Dębski <rdebski90@gmail.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-07-30T12:18:11.486Z","updatedAt":"2025-07-30T12:18:11.486Z","userId":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","projectId":"sVGwG1Ss6aXKNorC","user":{"createdAt":"2025-07-30T12:18:10.851Z","updatedAt":"2025-10-23T22:43:16.000Z","id":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","email":"rdebski90@gmail.com","firstName":"Rafał","lastName":"Dębski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-07-30T12:20:09.619Z","personalization_survey_n8n_version":"1.104.1"},"settings":{"userActivated":true,"easyAIWorkflowOnboarded":true,"firstSuccessfulWorkflowId":"gp796pP6j8IFZodb","userActivatedAt":1753881412699,"npsSurvey":{"responded":true,"lastShownAt":1755785806897},"dismissedCallouts":{"ragStarterCallout":true}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"updateNode","nodeId":"format-success-response","updates":{"parameters":{"jsCode":"const signedUrl = $input.first().json.signedURL;\nconst fileName = $('Prepare HTML Template').first().json.fileName;\nconst messageId = $('Prepare HTML Template').first().json.messageId;\n\nreturn [{\n  json: {\n    success: true,\n    message: 'PDF generated successfully',\n    data: {\n      pdfUrl: `https://xxciwnthnnywanbplqwg.supabase.co/storage/v1${signedUrl}`,\n      fileName: fileName,\n      messageId: messageId,\n      expiresIn: '24 hours'\n    }\n  }\n}];"}}}]


workflow_id: QMHZ5IAhBvRgyZAc
workflow_name: POST /chat/generate-pdf
trigger: partial_update
created_at: 2025-10-24 14:24:00
workflow_snapshot:
  {"createdAt":"2025-10-23T22:18:56.433Z","updatedAt":"2025-10-24T14:09:44.540Z","id":"QMHZ5IAhBvRgyZAc","name":"POST /chat/generate-pdf","active":true,"isArchived":false,"nodes":[{"parameters":{"httpMethod":"POST","path":"chat/generate-pdf","responseMode":"responseNode","options":{}},"id":"webhook-trigger","name":"POST /chat/generate-pdf","type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[240,312],"webhookId":"67403d18-ee13-4ad3-b9b7-02d012aeaf0e","onError":"continueRegularOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"message-id-condition","leftValue":"={{ $('POST /chat/generate-pdf').first().json.body.message_id }}","rightValue":"","operator":{"type":"string","operation":"notEmpty"}}],"combinator":"and"},"options":{}},"id":"check-message-id","name":"Check Message ID","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[912,400],"onError":"continueErrorOutput"},{"parameters":{"url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_messages?select=id,message,created_at,conversation_threads!inner(user_id)&id=eq.' + $('POST /chat/generate-pdf').first().json.body.message_id + '&conversation_threads.user_id=eq.' + $('JWT Validation').first().json.user_id }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"Prefer","value":"return=representation"}]},"options":{"response":{"response":{"responseFormat":"json"}}}},"id":"query-specific-message","name":"Query Specific Message","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1136,320],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_messages?select=id,message,created_at,conversation_threads!inner(user_id)&conversation_threads.user_id=eq.' + $('JWT Validation').first().json.user_id + '&order=created_at.desc&limit=1' }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"Prefer","value":"return=representation"}]},"options":{"response":{"response":{"responseFormat":"json"}}}},"id":"query-latest-message","name":"Query Latest Message","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1136,512],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"message-exists-condition","leftValue":"={{ $json.id }}","rightValue":"0","operator":{"type":"string","operation":"notEmpty"}}],"combinator":"and"},"options":{}},"id":"check-message-exists","name":"Check Message Exists","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1360,400],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ error: 'Not Found', message: 'Message not found or you do not have access to it' }) }}","options":{"responseCode":404}},"id":"return-not-found","name":"Return Not Found","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1584,320]},{"parameters":{"jsCode":"// Get message data from previous node\nconst messageData = $input.first().json;\n\n// Get user ID from JWT Validation\nconst userId = $('JWT Validation').first().json.user_id;\n\n// Extract content from JSONB structure\nconst content = messageData.message.content;\n\n// Format date in Polish\nconst date = new Date(messageData.created_at);\nconst formattedDate = date.toLocaleDateString('pl-PL', {\n  year: 'numeric',\n  month: 'long',\n  day: 'numeric',\n  hour: '2-digit',\n  minute: '2-digit'\n});\n\n// Create HTML for PDF with WOO branding\nconst html = `<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <style>\n    body {\n      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n      line-height: 1.6;\n      color: #333;\n      padding: 40px;\n      max-width: 800px;\n      margin: 0 auto;\n    }\n    .header {\n      display: flex;\n      justify-content: space-between;\n      align-items: center;\n      margin-bottom: 40px;\n      padding-bottom: 20px;\n      border-bottom: 3px solid #4b0082;\n    }\n    .logo {\n      width: 120px;\n      height: 120px;\n    }\n    .title {\n      color: #4b0082;\n      font-size: 24px;\n      font-weight: 600;\n    }\n    .date {\n      color: #666;\n      font-size: 14px;\n      margin-bottom: 20px;\n    }\n    .content {\n      background: #f9f9f9;\n      padding: 30px;\n      border-radius: 8px;\n      border-left: 4px solid #4b0082;\n    }\n    .footer {\n      margin-top: 40px;\n      padding-top: 20px;\n      border-top: 1px solid #ddd;\n      text-align: center;\n      color: #888;\n      font-size: 12px;\n    }\n  </style>\n</head>\n<body>\n  <div class=\"header\">\n    <div class=\"title\">WOO PRO - Wiadomość</div>\n    <img src=\"https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/public/public_files/logo-email.png\" \n         class=\"logo\" alt=\"WOO Logo\">\n  </div>\n  \n  <div class=\"date\">${formattedDate}</div>\n  \n  <div class=\"content\">\n    ${content.replace(/\\n/g, '<br>')}\n  </div>\n  \n  <div class=\"footer\">\n    Wygenerowano przez WOO PRO<br>\n    Ten dokument jest poufny i przeznaczony wyłącznie dla odbiorcy.\n  </div>\n</body>\n</html>`;\n\nreturn [{\n  json: {\n    html: html,\n    fileName: `${userId}/woo-message-${messageData.id}.pdf`,\n    messageId: messageData.id\n  }\n}];"},"id":"prepare-html-template","name":"Prepare HTML Template","type":"n8n-nodes-base.code","typeVersion":2,"position":[1584,512]},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"pdf-success-condition","leftValue":"={{ $json.error }}","rightValue":"false","operator":{"type":"boolean","operation":"false","singleValue":true}}],"combinator":"and"},"options":{}},"id":"check-pdf-success","name":"Check PDF Success","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[2032,496],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ error: 'PDF Generation Failed', message: $json.message || 'Failed to generate PDF document' }) }}","options":{"responseCode":500}},"id":"return-pdf-error","name":"Return PDF Error","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[2256,416]},{"parameters":{"method":"POST","url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/generated_pdfs/' + $('Prepare HTML Template').first().json.fileName }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Content-Type","value":"application/pdf"}]},"sendBody":true,"contentType":"binaryData","inputDataFieldName":"data","options":{"response":{"response":{"responseFormat":"json"}}}},"id":"upload-pdf-to-storage","name":"Upload PDF to Storage","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2480,608],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"method":"POST","url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/sign/generated_pdfs/' + $('Prepare HTML Template').first().json.fileName }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ { expiresIn: 86400 } }}","options":{"response":{"response":{"responseFormat":"json"}}}},"id":"generate-signed-url","name":"Generate Signed URL","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2704,608],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"jsCode":"const signedUrl = $input.first().json.signedURL;\nconst fileName = $('Prepare HTML Template').first().json.fileName;\nconst messageId = $('Prepare HTML Template').first().json.messageId;\n\nreturn [{\n  json: {\n    success: true,\n    message: 'PDF generated successfully',\n    data: {\n      pdfUrl: `https://xxciwnthnnywanbplqwg.supabase.co/storage/v1${signedUrl}`,\n      fileName: fileName,\n      messageId: messageId,\n      expiresIn: '24 hours'\n    }\n  }\n}];"},"id":"format-success-response","name":"Format Success Response","type":"n8n-nodes-base.code","typeVersion":2,"position":[2928,608]},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify($json) }}","options":{"responseCode":200}},"id":"return-success","name":"Return Success","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[3152,608]},{"parameters":{"method":"POST","url":"https://api.pdf.co/v1/pdf/convert/from/html","sendHeaders":true,"headerParameters":{"parameters":[{"name":"x-api-key","value":"reeunlockyourskills@gmail.com_SQcbrlvobSplxYtx2Ed8h2toSbsqenyPfWqLkjpvjc5uj68FXk78S3DNibeAw3v0"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ { \"html\": $json.html, \"name\": $json.fileName } }}","options":{"response":{"response":{"responseFormat":"json"}}}},"type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1808,512],"id":"f2e54550-eb45-4363-930d-c2908ca394ac","name":"call_generate_pdf"},{"parameters":{"url":"={{ $json.url }}","options":{"response":{"response":{"responseFormat":"file"}}}},"id":"download-pdf-from-url","name":"Download PDF from URL","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2256,608]},{"parameters":{"workflowId":{"__rl":true,"value":"dL4gKHrO0Mtdhpmo","mode":"list","cachedResultUrl":"/workflow/dL4gKHrO0Mtdhpmo","cachedResultName":"JWT Validation Middleware"},"workflowInputs":{"mappingMode":"defineBelow","value":{"headers":"={{ $json.headers }}","body":"={{ $json.body }}"},"matchingColumns":[],"schema":[{"id":"headers","displayName":"headers","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true,"type":"object"},{"id":"body","displayName":"body","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true},{"id":"params","displayName":"params","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true,"type":"object","removed":true}],"attemptToConvertTypes":false,"convertFieldsToString":true},"options":{}},"id":"97fea410-3161-474d-a49e-2dc7804c98db","name":"JWT Validation","type":"n8n-nodes-base.executeWorkflow","typeVersion":1.3,"position":[464,320],"onError":"continueErrorOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"jwt_error_check","leftValue":"={{ $json.is_valid }}","rightValue":"={{ true }}","operator":{"type":"boolean","operation":"false","singleValue":true}}],"combinator":"and"},"options":{}},"id":"1705f618-2fa2-4d37-8ec5-5f117e4df232","name":"Check JWT Error","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[688,320],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ {\n  success: false,\n  data: null,\n  message: 'Unauthorized',\n  metadata: {\n    timestamp: new Date().toISOString()\n  }\n} }}","options":{"responseCode":401}},"id":"dee5bfdc-9a05-4494-80a9-6f36cbcb8d26","name":"JWT Error Response","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[912,192],"onError":"continueRegularOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ {\n  success: false,\n  error: {\n    code: 'UNAUTHORIZED',\n    message: 'Invalid or expired access token'\n  },\n  metadata: {\n    timestamp: new Date().toISOString()\n  }\n} }}","options":{"responseCode":401}},"id":"d0079bd8-15d8-42a8-8418-191fde6dd0f3","name":"Auth Error Response","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[688,512],"onError":"continueRegularOutput"}],"connections":{"POST /chat/generate-pdf":{"main":[[{"node":"JWT Validation","type":"main","index":0}]]},"Query Specific Message":{"main":[[{"node":"Check Message Exists","type":"main","index":0}]]},"Query Latest Message":{"main":[[{"node":"Check Message Exists","type":"main","index":0}]]},"Upload PDF to Storage":{"main":[[{"node":"Generate Signed URL","type":"main","index":0}]]},"Generate Signed URL":{"main":[[{"node":"Format Success Response","type":"main","index":0}]]},"Format Success Response":{"main":[[{"node":"Return Success","type":"main","index":0}]]},"Check Message ID":{"main":[[{"node":"Query Specific Message","type":"main","index":0}],[{"node":"Query Latest Message","type":"main","index":0}]]},"Check Message Exists":{"main":[[{"node":"Prepare HTML Template","type":"main","index":0}],[{"node":"Return Not Found","type":"main","index":0}]]},"Check PDF Success":{"main":[[{"node":"Download PDF from URL","type":"main","index":0}],[{"node":"Return PDF Error","type":"main","index":0}]]},"Prepare HTML Template":{"main":[[{"node":"call_generate_pdf","type":"main","index":0}]]},"call_generate_pdf":{"main":[[{"node":"Check PDF Success","type":"main","index":0}]]},"Download PDF from URL":{"main":[[{"node":"Upload PDF to Storage","type":"main","index":0}]]},"JWT Validation":{"main":[[{"node":"Check JWT Error","type":"main","index":0}],[{"node":"Auth Error Response","type":"main","index":0}]]},"Check JWT Error":{"main":[[{"node":"JWT Error Response","type":"main","index":0}],[{"node":"Check Message ID","type":"main","index":0}]]}},"settings":{"saveManualExecutions":true,"saveDataErrorExecution":"all","saveDataSuccessExecution":"all","errorWorkflow":"","executionOrder":"v1"},"staticData":null,"meta":null,"pinData":{},"versionId":"8ad38d74-a0d1-4ad6-b2e8-d75f11042f69","triggerCount":1,"shared":[{"createdAt":"2025-10-23T22:18:56.436Z","updatedAt":"2025-10-23T22:18:56.436Z","role":"workflow:owner","workflowId":"QMHZ5IAhBvRgyZAc","projectId":"sVGwG1Ss6aXKNorC","project":{"createdAt":"2025-07-30T12:18:11.485Z","updatedAt":"2025-07-30T12:20:06.951Z","id":"sVGwG1Ss6aXKNorC","name":"Rafał Dębski <rdebski90@gmail.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-07-30T12:18:11.486Z","updatedAt":"2025-07-30T12:18:11.486Z","userId":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","projectId":"sVGwG1Ss6aXKNorC","user":{"createdAt":"2025-07-30T12:18:10.851Z","updatedAt":"2025-10-23T22:43:16.000Z","id":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","email":"rdebski90@gmail.com","firstName":"Rafał","lastName":"Dębski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-07-30T12:20:09.619Z","personalization_survey_n8n_version":"1.104.1"},"settings":{"userActivated":true,"easyAIWorkflowOnboarded":true,"firstSuccessfulWorkflowId":"gp796pP6j8IFZodb","userActivatedAt":1753881412699,"npsSurvey":{"responded":true,"lastShownAt":1755785806897},"dismissedCallouts":{"ragStarterCallout":true}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"updateNode","nodeId":"dee5bfdc-9a05-4494-80a9-6f36cbcb8d26","updates":{"parameters":{"respondWith":"json","responseBody":"={{ {\n  success: false,\n  data: null,\n  error: 'Unauthorized',\n  metadata: {\n    timestamp: new Date().toISOString()\n  }\n} }}","options":{"responseCode":401}}}}]


workflow_id: QMHZ5IAhBvRgyZAc
workflow_name: POST /chat/generate-pdf
trigger: partial_update
created_at: 2025-10-24 14:24:40
workflow_snapshot:
  {"createdAt":"2025-10-23T22:18:56.433Z","updatedAt":"2025-10-24T14:24:00.353Z","id":"QMHZ5IAhBvRgyZAc","name":"POST /chat/generate-pdf","active":true,"isArchived":false,"nodes":[{"parameters":{"httpMethod":"POST","path":"chat/generate-pdf","responseMode":"responseNode","options":{}},"id":"webhook-trigger","name":"POST /chat/generate-pdf","type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[240,312],"webhookId":"67403d18-ee13-4ad3-b9b7-02d012aeaf0e","onError":"continueRegularOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"message-id-condition","leftValue":"={{ $('POST /chat/generate-pdf').first().json.body.message_id }}","rightValue":"","operator":{"type":"string","operation":"notEmpty"}}],"combinator":"and"},"options":{}},"id":"check-message-id","name":"Check Message ID","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[912,400],"onError":"continueErrorOutput"},{"parameters":{"url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_messages?select=id,message,created_at,conversation_threads!inner(user_id)&id=eq.' + $('POST /chat/generate-pdf').first().json.body.message_id + '&conversation_threads.user_id=eq.' + $('JWT Validation').first().json.user_id }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"Prefer","value":"return=representation"}]},"options":{"response":{"response":{"responseFormat":"json"}}}},"id":"query-specific-message","name":"Query Specific Message","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1136,320],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_messages?select=id,message,created_at,conversation_threads!inner(user_id)&conversation_threads.user_id=eq.' + $('JWT Validation').first().json.user_id + '&order=created_at.desc&limit=1' }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"Prefer","value":"return=representation"}]},"options":{"response":{"response":{"responseFormat":"json"}}}},"id":"query-latest-message","name":"Query Latest Message","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1136,512],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"message-exists-condition","leftValue":"={{ $json.id }}","rightValue":"0","operator":{"type":"string","operation":"notEmpty"}}],"combinator":"and"},"options":{}},"id":"check-message-exists","name":"Check Message Exists","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1360,400],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ error: 'Not Found', message: 'Message not found or you do not have access to it' }) }}","options":{"responseCode":404}},"id":"return-not-found","name":"Return Not Found","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1584,320]},{"parameters":{"jsCode":"// Get message data from previous node\nconst messageData = $input.first().json;\n\n// Get user ID from JWT Validation\nconst userId = $('JWT Validation').first().json.user_id;\n\n// Extract content from JSONB structure\nconst content = messageData.message.content;\n\n// Format date in Polish\nconst date = new Date(messageData.created_at);\nconst formattedDate = date.toLocaleDateString('pl-PL', {\n  year: 'numeric',\n  month: 'long',\n  day: 'numeric',\n  hour: '2-digit',\n  minute: '2-digit'\n});\n\n// Create HTML for PDF with WOO branding\nconst html = `<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <style>\n    body {\n      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n      line-height: 1.6;\n      color: #333;\n      padding: 40px;\n      max-width: 800px;\n      margin: 0 auto;\n    }\n    .header {\n      display: flex;\n      justify-content: space-between;\n      align-items: center;\n      margin-bottom: 40px;\n      padding-bottom: 20px;\n      border-bottom: 3px solid #4b0082;\n    }\n    .logo {\n      width: 120px;\n      height: 120px;\n    }\n    .title {\n      color: #4b0082;\n      font-size: 24px;\n      font-weight: 600;\n    }\n    .date {\n      color: #666;\n      font-size: 14px;\n      margin-bottom: 20px;\n    }\n    .content {\n      background: #f9f9f9;\n      padding: 30px;\n      border-radius: 8px;\n      border-left: 4px solid #4b0082;\n    }\n    .footer {\n      margin-top: 40px;\n      padding-top: 20px;\n      border-top: 1px solid #ddd;\n      text-align: center;\n      color: #888;\n      font-size: 12px;\n    }\n  </style>\n</head>\n<body>\n  <div class=\"header\">\n    <div class=\"title\">WOO PRO - Wiadomość</div>\n    <img src=\"https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/public/public_files/logo-email.png\" \n         class=\"logo\" alt=\"WOO Logo\">\n  </div>\n  \n  <div class=\"date\">${formattedDate}</div>\n  \n  <div class=\"content\">\n    ${content.replace(/\\n/g, '<br>')}\n  </div>\n  \n  <div class=\"footer\">\n    Wygenerowano przez WOO PRO<br>\n    Ten dokument jest poufny i przeznaczony wyłącznie dla odbiorcy.\n  </div>\n</body>\n</html>`;\n\nreturn [{\n  json: {\n    html: html,\n    fileName: `${userId}/woo-message-${messageData.id}.pdf`,\n    messageId: messageData.id\n  }\n}];"},"id":"prepare-html-template","name":"Prepare HTML Template","type":"n8n-nodes-base.code","typeVersion":2,"position":[1584,512]},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"pdf-success-condition","leftValue":"={{ $json.error }}","rightValue":"false","operator":{"type":"boolean","operation":"false","singleValue":true}}],"combinator":"and"},"options":{}},"id":"check-pdf-success","name":"Check PDF Success","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[2032,496],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ error: 'PDF Generation Failed', message: $json.message || 'Failed to generate PDF document' }) }}","options":{"responseCode":500}},"id":"return-pdf-error","name":"Return PDF Error","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[2256,416]},{"parameters":{"method":"POST","url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/generated_pdfs/' + $('Prepare HTML Template').first().json.fileName }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Content-Type","value":"application/pdf"}]},"sendBody":true,"contentType":"binaryData","inputDataFieldName":"data","options":{"response":{"response":{"responseFormat":"json"}}}},"id":"upload-pdf-to-storage","name":"Upload PDF to Storage","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2480,608],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"method":"POST","url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/sign/generated_pdfs/' + $('Prepare HTML Template').first().json.fileName }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ { expiresIn: 86400 } }}","options":{"response":{"response":{"responseFormat":"json"}}}},"id":"generate-signed-url","name":"Generate Signed URL","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2704,608],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"jsCode":"const signedUrl = $input.first().json.signedURL;\nconst fileName = $('Prepare HTML Template').first().json.fileName;\nconst messageId = $('Prepare HTML Template').first().json.messageId;\n\nreturn [{\n  json: {\n    success: true,\n    message: 'PDF generated successfully',\n    data: {\n      pdfUrl: `https://xxciwnthnnywanbplqwg.supabase.co/storage/v1${signedUrl}`,\n      fileName: fileName,\n      messageId: messageId,\n      expiresIn: '24 hours'\n    }\n  }\n}];"},"id":"format-success-response","name":"Format Success Response","type":"n8n-nodes-base.code","typeVersion":2,"position":[2928,608]},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify($json) }}","options":{"responseCode":200}},"id":"return-success","name":"Return Success","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[3152,608]},{"parameters":{"method":"POST","url":"https://api.pdf.co/v1/pdf/convert/from/html","sendHeaders":true,"headerParameters":{"parameters":[{"name":"x-api-key","value":"reeunlockyourskills@gmail.com_SQcbrlvobSplxYtx2Ed8h2toSbsqenyPfWqLkjpvjc5uj68FXk78S3DNibeAw3v0"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ { \"html\": $json.html, \"name\": $json.fileName } }}","options":{"response":{"response":{"responseFormat":"json"}}}},"type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1808,512],"id":"f2e54550-eb45-4363-930d-c2908ca394ac","name":"call_generate_pdf"},{"parameters":{"url":"={{ $json.url }}","options":{"response":{"response":{"responseFormat":"file"}}}},"id":"download-pdf-from-url","name":"Download PDF from URL","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2256,608]},{"parameters":{"workflowId":{"__rl":true,"value":"dL4gKHrO0Mtdhpmo","mode":"list","cachedResultUrl":"/workflow/dL4gKHrO0Mtdhpmo","cachedResultName":"JWT Validation Middleware"},"workflowInputs":{"mappingMode":"defineBelow","value":{"headers":"={{ $json.headers }}","body":"={{ $json.body }}"},"matchingColumns":[],"schema":[{"id":"headers","displayName":"headers","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true,"type":"object"},{"id":"body","displayName":"body","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true},{"id":"params","displayName":"params","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true,"type":"object","removed":true}],"attemptToConvertTypes":false,"convertFieldsToString":true},"options":{}},"id":"97fea410-3161-474d-a49e-2dc7804c98db","name":"JWT Validation","type":"n8n-nodes-base.executeWorkflow","typeVersion":1.3,"position":[464,320],"onError":"continueErrorOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"jwt_error_check","leftValue":"={{ $json.is_valid }}","rightValue":"={{ true }}","operator":{"type":"boolean","operation":"false","singleValue":true}}],"combinator":"and"},"options":{}},"id":"1705f618-2fa2-4d37-8ec5-5f117e4df232","name":"Check JWT Error","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[688,320],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ {\n  success: false,\n  data: null,\n  error: 'Unauthorized',\n  metadata: {\n    timestamp: new Date().toISOString()\n  }\n} }}","options":{"responseCode":401}},"id":"dee5bfdc-9a05-4494-80a9-6f36cbcb8d26","name":"JWT Error Response","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[912,192],"onError":"continueRegularOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ {\n  success: false,\n  error: {\n    code: 'UNAUTHORIZED',\n    message: 'Invalid or expired access token'\n  },\n  metadata: {\n    timestamp: new Date().toISOString()\n  }\n} }}","options":{"responseCode":401}},"id":"d0079bd8-15d8-42a8-8418-191fde6dd0f3","name":"Auth Error Response","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[688,512],"onError":"continueRegularOutput"}],"connections":{"POST /chat/generate-pdf":{"main":[[{"node":"JWT Validation","type":"main","index":0}]]},"Query Specific Message":{"main":[[{"node":"Check Message Exists","type":"main","index":0}]]},"Query Latest Message":{"main":[[{"node":"Check Message Exists","type":"main","index":0}]]},"Upload PDF to Storage":{"main":[[{"node":"Generate Signed URL","type":"main","index":0}]]},"Generate Signed URL":{"main":[[{"node":"Format Success Response","type":"main","index":0}]]},"Format Success Response":{"main":[[{"node":"Return Success","type":"main","index":0}]]},"Check Message ID":{"main":[[{"node":"Query Specific Message","type":"main","index":0}],[{"node":"Query Latest Message","type":"main","index":0}]]},"Check Message Exists":{"main":[[{"node":"Prepare HTML Template","type":"main","index":0}],[{"node":"Return Not Found","type":"main","index":0}]]},"Check PDF Success":{"main":[[{"node":"Download PDF from URL","type":"main","index":0}],[{"node":"Return PDF Error","type":"main","index":0}]]},"Prepare HTML Template":{"main":[[{"node":"call_generate_pdf","type":"main","index":0}]]},"call_generate_pdf":{"main":[[{"node":"Check PDF Success","type":"main","index":0}]]},"Download PDF from URL":{"main":[[{"node":"Upload PDF to Storage","type":"main","index":0}]]},"JWT Validation":{"main":[[{"node":"Check JWT Error","type":"main","index":0}],[{"node":"Auth Error Response","type":"main","index":0}]]},"Check JWT Error":{"main":[[{"node":"JWT Error Response","type":"main","index":0}],[{"node":"Check Message ID","type":"main","index":0}]]}},"settings":{"saveManualExecutions":true,"saveDataErrorExecution":"all","saveDataSuccessExecution":"all","errorWorkflow":"","executionOrder":"v1"},"staticData":null,"meta":null,"pinData":{},"versionId":"6d096452-1178-4b54-bea6-0257608ae55c","triggerCount":1,"shared":[{"createdAt":"2025-10-23T22:18:56.436Z","updatedAt":"2025-10-23T22:18:56.436Z","role":"workflow:owner","workflowId":"QMHZ5IAhBvRgyZAc","projectId":"sVGwG1Ss6aXKNorC","project":{"createdAt":"2025-07-30T12:18:11.485Z","updatedAt":"2025-07-30T12:20:06.951Z","id":"sVGwG1Ss6aXKNorC","name":"Rafał Dębski <rdebski90@gmail.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-07-30T12:18:11.486Z","updatedAt":"2025-07-30T12:18:11.486Z","userId":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","projectId":"sVGwG1Ss6aXKNorC","user":{"createdAt":"2025-07-30T12:18:10.851Z","updatedAt":"2025-10-23T22:43:16.000Z","id":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","email":"rdebski90@gmail.com","firstName":"Rafał","lastName":"Dębski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-07-30T12:20:09.619Z","personalization_survey_n8n_version":"1.104.1"},"settings":{"userActivated":true,"easyAIWorkflowOnboarded":true,"firstSuccessfulWorkflowId":"gp796pP6j8IFZodb","userActivatedAt":1753881412699,"npsSurvey":{"responded":true,"lastShownAt":1755785806897},"dismissedCallouts":{"ragStarterCallout":true}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"id":"validate-uuid-format","name":"Validate UUID Format","type":"n8n-nodes-base.code","typeVersion":2,"position":[1024,320],"parameters":{"jsCode":"const messageId = $('POST /chat/generate-pdf').first().json.body.message_id;\n\n// UUID v4 regex pattern\nconst uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\nconst isValid = uuidRegex.test(messageId);\n\nreturn [{\n  json: {\n    messageId: messageId,\n    isValidUUID: isValid\n  }\n}];"}}},{"type":"addNode","node":{"id":"check-uuid-valid","name":"Check UUID Valid","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1136,240],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"uuid-valid-condition","leftValue":"={{ $json.isValidUUID }}","rightValue":"={{ true }}","operator":{"type":"boolean","operation":"true","singleValue":true}}],"combinator":"and"},"options":{}},"onError":"continueErrorOutput"}},{"type":"addNode","node":{"id":"return-invalid-uuid","name":"Return Invalid UUID","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1360,160],"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ success: false, error: 'Invalid message_id format. Expected valid UUID.' }) }}","options":{"responseCode":400}}}}]


workflow_id: QMHZ5IAhBvRgyZAc
workflow_name: POST /chat/generate-pdf
trigger: partial_update
created_at: 2025-10-24 14:24:58
workflow_snapshot:
  {"createdAt":"2025-10-23T22:18:56.433Z","updatedAt":"2025-10-24T14:24:00.353Z","id":"QMHZ5IAhBvRgyZAc","name":"POST /chat/generate-pdf","active":true,"isArchived":false,"nodes":[{"parameters":{"httpMethod":"POST","path":"chat/generate-pdf","responseMode":"responseNode","options":{}},"id":"webhook-trigger","name":"POST /chat/generate-pdf","type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[240,312],"webhookId":"67403d18-ee13-4ad3-b9b7-02d012aeaf0e","onError":"continueRegularOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"message-id-condition","leftValue":"={{ $('POST /chat/generate-pdf').first().json.body.message_id }}","rightValue":"","operator":{"type":"string","operation":"notEmpty"}}],"combinator":"and"},"options":{}},"id":"check-message-id","name":"Check Message ID","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[912,400],"onError":"continueErrorOutput"},{"parameters":{"url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_messages?select=id,message,created_at,conversation_threads!inner(user_id)&id=eq.' + $('POST /chat/generate-pdf').first().json.body.message_id + '&conversation_threads.user_id=eq.' + $('JWT Validation').first().json.user_id }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"Prefer","value":"return=representation"}]},"options":{"response":{"response":{"responseFormat":"json"}}}},"id":"query-specific-message","name":"Query Specific Message","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1136,320],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_messages?select=id,message,created_at,conversation_threads!inner(user_id)&conversation_threads.user_id=eq.' + $('JWT Validation').first().json.user_id + '&order=created_at.desc&limit=1' }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"Prefer","value":"return=representation"}]},"options":{"response":{"response":{"responseFormat":"json"}}}},"id":"query-latest-message","name":"Query Latest Message","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1136,512],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"message-exists-condition","leftValue":"={{ $json.id }}","rightValue":"0","operator":{"type":"string","operation":"notEmpty"}}],"combinator":"and"},"options":{}},"id":"check-message-exists","name":"Check Message Exists","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1360,400],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ error: 'Not Found', message: 'Message not found or you do not have access to it' }) }}","options":{"responseCode":404}},"id":"return-not-found","name":"Return Not Found","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1584,320]},{"parameters":{"jsCode":"// Get message data from previous node\nconst messageData = $input.first().json;\n\n// Get user ID from JWT Validation\nconst userId = $('JWT Validation').first().json.user_id;\n\n// Extract content from JSONB structure\nconst content = messageData.message.content;\n\n// Format date in Polish\nconst date = new Date(messageData.created_at);\nconst formattedDate = date.toLocaleDateString('pl-PL', {\n  year: 'numeric',\n  month: 'long',\n  day: 'numeric',\n  hour: '2-digit',\n  minute: '2-digit'\n});\n\n// Create HTML for PDF with WOO branding\nconst html = `<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <style>\n    body {\n      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n      line-height: 1.6;\n      color: #333;\n      padding: 40px;\n      max-width: 800px;\n      margin: 0 auto;\n    }\n    .header {\n      display: flex;\n      justify-content: space-between;\n      align-items: center;\n      margin-bottom: 40px;\n      padding-bottom: 20px;\n      border-bottom: 3px solid #4b0082;\n    }\n    .logo {\n      width: 120px;\n      height: 120px;\n    }\n    .title {\n      color: #4b0082;\n      font-size: 24px;\n      font-weight: 600;\n    }\n    .date {\n      color: #666;\n      font-size: 14px;\n      margin-bottom: 20px;\n    }\n    .content {\n      background: #f9f9f9;\n      padding: 30px;\n      border-radius: 8px;\n      border-left: 4px solid #4b0082;\n    }\n    .footer {\n      margin-top: 40px;\n      padding-top: 20px;\n      border-top: 1px solid #ddd;\n      text-align: center;\n      color: #888;\n      font-size: 12px;\n    }\n  </style>\n</head>\n<body>\n  <div class=\"header\">\n    <div class=\"title\">WOO PRO - Wiadomość</div>\n    <img src=\"https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/public/public_files/logo-email.png\" \n         class=\"logo\" alt=\"WOO Logo\">\n  </div>\n  \n  <div class=\"date\">${formattedDate}</div>\n  \n  <div class=\"content\">\n    ${content.replace(/\\n/g, '<br>')}\n  </div>\n  \n  <div class=\"footer\">\n    Wygenerowano przez WOO PRO<br>\n    Ten dokument jest poufny i przeznaczony wyłącznie dla odbiorcy.\n  </div>\n</body>\n</html>`;\n\nreturn [{\n  json: {\n    html: html,\n    fileName: `${userId}/woo-message-${messageData.id}.pdf`,\n    messageId: messageData.id\n  }\n}];"},"id":"prepare-html-template","name":"Prepare HTML Template","type":"n8n-nodes-base.code","typeVersion":2,"position":[1584,512]},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"pdf-success-condition","leftValue":"={{ $json.error }}","rightValue":"false","operator":{"type":"boolean","operation":"false","singleValue":true}}],"combinator":"and"},"options":{}},"id":"check-pdf-success","name":"Check PDF Success","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[2032,496],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ error: 'PDF Generation Failed', message: $json.message || 'Failed to generate PDF document' }) }}","options":{"responseCode":500}},"id":"return-pdf-error","name":"Return PDF Error","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[2256,416]},{"parameters":{"method":"POST","url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/generated_pdfs/' + $('Prepare HTML Template').first().json.fileName }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Content-Type","value":"application/pdf"}]},"sendBody":true,"contentType":"binaryData","inputDataFieldName":"data","options":{"response":{"response":{"responseFormat":"json"}}}},"id":"upload-pdf-to-storage","name":"Upload PDF to Storage","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2480,608],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"method":"POST","url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/sign/generated_pdfs/' + $('Prepare HTML Template').first().json.fileName }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ { expiresIn: 86400 } }}","options":{"response":{"response":{"responseFormat":"json"}}}},"id":"generate-signed-url","name":"Generate Signed URL","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2704,608],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"jsCode":"const signedUrl = $input.first().json.signedURL;\nconst fileName = $('Prepare HTML Template').first().json.fileName;\nconst messageId = $('Prepare HTML Template').first().json.messageId;\n\nreturn [{\n  json: {\n    success: true,\n    message: 'PDF generated successfully',\n    data: {\n      pdfUrl: `https://xxciwnthnnywanbplqwg.supabase.co/storage/v1${signedUrl}`,\n      fileName: fileName,\n      messageId: messageId,\n      expiresIn: '24 hours'\n    }\n  }\n}];"},"id":"format-success-response","name":"Format Success Response","type":"n8n-nodes-base.code","typeVersion":2,"position":[2928,608]},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify($json) }}","options":{"responseCode":200}},"id":"return-success","name":"Return Success","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[3152,608]},{"parameters":{"method":"POST","url":"https://api.pdf.co/v1/pdf/convert/from/html","sendHeaders":true,"headerParameters":{"parameters":[{"name":"x-api-key","value":"reeunlockyourskills@gmail.com_SQcbrlvobSplxYtx2Ed8h2toSbsqenyPfWqLkjpvjc5uj68FXk78S3DNibeAw3v0"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ { \"html\": $json.html, \"name\": $json.fileName } }}","options":{"response":{"response":{"responseFormat":"json"}}}},"type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1808,512],"id":"f2e54550-eb45-4363-930d-c2908ca394ac","name":"call_generate_pdf"},{"parameters":{"url":"={{ $json.url }}","options":{"response":{"response":{"responseFormat":"file"}}}},"id":"download-pdf-from-url","name":"Download PDF from URL","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2256,608]},{"parameters":{"workflowId":{"__rl":true,"value":"dL4gKHrO0Mtdhpmo","mode":"list","cachedResultUrl":"/workflow/dL4gKHrO0Mtdhpmo","cachedResultName":"JWT Validation Middleware"},"workflowInputs":{"mappingMode":"defineBelow","value":{"headers":"={{ $json.headers }}","body":"={{ $json.body }}"},"matchingColumns":[],"schema":[{"id":"headers","displayName":"headers","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true,"type":"object"},{"id":"body","displayName":"body","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true},{"id":"params","displayName":"params","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true,"type":"object","removed":true}],"attemptToConvertTypes":false,"convertFieldsToString":true},"options":{}},"id":"97fea410-3161-474d-a49e-2dc7804c98db","name":"JWT Validation","type":"n8n-nodes-base.executeWorkflow","typeVersion":1.3,"position":[464,320],"onError":"continueErrorOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"jwt_error_check","leftValue":"={{ $json.is_valid }}","rightValue":"={{ true }}","operator":{"type":"boolean","operation":"false","singleValue":true}}],"combinator":"and"},"options":{}},"id":"1705f618-2fa2-4d37-8ec5-5f117e4df232","name":"Check JWT Error","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[688,320],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ {\n  success: false,\n  data: null,\n  error: 'Unauthorized',\n  metadata: {\n    timestamp: new Date().toISOString()\n  }\n} }}","options":{"responseCode":401}},"id":"dee5bfdc-9a05-4494-80a9-6f36cbcb8d26","name":"JWT Error Response","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[912,192],"onError":"continueRegularOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ {\n  success: false,\n  error: {\n    code: 'UNAUTHORIZED',\n    message: 'Invalid or expired access token'\n  },\n  metadata: {\n    timestamp: new Date().toISOString()\n  }\n} }}","options":{"responseCode":401}},"id":"d0079bd8-15d8-42a8-8418-191fde6dd0f3","name":"Auth Error Response","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[688,512],"onError":"continueRegularOutput"}],"connections":{"POST /chat/generate-pdf":{"main":[[{"node":"JWT Validation","type":"main","index":0}]]},"Query Specific Message":{"main":[[{"node":"Check Message Exists","type":"main","index":0}]]},"Query Latest Message":{"main":[[{"node":"Check Message Exists","type":"main","index":0}]]},"Upload PDF to Storage":{"main":[[{"node":"Generate Signed URL","type":"main","index":0}]]},"Generate Signed URL":{"main":[[{"node":"Format Success Response","type":"main","index":0}]]},"Format Success Response":{"main":[[{"node":"Return Success","type":"main","index":0}]]},"Check Message ID":{"main":[[{"node":"Query Specific Message","type":"main","index":0}],[{"node":"Query Latest Message","type":"main","index":0}]]},"Check Message Exists":{"main":[[{"node":"Prepare HTML Template","type":"main","index":0}],[{"node":"Return Not Found","type":"main","index":0}]]},"Check PDF Success":{"main":[[{"node":"Download PDF from URL","type":"main","index":0}],[{"node":"Return PDF Error","type":"main","index":0}]]},"Prepare HTML Template":{"main":[[{"node":"call_generate_pdf","type":"main","index":0}]]},"call_generate_pdf":{"main":[[{"node":"Check PDF Success","type":"main","index":0}]]},"Download PDF from URL":{"main":[[{"node":"Upload PDF to Storage","type":"main","index":0}]]},"JWT Validation":{"main":[[{"node":"Check JWT Error","type":"main","index":0}],[{"node":"Auth Error Response","type":"main","index":0}]]},"Check JWT Error":{"main":[[{"node":"JWT Error Response","type":"main","index":0}],[{"node":"Check Message ID","type":"main","index":0}]]}},"settings":{"saveManualExecutions":true,"saveDataErrorExecution":"all","saveDataSuccessExecution":"all","errorWorkflow":"","executionOrder":"v1"},"staticData":null,"meta":null,"pinData":{},"versionId":"6d096452-1178-4b54-bea6-0257608ae55c","triggerCount":1,"shared":[{"createdAt":"2025-10-23T22:18:56.436Z","updatedAt":"2025-10-23T22:18:56.436Z","role":"workflow:owner","workflowId":"QMHZ5IAhBvRgyZAc","projectId":"sVGwG1Ss6aXKNorC","project":{"createdAt":"2025-07-30T12:18:11.485Z","updatedAt":"2025-07-30T12:20:06.951Z","id":"sVGwG1Ss6aXKNorC","name":"Rafał Dębski <rdebski90@gmail.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-07-30T12:18:11.486Z","updatedAt":"2025-07-30T12:18:11.486Z","userId":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","projectId":"sVGwG1Ss6aXKNorC","user":{"createdAt":"2025-07-30T12:18:10.851Z","updatedAt":"2025-10-23T22:43:16.000Z","id":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","email":"rdebski90@gmail.com","firstName":"Rafał","lastName":"Dębski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-07-30T12:20:09.619Z","personalization_survey_n8n_version":"1.104.1"},"settings":{"userActivated":true,"easyAIWorkflowOnboarded":true,"firstSuccessfulWorkflowId":"gp796pP6j8IFZodb","userActivatedAt":1753881412699,"npsSurvey":{"responded":true,"lastShownAt":1755785806897},"dismissedCallouts":{"ragStarterCallout":true}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"id":"validate-uuid-format","name":"Validate UUID Format","type":"n8n-nodes-base.code","typeVersion":2,"position":[1024,320],"parameters":{"jsCode":"const messageId = $('POST /chat/generate-pdf').first().json.body.message_id;\n\n// UUID v4 regex pattern\nconst uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\nconst isValid = uuidRegex.test(messageId);\n\nreturn [{\n  json: {\n    messageId: messageId,\n    isValidUUID: isValid\n  }\n}];"}}},{"type":"addNode","node":{"id":"check-uuid-valid","name":"Check UUID Valid","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1248,320],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"uuid-valid-condition","leftValue":"={{ $json.isValidUUID }}","rightValue":"={{ true }}","operator":{"type":"boolean","operation":"true","singleValue":true}}],"combinator":"and"},"options":{}},"onError":"continueErrorOutput"}},{"type":"addNode","node":{"id":"return-invalid-uuid","name":"Return Invalid UUID","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1472,240],"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ success: false, error: 'Invalid message_id format. Expected valid UUID.' }) }}","options":{"responseCode":400}}}},{"type":"removeConnection","source":"check-message-id","target":"query-specific-message"},{"type":"addConnection","source":"check-message-id","target":"validate-uuid-format"},{"type":"addConnection","source":"validate-uuid-format","target":"check-uuid-valid"},{"type":"addConnection","source":"check-uuid-valid","target":"query-specific-message"},{"type":"addConnection","source":"check-uuid-valid","target":"return-invalid-uuid"}]


workflow_id: QMHZ5IAhBvRgyZAc
workflow_name: POST /chat/generate-pdf
trigger: partial_update
created_at: 2025-10-24 14:25:09
workflow_snapshot:
  {"createdAt":"2025-10-23T22:18:56.433Z","updatedAt":"2025-10-24T14:24:58.342Z","id":"QMHZ5IAhBvRgyZAc","name":"POST /chat/generate-pdf","active":true,"isArchived":false,"nodes":[{"parameters":{"httpMethod":"POST","path":"chat/generate-pdf","responseMode":"responseNode","options":{}},"id":"webhook-trigger","name":"POST /chat/generate-pdf","type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[240,312],"webhookId":"67403d18-ee13-4ad3-b9b7-02d012aeaf0e","onError":"continueRegularOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"message-id-condition","leftValue":"={{ $('POST /chat/generate-pdf').first().json.body.message_id }}","rightValue":"","operator":{"type":"string","operation":"notEmpty"}}],"combinator":"and"},"options":{}},"id":"check-message-id","name":"Check Message ID","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[912,400],"onError":"continueErrorOutput"},{"parameters":{"url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_messages?select=id,message,created_at,conversation_threads!inner(user_id)&id=eq.' + $('POST /chat/generate-pdf').first().json.body.message_id + '&conversation_threads.user_id=eq.' + $('JWT Validation').first().json.user_id }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"Prefer","value":"return=representation"}]},"options":{"response":{"response":{"responseFormat":"json"}}}},"id":"query-specific-message","name":"Query Specific Message","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1136,320],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_messages?select=id,message,created_at,conversation_threads!inner(user_id)&conversation_threads.user_id=eq.' + $('JWT Validation').first().json.user_id + '&order=created_at.desc&limit=1' }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"Prefer","value":"return=representation"}]},"options":{"response":{"response":{"responseFormat":"json"}}}},"id":"query-latest-message","name":"Query Latest Message","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1136,512],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"message-exists-condition","leftValue":"={{ $json.id }}","rightValue":"0","operator":{"type":"string","operation":"notEmpty"}}],"combinator":"and"},"options":{}},"id":"check-message-exists","name":"Check Message Exists","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1360,400],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ error: 'Not Found', message: 'Message not found or you do not have access to it' }) }}","options":{"responseCode":404}},"id":"return-not-found","name":"Return Not Found","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1584,320]},{"parameters":{"jsCode":"// Get message data from previous node\nconst messageData = $input.first().json;\n\n// Get user ID from JWT Validation\nconst userId = $('JWT Validation').first().json.user_id;\n\n// Extract content from JSONB structure\nconst content = messageData.message.content;\n\n// Format date in Polish\nconst date = new Date(messageData.created_at);\nconst formattedDate = date.toLocaleDateString('pl-PL', {\n  year: 'numeric',\n  month: 'long',\n  day: 'numeric',\n  hour: '2-digit',\n  minute: '2-digit'\n});\n\n// Create HTML for PDF with WOO branding\nconst html = `<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <style>\n    body {\n      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n      line-height: 1.6;\n      color: #333;\n      padding: 40px;\n      max-width: 800px;\n      margin: 0 auto;\n    }\n    .header {\n      display: flex;\n      justify-content: space-between;\n      align-items: center;\n      margin-bottom: 40px;\n      padding-bottom: 20px;\n      border-bottom: 3px solid #4b0082;\n    }\n    .logo {\n      width: 120px;\n      height: 120px;\n    }\n    .title {\n      color: #4b0082;\n      font-size: 24px;\n      font-weight: 600;\n    }\n    .date {\n      color: #666;\n      font-size: 14px;\n      margin-bottom: 20px;\n    }\n    .content {\n      background: #f9f9f9;\n      padding: 30px;\n      border-radius: 8px;\n      border-left: 4px solid #4b0082;\n    }\n    .footer {\n      margin-top: 40px;\n      padding-top: 20px;\n      border-top: 1px solid #ddd;\n      text-align: center;\n      color: #888;\n      font-size: 12px;\n    }\n  </style>\n</head>\n<body>\n  <div class=\"header\">\n    <div class=\"title\">WOO PRO - Wiadomość</div>\n    <img src=\"https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/public/public_files/logo-email.png\" \n         class=\"logo\" alt=\"WOO Logo\">\n  </div>\n  \n  <div class=\"date\">${formattedDate}</div>\n  \n  <div class=\"content\">\n    ${content.replace(/\\n/g, '<br>')}\n  </div>\n  \n  <div class=\"footer\">\n    Wygenerowano przez WOO PRO<br>\n    Ten dokument jest poufny i przeznaczony wyłącznie dla odbiorcy.\n  </div>\n</body>\n</html>`;\n\nreturn [{\n  json: {\n    html: html,\n    fileName: `${userId}/woo-message-${messageData.id}.pdf`,\n    messageId: messageData.id\n  }\n}];"},"id":"prepare-html-template","name":"Prepare HTML Template","type":"n8n-nodes-base.code","typeVersion":2,"position":[1584,512]},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"pdf-success-condition","leftValue":"={{ $json.error }}","rightValue":"false","operator":{"type":"boolean","operation":"false","singleValue":true}}],"combinator":"and"},"options":{}},"id":"check-pdf-success","name":"Check PDF Success","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[2032,496],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ error: 'PDF Generation Failed', message: $json.message || 'Failed to generate PDF document' }) }}","options":{"responseCode":500}},"id":"return-pdf-error","name":"Return PDF Error","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[2256,416]},{"parameters":{"method":"POST","url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/generated_pdfs/' + $('Prepare HTML Template').first().json.fileName }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Content-Type","value":"application/pdf"}]},"sendBody":true,"contentType":"binaryData","inputDataFieldName":"data","options":{"response":{"response":{"responseFormat":"json"}}}},"id":"upload-pdf-to-storage","name":"Upload PDF to Storage","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2480,608],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"method":"POST","url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/sign/generated_pdfs/' + $('Prepare HTML Template').first().json.fileName }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ { expiresIn: 86400 } }}","options":{"response":{"response":{"responseFormat":"json"}}}},"id":"generate-signed-url","name":"Generate Signed URL","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2704,608],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"jsCode":"const signedUrl = $input.first().json.signedURL;\nconst fileName = $('Prepare HTML Template').first().json.fileName;\nconst messageId = $('Prepare HTML Template').first().json.messageId;\n\nreturn [{\n  json: {\n    success: true,\n    message: 'PDF generated successfully',\n    data: {\n      pdfUrl: `https://xxciwnthnnywanbplqwg.supabase.co/storage/v1${signedUrl}`,\n      fileName: fileName,\n      messageId: messageId,\n      expiresIn: '24 hours'\n    }\n  }\n}];"},"id":"format-success-response","name":"Format Success Response","type":"n8n-nodes-base.code","typeVersion":2,"position":[2928,608]},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify($json) }}","options":{"responseCode":200}},"id":"return-success","name":"Return Success","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[3152,608]},{"parameters":{"method":"POST","url":"https://api.pdf.co/v1/pdf/convert/from/html","sendHeaders":true,"headerParameters":{"parameters":[{"name":"x-api-key","value":"reeunlockyourskills@gmail.com_SQcbrlvobSplxYtx2Ed8h2toSbsqenyPfWqLkjpvjc5uj68FXk78S3DNibeAw3v0"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ { \"html\": $json.html, \"name\": $json.fileName } }}","options":{"response":{"response":{"responseFormat":"json"}}}},"type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1808,512],"id":"f2e54550-eb45-4363-930d-c2908ca394ac","name":"call_generate_pdf"},{"parameters":{"url":"={{ $json.url }}","options":{"response":{"response":{"responseFormat":"file"}}}},"id":"download-pdf-from-url","name":"Download PDF from URL","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2256,608]},{"parameters":{"workflowId":{"__rl":true,"value":"dL4gKHrO0Mtdhpmo","mode":"list","cachedResultUrl":"/workflow/dL4gKHrO0Mtdhpmo","cachedResultName":"JWT Validation Middleware"},"workflowInputs":{"mappingMode":"defineBelow","value":{"headers":"={{ $json.headers }}","body":"={{ $json.body }}"},"matchingColumns":[],"schema":[{"id":"headers","displayName":"headers","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true,"type":"object"},{"id":"body","displayName":"body","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true},{"id":"params","displayName":"params","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true,"type":"object","removed":true}],"attemptToConvertTypes":false,"convertFieldsToString":true},"options":{}},"id":"97fea410-3161-474d-a49e-2dc7804c98db","name":"JWT Validation","type":"n8n-nodes-base.executeWorkflow","typeVersion":1.3,"position":[464,320],"onError":"continueErrorOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"jwt_error_check","leftValue":"={{ $json.is_valid }}","rightValue":"={{ true }}","operator":{"type":"boolean","operation":"false","singleValue":true}}],"combinator":"and"},"options":{}},"id":"1705f618-2fa2-4d37-8ec5-5f117e4df232","name":"Check JWT Error","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[688,320],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ {\n  success: false,\n  data: null,\n  error: 'Unauthorized',\n  metadata: {\n    timestamp: new Date().toISOString()\n  }\n} }}","options":{"responseCode":401}},"id":"dee5bfdc-9a05-4494-80a9-6f36cbcb8d26","name":"JWT Error Response","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[912,192],"onError":"continueRegularOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ {\n  success: false,\n  error: {\n    code: 'UNAUTHORIZED',\n    message: 'Invalid or expired access token'\n  },\n  metadata: {\n    timestamp: new Date().toISOString()\n  }\n} }}","options":{"responseCode":401}},"id":"d0079bd8-15d8-42a8-8418-191fde6dd0f3","name":"Auth Error Response","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[688,512],"onError":"continueRegularOutput"},{"id":"validate-uuid-format","name":"Validate UUID Format","type":"n8n-nodes-base.code","typeVersion":2,"position":[1024,320],"parameters":{"jsCode":"const messageId = $('POST /chat/generate-pdf').first().json.body.message_id;\n\n// UUID v4 regex pattern\nconst uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\nconst isValid = uuidRegex.test(messageId);\n\nreturn [{\n  json: {\n    messageId: messageId,\n    isValidUUID: isValid\n  }\n}];"}},{"id":"check-uuid-valid","name":"Check UUID Valid","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1248,320],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"uuid-valid-condition","leftValue":"={{ $json.isValidUUID }}","rightValue":"={{ true }}","operator":{"type":"boolean","operation":"true","singleValue":true}}],"combinator":"and"},"options":{}},"onError":"continueErrorOutput"},{"id":"return-invalid-uuid","name":"Return Invalid UUID","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1472,240],"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ success: false, error: 'Invalid message_id format. Expected valid UUID.' }) }}","options":{"responseCode":400}}}],"connections":{"POST /chat/generate-pdf":{"main":[[{"node":"JWT Validation","type":"main","index":0}]]},"Query Specific Message":{"main":[[{"node":"Check Message Exists","type":"main","index":0}]]},"Query Latest Message":{"main":[[{"node":"Check Message Exists","type":"main","index":0}]]},"Upload PDF to Storage":{"main":[[{"node":"Generate Signed URL","type":"main","index":0}]]},"Generate Signed URL":{"main":[[{"node":"Format Success Response","type":"main","index":0}]]},"Format Success Response":{"main":[[{"node":"Return Success","type":"main","index":0}]]},"Check Message ID":{"main":[[{"node":"Validate UUID Format","type":"main","index":0}],[{"node":"Query Latest Message","type":"main","index":0}]]},"Check Message Exists":{"main":[[{"node":"Prepare HTML Template","type":"main","index":0}],[{"node":"Return Not Found","type":"main","index":0}]]},"Check PDF Success":{"main":[[{"node":"Download PDF from URL","type":"main","index":0}],[{"node":"Return PDF Error","type":"main","index":0}]]},"Prepare HTML Template":{"main":[[{"node":"call_generate_pdf","type":"main","index":0}]]},"call_generate_pdf":{"main":[[{"node":"Check PDF Success","type":"main","index":0}]]},"Download PDF from URL":{"main":[[{"node":"Upload PDF to Storage","type":"main","index":0}]]},"JWT Validation":{"main":[[{"node":"Check JWT Error","type":"main","index":0}],[{"node":"Auth Error Response","type":"main","index":0}]]},"Check JWT Error":{"main":[[{"node":"JWT Error Response","type":"main","index":0}],[{"node":"Check Message ID","type":"main","index":0}]]},"Validate UUID Format":{"main":[[{"node":"Check UUID Valid","type":"main","index":0}]]},"Check UUID Valid":{"main":[[{"node":"Query Specific Message","type":"main","index":0},{"node":"Return Invalid UUID","type":"main","index":0}]]}},"settings":{"saveManualExecutions":true,"saveDataErrorExecution":"all","saveDataSuccessExecution":"all","errorWorkflow":"","executionOrder":"v1"},"staticData":null,"meta":null,"pinData":{},"versionId":"19749b07-a8cb-48ed-9042-0f4a43d99509","triggerCount":1,"shared":[{"createdAt":"2025-10-23T22:18:56.436Z","updatedAt":"2025-10-23T22:18:56.436Z","role":"workflow:owner","workflowId":"QMHZ5IAhBvRgyZAc","projectId":"sVGwG1Ss6aXKNorC","project":{"createdAt":"2025-07-30T12:18:11.485Z","updatedAt":"2025-07-30T12:20:06.951Z","id":"sVGwG1Ss6aXKNorC","name":"Rafał Dębski <rdebski90@gmail.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-07-30T12:18:11.486Z","updatedAt":"2025-07-30T12:18:11.486Z","userId":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","projectId":"sVGwG1Ss6aXKNorC","user":{"createdAt":"2025-07-30T12:18:10.851Z","updatedAt":"2025-10-23T22:43:16.000Z","id":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","email":"rdebski90@gmail.com","firstName":"Rafał","lastName":"Dębski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-07-30T12:20:09.619Z","personalization_survey_n8n_version":"1.104.1"},"settings":{"userActivated":true,"easyAIWorkflowOnboarded":true,"firstSuccessfulWorkflowId":"gp796pP6j8IFZodb","userActivatedAt":1753881412699,"npsSurvey":{"responded":true,"lastShownAt":1755785806897},"dismissedCallouts":{"ragStarterCallout":true}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"removeConnection","source":"check-uuid-valid","target":"return-invalid-uuid"},{"type":"addConnection","source":"check-uuid-valid","target":"return-invalid-uuid"}]


workflow_id: QMHZ5IAhBvRgyZAc
workflow_name: POST /chat/generate-pdf
trigger: partial_update
created_at: 2025-10-24 14:25:23
workflow_snapshot:
  {"createdAt":"2025-10-23T22:18:56.433Z","updatedAt":"2025-10-24T14:25:10.114Z","id":"QMHZ5IAhBvRgyZAc","name":"POST /chat/generate-pdf","active":true,"isArchived":false,"nodes":[{"parameters":{"httpMethod":"POST","path":"chat/generate-pdf","responseMode":"responseNode","options":{}},"id":"webhook-trigger","name":"POST /chat/generate-pdf","type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[240,312],"webhookId":"67403d18-ee13-4ad3-b9b7-02d012aeaf0e","onError":"continueRegularOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"message-id-condition","leftValue":"={{ $('POST /chat/generate-pdf').first().json.body.message_id }}","rightValue":"","operator":{"type":"string","operation":"notEmpty"}}],"combinator":"and"},"options":{}},"id":"check-message-id","name":"Check Message ID","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[912,400],"onError":"continueErrorOutput"},{"parameters":{"url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_messages?select=id,message,created_at,conversation_threads!inner(user_id)&id=eq.' + $('POST /chat/generate-pdf').first().json.body.message_id + '&conversation_threads.user_id=eq.' + $('JWT Validation').first().json.user_id }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"Prefer","value":"return=representation"}]},"options":{"response":{"response":{"responseFormat":"json"}}}},"id":"query-specific-message","name":"Query Specific Message","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1136,320],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_messages?select=id,message,created_at,conversation_threads!inner(user_id)&conversation_threads.user_id=eq.' + $('JWT Validation').first().json.user_id + '&order=created_at.desc&limit=1' }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"Prefer","value":"return=representation"}]},"options":{"response":{"response":{"responseFormat":"json"}}}},"id":"query-latest-message","name":"Query Latest Message","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1136,512],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"message-exists-condition","leftValue":"={{ $json.id }}","rightValue":"0","operator":{"type":"string","operation":"notEmpty"}}],"combinator":"and"},"options":{}},"id":"check-message-exists","name":"Check Message Exists","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1360,400],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ error: 'Not Found', message: 'Message not found or you do not have access to it' }) }}","options":{"responseCode":404}},"id":"return-not-found","name":"Return Not Found","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1584,320]},{"parameters":{"jsCode":"// Get message data from previous node\nconst messageData = $input.first().json;\n\n// Get user ID from JWT Validation\nconst userId = $('JWT Validation').first().json.user_id;\n\n// Extract content from JSONB structure\nconst content = messageData.message.content;\n\n// Format date in Polish\nconst date = new Date(messageData.created_at);\nconst formattedDate = date.toLocaleDateString('pl-PL', {\n  year: 'numeric',\n  month: 'long',\n  day: 'numeric',\n  hour: '2-digit',\n  minute: '2-digit'\n});\n\n// Create HTML for PDF with WOO branding\nconst html = `<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <style>\n    body {\n      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n      line-height: 1.6;\n      color: #333;\n      padding: 40px;\n      max-width: 800px;\n      margin: 0 auto;\n    }\n    .header {\n      display: flex;\n      justify-content: space-between;\n      align-items: center;\n      margin-bottom: 40px;\n      padding-bottom: 20px;\n      border-bottom: 3px solid #4b0082;\n    }\n    .logo {\n      width: 120px;\n      height: 120px;\n    }\n    .title {\n      color: #4b0082;\n      font-size: 24px;\n      font-weight: 600;\n    }\n    .date {\n      color: #666;\n      font-size: 14px;\n      margin-bottom: 20px;\n    }\n    .content {\n      background: #f9f9f9;\n      padding: 30px;\n      border-radius: 8px;\n      border-left: 4px solid #4b0082;\n    }\n    .footer {\n      margin-top: 40px;\n      padding-top: 20px;\n      border-top: 1px solid #ddd;\n      text-align: center;\n      color: #888;\n      font-size: 12px;\n    }\n  </style>\n</head>\n<body>\n  <div class=\"header\">\n    <div class=\"title\">WOO PRO - Wiadomość</div>\n    <img src=\"https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/public/public_files/logo-email.png\" \n         class=\"logo\" alt=\"WOO Logo\">\n  </div>\n  \n  <div class=\"date\">${formattedDate}</div>\n  \n  <div class=\"content\">\n    ${content.replace(/\\n/g, '<br>')}\n  </div>\n  \n  <div class=\"footer\">\n    Wygenerowano przez WOO PRO<br>\n    Ten dokument jest poufny i przeznaczony wyłącznie dla odbiorcy.\n  </div>\n</body>\n</html>`;\n\nreturn [{\n  json: {\n    html: html,\n    fileName: `${userId}/woo-message-${messageData.id}.pdf`,\n    messageId: messageData.id\n  }\n}];"},"id":"prepare-html-template","name":"Prepare HTML Template","type":"n8n-nodes-base.code","typeVersion":2,"position":[1584,512]},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"pdf-success-condition","leftValue":"={{ $json.error }}","rightValue":"false","operator":{"type":"boolean","operation":"false","singleValue":true}}],"combinator":"and"},"options":{}},"id":"check-pdf-success","name":"Check PDF Success","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[2032,496],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ error: 'PDF Generation Failed', message: $json.message || 'Failed to generate PDF document' }) }}","options":{"responseCode":500}},"id":"return-pdf-error","name":"Return PDF Error","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[2256,416]},{"parameters":{"method":"POST","url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/generated_pdfs/' + $('Prepare HTML Template').first().json.fileName }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Content-Type","value":"application/pdf"}]},"sendBody":true,"contentType":"binaryData","inputDataFieldName":"data","options":{"response":{"response":{"responseFormat":"json"}}}},"id":"upload-pdf-to-storage","name":"Upload PDF to Storage","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2480,608],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"method":"POST","url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/sign/generated_pdfs/' + $('Prepare HTML Template').first().json.fileName }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ { expiresIn: 86400 } }}","options":{"response":{"response":{"responseFormat":"json"}}}},"id":"generate-signed-url","name":"Generate Signed URL","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2704,608],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"jsCode":"const signedUrl = $input.first().json.signedURL;\nconst fileName = $('Prepare HTML Template').first().json.fileName;\nconst messageId = $('Prepare HTML Template').first().json.messageId;\n\nreturn [{\n  json: {\n    success: true,\n    message: 'PDF generated successfully',\n    data: {\n      pdfUrl: `https://xxciwnthnnywanbplqwg.supabase.co/storage/v1${signedUrl}`,\n      fileName: fileName,\n      messageId: messageId,\n      expiresIn: '24 hours'\n    }\n  }\n}];"},"id":"format-success-response","name":"Format Success Response","type":"n8n-nodes-base.code","typeVersion":2,"position":[2928,608]},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify($json) }}","options":{"responseCode":200}},"id":"return-success","name":"Return Success","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[3152,608]},{"parameters":{"method":"POST","url":"https://api.pdf.co/v1/pdf/convert/from/html","sendHeaders":true,"headerParameters":{"parameters":[{"name":"x-api-key","value":"reeunlockyourskills@gmail.com_SQcbrlvobSplxYtx2Ed8h2toSbsqenyPfWqLkjpvjc5uj68FXk78S3DNibeAw3v0"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ { \"html\": $json.html, \"name\": $json.fileName } }}","options":{"response":{"response":{"responseFormat":"json"}}}},"type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1808,512],"id":"f2e54550-eb45-4363-930d-c2908ca394ac","name":"call_generate_pdf"},{"parameters":{"url":"={{ $json.url }}","options":{"response":{"response":{"responseFormat":"file"}}}},"id":"download-pdf-from-url","name":"Download PDF from URL","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2256,608]},{"parameters":{"workflowId":{"__rl":true,"value":"dL4gKHrO0Mtdhpmo","mode":"list","cachedResultUrl":"/workflow/dL4gKHrO0Mtdhpmo","cachedResultName":"JWT Validation Middleware"},"workflowInputs":{"mappingMode":"defineBelow","value":{"headers":"={{ $json.headers }}","body":"={{ $json.body }}"},"matchingColumns":[],"schema":[{"id":"headers","displayName":"headers","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true,"type":"object"},{"id":"body","displayName":"body","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true},{"id":"params","displayName":"params","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true,"type":"object","removed":true}],"attemptToConvertTypes":false,"convertFieldsToString":true},"options":{}},"id":"97fea410-3161-474d-a49e-2dc7804c98db","name":"JWT Validation","type":"n8n-nodes-base.executeWorkflow","typeVersion":1.3,"position":[464,320],"onError":"continueErrorOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"jwt_error_check","leftValue":"={{ $json.is_valid }}","rightValue":"={{ true }}","operator":{"type":"boolean","operation":"false","singleValue":true}}],"combinator":"and"},"options":{}},"id":"1705f618-2fa2-4d37-8ec5-5f117e4df232","name":"Check JWT Error","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[688,320],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ {\n  success: false,\n  data: null,\n  error: 'Unauthorized',\n  metadata: {\n    timestamp: new Date().toISOString()\n  }\n} }}","options":{"responseCode":401}},"id":"dee5bfdc-9a05-4494-80a9-6f36cbcb8d26","name":"JWT Error Response","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[912,192],"onError":"continueRegularOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ {\n  success: false,\n  error: {\n    code: 'UNAUTHORIZED',\n    message: 'Invalid or expired access token'\n  },\n  metadata: {\n    timestamp: new Date().toISOString()\n  }\n} }}","options":{"responseCode":401}},"id":"d0079bd8-15d8-42a8-8418-191fde6dd0f3","name":"Auth Error Response","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[688,512],"onError":"continueRegularOutput"},{"id":"validate-uuid-format","name":"Validate UUID Format","type":"n8n-nodes-base.code","typeVersion":2,"position":[1024,320],"parameters":{"jsCode":"const messageId = $('POST /chat/generate-pdf').first().json.body.message_id;\n\n// UUID v4 regex pattern\nconst uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\nconst isValid = uuidRegex.test(messageId);\n\nreturn [{\n  json: {\n    messageId: messageId,\n    isValidUUID: isValid\n  }\n}];"}},{"id":"check-uuid-valid","name":"Check UUID Valid","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1248,320],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"uuid-valid-condition","leftValue":"={{ $json.isValidUUID }}","rightValue":"={{ true }}","operator":{"type":"boolean","operation":"true","singleValue":true}}],"combinator":"and"},"options":{}},"onError":"continueErrorOutput"},{"id":"return-invalid-uuid","name":"Return Invalid UUID","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1472,240],"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ success: false, error: 'Invalid message_id format. Expected valid UUID.' }) }}","options":{"responseCode":400}}}],"connections":{"POST /chat/generate-pdf":{"main":[[{"node":"JWT Validation","type":"main","index":0}]]},"Query Specific Message":{"main":[[{"node":"Check Message Exists","type":"main","index":0}]]},"Query Latest Message":{"main":[[{"node":"Check Message Exists","type":"main","index":0}]]},"Upload PDF to Storage":{"main":[[{"node":"Generate Signed URL","type":"main","index":0}]]},"Generate Signed URL":{"main":[[{"node":"Format Success Response","type":"main","index":0}]]},"Format Success Response":{"main":[[{"node":"Return Success","type":"main","index":0}]]},"Check Message ID":{"main":[[{"node":"Validate UUID Format","type":"main","index":0}],[{"node":"Query Latest Message","type":"main","index":0}]]},"Check Message Exists":{"main":[[{"node":"Prepare HTML Template","type":"main","index":0}],[{"node":"Return Not Found","type":"main","index":0}]]},"Check PDF Success":{"main":[[{"node":"Download PDF from URL","type":"main","index":0}],[{"node":"Return PDF Error","type":"main","index":0}]]},"Prepare HTML Template":{"main":[[{"node":"call_generate_pdf","type":"main","index":0}]]},"call_generate_pdf":{"main":[[{"node":"Check PDF Success","type":"main","index":0}]]},"Download PDF from URL":{"main":[[{"node":"Upload PDF to Storage","type":"main","index":0}]]},"JWT Validation":{"main":[[{"node":"Check JWT Error","type":"main","index":0}],[{"node":"Auth Error Response","type":"main","index":0}]]},"Check JWT Error":{"main":[[{"node":"JWT Error Response","type":"main","index":0}],[{"node":"Check Message ID","type":"main","index":0}]]},"Validate UUID Format":{"main":[[{"node":"Check UUID Valid","type":"main","index":0}]]},"Check UUID Valid":{"main":[[{"node":"Query Specific Message","type":"main","index":0},{"node":"Return Invalid UUID","type":"main","index":0}]]}},"settings":{"saveManualExecutions":true,"saveDataErrorExecution":"all","saveDataSuccessExecution":"all","errorWorkflow":"","executionOrder":"v1"},"staticData":null,"meta":null,"pinData":{},"versionId":"a00afb45-9926-4b08-86d4-d1ac8dcc3bc0","triggerCount":1,"shared":[{"createdAt":"2025-10-23T22:18:56.436Z","updatedAt":"2025-10-23T22:18:56.436Z","role":"workflow:owner","workflowId":"QMHZ5IAhBvRgyZAc","projectId":"sVGwG1Ss6aXKNorC","project":{"createdAt":"2025-07-30T12:18:11.485Z","updatedAt":"2025-07-30T12:20:06.951Z","id":"sVGwG1Ss6aXKNorC","name":"Rafał Dębski <rdebski90@gmail.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-07-30T12:18:11.486Z","updatedAt":"2025-07-30T12:18:11.486Z","userId":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","projectId":"sVGwG1Ss6aXKNorC","user":{"createdAt":"2025-07-30T12:18:10.851Z","updatedAt":"2025-10-23T22:43:16.000Z","id":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","email":"rdebski90@gmail.com","firstName":"Rafał","lastName":"Dębski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-07-30T12:20:09.619Z","personalization_survey_n8n_version":"1.104.1"},"settings":{"userActivated":true,"easyAIWorkflowOnboarded":true,"firstSuccessfulWorkflowId":"gp796pP6j8IFZodb","userActivatedAt":1753881412699,"npsSurvey":{"responded":true,"lastShownAt":1755785806897},"dismissedCallouts":{"ragStarterCallout":true}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"removeConnection","source":"check-uuid-valid","target":"query-specific-message"},{"type":"removeConnection","source":"check-uuid-valid","target":"return-invalid-uuid"},{"type":"addConnection","source":"check-uuid-valid","target":"query-specific-message"},{"type":"addConnection","source":"check-uuid-valid","target":"return-invalid-uuid"}]


workflow_id: QMHZ5IAhBvRgyZAc
workflow_name: POST /chat/generate-pdf
trigger: partial_update
created_at: 2025-10-24 14:25:52
workflow_snapshot:
  {"createdAt":"2025-10-23T22:18:56.433Z","updatedAt":"2025-10-24T14:25:23.457Z","id":"QMHZ5IAhBvRgyZAc","name":"POST /chat/generate-pdf","active":true,"isArchived":false,"nodes":[{"parameters":{"httpMethod":"POST","path":"chat/generate-pdf","responseMode":"responseNode","options":{}},"id":"webhook-trigger","name":"POST /chat/generate-pdf","type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[240,312],"webhookId":"67403d18-ee13-4ad3-b9b7-02d012aeaf0e","onError":"continueRegularOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"message-id-condition","leftValue":"={{ $('POST /chat/generate-pdf').first().json.body.message_id }}","rightValue":"","operator":{"type":"string","operation":"notEmpty"}}],"combinator":"and"},"options":{}},"id":"check-message-id","name":"Check Message ID","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[912,400],"onError":"continueErrorOutput"},{"parameters":{"url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_messages?select=id,message,created_at,conversation_threads!inner(user_id)&id=eq.' + $('POST /chat/generate-pdf').first().json.body.message_id + '&conversation_threads.user_id=eq.' + $('JWT Validation').first().json.user_id }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"Prefer","value":"return=representation"}]},"options":{"response":{"response":{"responseFormat":"json"}}}},"id":"query-specific-message","name":"Query Specific Message","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1136,320],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_messages?select=id,message,created_at,conversation_threads!inner(user_id)&conversation_threads.user_id=eq.' + $('JWT Validation').first().json.user_id + '&order=created_at.desc&limit=1' }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"Prefer","value":"return=representation"}]},"options":{"response":{"response":{"responseFormat":"json"}}}},"id":"query-latest-message","name":"Query Latest Message","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1136,512],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"message-exists-condition","leftValue":"={{ $json.id }}","rightValue":"0","operator":{"type":"string","operation":"notEmpty"}}],"combinator":"and"},"options":{}},"id":"check-message-exists","name":"Check Message Exists","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1360,400],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ error: 'Not Found', message: 'Message not found or you do not have access to it' }) }}","options":{"responseCode":404}},"id":"return-not-found","name":"Return Not Found","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1584,320]},{"parameters":{"jsCode":"// Get message data from previous node\nconst messageData = $input.first().json;\n\n// Get user ID from JWT Validation\nconst userId = $('JWT Validation').first().json.user_id;\n\n// Extract content from JSONB structure\nconst content = messageData.message.content;\n\n// Format date in Polish\nconst date = new Date(messageData.created_at);\nconst formattedDate = date.toLocaleDateString('pl-PL', {\n  year: 'numeric',\n  month: 'long',\n  day: 'numeric',\n  hour: '2-digit',\n  minute: '2-digit'\n});\n\n// Create HTML for PDF with WOO branding\nconst html = `<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <style>\n    body {\n      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n      line-height: 1.6;\n      color: #333;\n      padding: 40px;\n      max-width: 800px;\n      margin: 0 auto;\n    }\n    .header {\n      display: flex;\n      justify-content: space-between;\n      align-items: center;\n      margin-bottom: 40px;\n      padding-bottom: 20px;\n      border-bottom: 3px solid #4b0082;\n    }\n    .logo {\n      width: 120px;\n      height: 120px;\n    }\n    .title {\n      color: #4b0082;\n      font-size: 24px;\n      font-weight: 600;\n    }\n    .date {\n      color: #666;\n      font-size: 14px;\n      margin-bottom: 20px;\n    }\n    .content {\n      background: #f9f9f9;\n      padding: 30px;\n      border-radius: 8px;\n      border-left: 4px solid #4b0082;\n    }\n    .footer {\n      margin-top: 40px;\n      padding-top: 20px;\n      border-top: 1px solid #ddd;\n      text-align: center;\n      color: #888;\n      font-size: 12px;\n    }\n  </style>\n</head>\n<body>\n  <div class=\"header\">\n    <div class=\"title\">WOO PRO - Wiadomość</div>\n    <img src=\"https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/public/public_files/logo-email.png\" \n         class=\"logo\" alt=\"WOO Logo\">\n  </div>\n  \n  <div class=\"date\">${formattedDate}</div>\n  \n  <div class=\"content\">\n    ${content.replace(/\\n/g, '<br>')}\n  </div>\n  \n  <div class=\"footer\">\n    Wygenerowano przez WOO PRO<br>\n    Ten dokument jest poufny i przeznaczony wyłącznie dla odbiorcy.\n  </div>\n</body>\n</html>`;\n\nreturn [{\n  json: {\n    html: html,\n    fileName: `${userId}/woo-message-${messageData.id}.pdf`,\n    messageId: messageData.id\n  }\n}];"},"id":"prepare-html-template","name":"Prepare HTML Template","type":"n8n-nodes-base.code","typeVersion":2,"position":[1584,512]},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"pdf-success-condition","leftValue":"={{ $json.error }}","rightValue":"false","operator":{"type":"boolean","operation":"false","singleValue":true}}],"combinator":"and"},"options":{}},"id":"check-pdf-success","name":"Check PDF Success","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[2032,496],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ error: 'PDF Generation Failed', message: $json.message || 'Failed to generate PDF document' }) }}","options":{"responseCode":500}},"id":"return-pdf-error","name":"Return PDF Error","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[2256,416]},{"parameters":{"method":"POST","url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/generated_pdfs/' + $('Prepare HTML Template').first().json.fileName }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Content-Type","value":"application/pdf"}]},"sendBody":true,"contentType":"binaryData","inputDataFieldName":"data","options":{"response":{"response":{"responseFormat":"json"}}}},"id":"upload-pdf-to-storage","name":"Upload PDF to Storage","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2480,608],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"method":"POST","url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/sign/generated_pdfs/' + $('Prepare HTML Template').first().json.fileName }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ { expiresIn: 86400 } }}","options":{"response":{"response":{"responseFormat":"json"}}}},"id":"generate-signed-url","name":"Generate Signed URL","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2704,608],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"jsCode":"const signedUrl = $input.first().json.signedURL;\nconst fileName = $('Prepare HTML Template').first().json.fileName;\nconst messageId = $('Prepare HTML Template').first().json.messageId;\n\nreturn [{\n  json: {\n    success: true,\n    message: 'PDF generated successfully',\n    data: {\n      pdfUrl: `https://xxciwnthnnywanbplqwg.supabase.co/storage/v1${signedUrl}`,\n      fileName: fileName,\n      messageId: messageId,\n      expiresIn: '24 hours'\n    }\n  }\n}];"},"id":"format-success-response","name":"Format Success Response","type":"n8n-nodes-base.code","typeVersion":2,"position":[2928,608]},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify($json) }}","options":{"responseCode":200}},"id":"return-success","name":"Return Success","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[3152,608]},{"parameters":{"method":"POST","url":"https://api.pdf.co/v1/pdf/convert/from/html","sendHeaders":true,"headerParameters":{"parameters":[{"name":"x-api-key","value":"reeunlockyourskills@gmail.com_SQcbrlvobSplxYtx2Ed8h2toSbsqenyPfWqLkjpvjc5uj68FXk78S3DNibeAw3v0"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ { \"html\": $json.html, \"name\": $json.fileName } }}","options":{"response":{"response":{"responseFormat":"json"}}}},"type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1808,512],"id":"f2e54550-eb45-4363-930d-c2908ca394ac","name":"call_generate_pdf"},{"parameters":{"url":"={{ $json.url }}","options":{"response":{"response":{"responseFormat":"file"}}}},"id":"download-pdf-from-url","name":"Download PDF from URL","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2256,608]},{"parameters":{"workflowId":{"__rl":true,"value":"dL4gKHrO0Mtdhpmo","mode":"list","cachedResultUrl":"/workflow/dL4gKHrO0Mtdhpmo","cachedResultName":"JWT Validation Middleware"},"workflowInputs":{"mappingMode":"defineBelow","value":{"headers":"={{ $json.headers }}","body":"={{ $json.body }}"},"matchingColumns":[],"schema":[{"id":"headers","displayName":"headers","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true,"type":"object"},{"id":"body","displayName":"body","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true},{"id":"params","displayName":"params","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true,"type":"object","removed":true}],"attemptToConvertTypes":false,"convertFieldsToString":true},"options":{}},"id":"97fea410-3161-474d-a49e-2dc7804c98db","name":"JWT Validation","type":"n8n-nodes-base.executeWorkflow","typeVersion":1.3,"position":[464,320],"onError":"continueErrorOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"jwt_error_check","leftValue":"={{ $json.is_valid }}","rightValue":"={{ true }}","operator":{"type":"boolean","operation":"false","singleValue":true}}],"combinator":"and"},"options":{}},"id":"1705f618-2fa2-4d37-8ec5-5f117e4df232","name":"Check JWT Error","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[688,320],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ {\n  success: false,\n  data: null,\n  error: 'Unauthorized',\n  metadata: {\n    timestamp: new Date().toISOString()\n  }\n} }}","options":{"responseCode":401}},"id":"dee5bfdc-9a05-4494-80a9-6f36cbcb8d26","name":"JWT Error Response","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[912,192],"onError":"continueRegularOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ {\n  success: false,\n  error: {\n    code: 'UNAUTHORIZED',\n    message: 'Invalid or expired access token'\n  },\n  metadata: {\n    timestamp: new Date().toISOString()\n  }\n} }}","options":{"responseCode":401}},"id":"d0079bd8-15d8-42a8-8418-191fde6dd0f3","name":"Auth Error Response","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[688,512],"onError":"continueRegularOutput"},{"id":"validate-uuid-format","name":"Validate UUID Format","type":"n8n-nodes-base.code","typeVersion":2,"position":[1024,320],"parameters":{"jsCode":"const messageId = $('POST /chat/generate-pdf').first().json.body.message_id;\n\n// UUID v4 regex pattern\nconst uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\nconst isValid = uuidRegex.test(messageId);\n\nreturn [{\n  json: {\n    messageId: messageId,\n    isValidUUID: isValid\n  }\n}];"}},{"id":"check-uuid-valid","name":"Check UUID Valid","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1248,320],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"uuid-valid-condition","leftValue":"={{ $json.isValidUUID }}","rightValue":"={{ true }}","operator":{"type":"boolean","operation":"true","singleValue":true}}],"combinator":"and"},"options":{}},"onError":"continueErrorOutput"},{"id":"return-invalid-uuid","name":"Return Invalid UUID","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1472,240],"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ success: false, error: 'Invalid message_id format. Expected valid UUID.' }) }}","options":{"responseCode":400}}}],"connections":{"POST /chat/generate-pdf":{"main":[[{"node":"JWT Validation","type":"main","index":0}]]},"Query Specific Message":{"main":[[{"node":"Check Message Exists","type":"main","index":0}]]},"Query Latest Message":{"main":[[{"node":"Check Message Exists","type":"main","index":0}]]},"Upload PDF to Storage":{"main":[[{"node":"Generate Signed URL","type":"main","index":0}]]},"Generate Signed URL":{"main":[[{"node":"Format Success Response","type":"main","index":0}]]},"Format Success Response":{"main":[[{"node":"Return Success","type":"main","index":0}]]},"Check Message ID":{"main":[[{"node":"Validate UUID Format","type":"main","index":0}],[{"node":"Query Latest Message","type":"main","index":0}]]},"Check Message Exists":{"main":[[{"node":"Prepare HTML Template","type":"main","index":0}],[{"node":"Return Not Found","type":"main","index":0}]]},"Check PDF Success":{"main":[[{"node":"Download PDF from URL","type":"main","index":0}],[{"node":"Return PDF Error","type":"main","index":0}]]},"Prepare HTML Template":{"main":[[{"node":"call_generate_pdf","type":"main","index":0}]]},"call_generate_pdf":{"main":[[{"node":"Check PDF Success","type":"main","index":0}]]},"Download PDF from URL":{"main":[[{"node":"Upload PDF to Storage","type":"main","index":0}]]},"JWT Validation":{"main":[[{"node":"Check JWT Error","type":"main","index":0}],[{"node":"Auth Error Response","type":"main","index":0}]]},"Check JWT Error":{"main":[[{"node":"JWT Error Response","type":"main","index":0}],[{"node":"Check Message ID","type":"main","index":0}]]},"Validate UUID Format":{"main":[[{"node":"Check UUID Valid","type":"main","index":0}]]},"Check UUID Valid":{"main":[[{"node":"Query Specific Message","type":"main","index":0},{"node":"Return Invalid UUID","type":"main","index":0}]]}},"settings":{"saveManualExecutions":true,"saveDataErrorExecution":"all","saveDataSuccessExecution":"all","errorWorkflow":"","executionOrder":"v1"},"staticData":null,"meta":null,"pinData":{},"versionId":"11060d78-19bf-44f4-86ef-4ee63f801b96","triggerCount":1,"shared":[{"createdAt":"2025-10-23T22:18:56.436Z","updatedAt":"2025-10-23T22:18:56.436Z","role":"workflow:owner","workflowId":"QMHZ5IAhBvRgyZAc","projectId":"sVGwG1Ss6aXKNorC","project":{"createdAt":"2025-07-30T12:18:11.485Z","updatedAt":"2025-07-30T12:20:06.951Z","id":"sVGwG1Ss6aXKNorC","name":"Rafał Dębski <rdebski90@gmail.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-07-30T12:18:11.486Z","updatedAt":"2025-07-30T12:18:11.486Z","userId":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","projectId":"sVGwG1Ss6aXKNorC","user":{"createdAt":"2025-07-30T12:18:10.851Z","updatedAt":"2025-10-23T22:43:16.000Z","id":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","email":"rdebski90@gmail.com","firstName":"Rafał","lastName":"Dębski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-07-30T12:20:09.619Z","personalization_survey_n8n_version":"1.104.1"},"settings":{"userActivated":true,"easyAIWorkflowOnboarded":true,"firstSuccessfulWorkflowId":"gp796pP6j8IFZodb","userActivatedAt":1753881412699,"npsSurvey":{"responded":true,"lastShownAt":1755785806897},"dismissedCallouts":{"ragStarterCallout":true}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"fixConnections","nodeId":"check-uuid-valid","connections":{"main":[[{"node":"Query Specific Message","type":"main","index":0}],[{"node":"Return Invalid UUID","type":"main","index":0}]]}}]


workflow_id: QMHZ5IAhBvRgyZAc
workflow_name: POST /chat/generate-pdf
trigger: partial_update
operations: [{"type":"updateNode","nodeId":"Check UUID Valid","updates":{}}]
created_at: 2025-10-24 14:26:35
workflow_snapshot:
  {"createdAt":"2025-10-23T22:18:56.433Z","updatedAt":"2025-10-24T14:26:04.559Z","id":"QMHZ5IAhBvRgyZAc","name":"POST /chat/generate-pdf","active":true,"isArchived":false,"nodes":[{"parameters":{"httpMethod":"POST","path":"chat/generate-pdf","responseMode":"responseNode","options":{}},"id":"webhook-trigger","name":"POST /chat/generate-pdf","type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[240,312],"webhookId":"67403d18-ee13-4ad3-b9b7-02d012aeaf0e","onError":"continueRegularOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"message-id-condition","leftValue":"={{ $('POST /chat/generate-pdf').first().json.body.message_id }}","rightValue":"","operator":{"type":"string","operation":"notEmpty"}}],"combinator":"and"},"options":{}},"id":"check-message-id","name":"Check Message ID","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[912,400],"onError":"continueErrorOutput"},{"parameters":{"url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_messages?select=id,message,created_at,conversation_threads!inner(user_id)&id=eq.' + $('POST /chat/generate-pdf').first().json.body.message_id + '&conversation_threads.user_id=eq.' + $('JWT Validation').first().json.user_id }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"Prefer","value":"return=representation"}]},"options":{"response":{"response":{"responseFormat":"json"}}}},"id":"query-specific-message","name":"Query Specific Message","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1136,320],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/rest/v1/conversation_messages?select=id,message,created_at,conversation_threads!inner(user_id)&conversation_threads.user_id=eq.' + $('JWT Validation').first().json.user_id + '&order=created_at.desc&limit=1' }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"Prefer","value":"return=representation"}]},"options":{"response":{"response":{"responseFormat":"json"}}}},"id":"query-latest-message","name":"Query Latest Message","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1136,512],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"message-exists-condition","leftValue":"={{ $json.id }}","rightValue":"0","operator":{"type":"string","operation":"notEmpty"}}],"combinator":"and"},"options":{}},"id":"check-message-exists","name":"Check Message Exists","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1360,400],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ error: 'Not Found', message: 'Message not found or you do not have access to it' }) }}","options":{"responseCode":404}},"id":"return-not-found","name":"Return Not Found","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1584,320]},{"parameters":{"jsCode":"// Get message data from previous node\nconst messageData = $input.first().json;\n\n// Get user ID from JWT Validation\nconst userId = $('JWT Validation').first().json.user_id;\n\n// Extract content from JSONB structure\nconst content = messageData.message.content;\n\n// Format date in Polish\nconst date = new Date(messageData.created_at);\nconst formattedDate = date.toLocaleDateString('pl-PL', {\n  year: 'numeric',\n  month: 'long',\n  day: 'numeric',\n  hour: '2-digit',\n  minute: '2-digit'\n});\n\n// Create HTML for PDF with WOO branding\nconst html = `<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <style>\n    body {\n      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n      line-height: 1.6;\n      color: #333;\n      padding: 40px;\n      max-width: 800px;\n      margin: 0 auto;\n    }\n    .header {\n      display: flex;\n      justify-content: space-between;\n      align-items: center;\n      margin-bottom: 40px;\n      padding-bottom: 20px;\n      border-bottom: 3px solid #4b0082;\n    }\n    .logo {\n      width: 120px;\n      height: 120px;\n    }\n    .title {\n      color: #4b0082;\n      font-size: 24px;\n      font-weight: 600;\n    }\n    .date {\n      color: #666;\n      font-size: 14px;\n      margin-bottom: 20px;\n    }\n    .content {\n      background: #f9f9f9;\n      padding: 30px;\n      border-radius: 8px;\n      border-left: 4px solid #4b0082;\n    }\n    .footer {\n      margin-top: 40px;\n      padding-top: 20px;\n      border-top: 1px solid #ddd;\n      text-align: center;\n      color: #888;\n      font-size: 12px;\n    }\n  </style>\n</head>\n<body>\n  <div class=\"header\">\n    <div class=\"title\">WOO PRO - Wiadomość</div>\n    <img src=\"https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/public/public_files/logo-email.png\" \n         class=\"logo\" alt=\"WOO Logo\">\n  </div>\n  \n  <div class=\"date\">${formattedDate}</div>\n  \n  <div class=\"content\">\n    ${content.replace(/\\n/g, '<br>')}\n  </div>\n  \n  <div class=\"footer\">\n    Wygenerowano przez WOO PRO<br>\n    Ten dokument jest poufny i przeznaczony wyłącznie dla odbiorcy.\n  </div>\n</body>\n</html>`;\n\nreturn [{\n  json: {\n    html: html,\n    fileName: `${userId}/woo-message-${messageData.id}.pdf`,\n    messageId: messageData.id\n  }\n}];"},"id":"prepare-html-template","name":"Prepare HTML Template","type":"n8n-nodes-base.code","typeVersion":2,"position":[1584,512]},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"pdf-success-condition","leftValue":"={{ $json.error }}","rightValue":"false","operator":{"type":"boolean","operation":"false","singleValue":true}}],"combinator":"and"},"options":{}},"id":"check-pdf-success","name":"Check PDF Success","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[2032,496],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ error: 'PDF Generation Failed', message: $json.message || 'Failed to generate PDF document' }) }}","options":{"responseCode":500}},"id":"return-pdf-error","name":"Return PDF Error","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[2256,416]},{"parameters":{"method":"POST","url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/generated_pdfs/' + $('Prepare HTML Template').first().json.fileName }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Content-Type","value":"application/pdf"}]},"sendBody":true,"contentType":"binaryData","inputDataFieldName":"data","options":{"response":{"response":{"responseFormat":"json"}}}},"id":"upload-pdf-to-storage","name":"Upload PDF to Storage","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2480,608],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"method":"POST","url":"={{ 'https://xxciwnthnnywanbplqwg.supabase.co/storage/v1/object/sign/generated_pdfs/' + $('Prepare HTML Template').first().json.fileName }}","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"={{ $('POST /chat/generate-pdf').first().json.headers.authorization }}"},{"name":"apikey","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4Y2l3bnRobm55d2FuYnBscXdnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAzMzM0NjYsImV4cCI6MjA3NTkwOTQ2Nn0.gVvLw4aHwKG3TFhoQv6MwvoennmFVgmbLTOOpZLBQO8"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ { expiresIn: 86400 } }}","options":{"response":{"response":{"responseFormat":"json"}}}},"id":"generate-signed-url","name":"Generate Signed URL","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2704,608],"alwaysOutputData":true,"onError":"continueRegularOutput"},{"parameters":{"jsCode":"const signedUrl = $input.first().json.signedURL;\nconst fileName = $('Prepare HTML Template').first().json.fileName;\nconst messageId = $('Prepare HTML Template').first().json.messageId;\n\nreturn [{\n  json: {\n    success: true,\n    message: 'PDF generated successfully',\n    data: {\n      pdfUrl: `https://xxciwnthnnywanbplqwg.supabase.co/storage/v1${signedUrl}`,\n      fileName: fileName,\n      messageId: messageId,\n      expiresIn: '24 hours'\n    }\n  }\n}];"},"id":"format-success-response","name":"Format Success Response","type":"n8n-nodes-base.code","typeVersion":2,"position":[2928,608]},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify($json) }}","options":{"responseCode":200}},"id":"return-success","name":"Return Success","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[3152,608]},{"parameters":{"method":"POST","url":"https://api.pdf.co/v1/pdf/convert/from/html","sendHeaders":true,"headerParameters":{"parameters":[{"name":"x-api-key","value":"reeunlockyourskills@gmail.com_SQcbrlvobSplxYtx2Ed8h2toSbsqenyPfWqLkjpvjc5uj68FXk78S3DNibeAw3v0"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ { \"html\": $json.html, \"name\": $json.fileName } }}","options":{"response":{"response":{"responseFormat":"json"}}}},"type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1808,512],"id":"f2e54550-eb45-4363-930d-c2908ca394ac","name":"call_generate_pdf"},{"parameters":{"url":"={{ $json.url }}","options":{"response":{"response":{"responseFormat":"file"}}}},"id":"download-pdf-from-url","name":"Download PDF from URL","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2256,608]},{"parameters":{"workflowId":{"__rl":true,"value":"dL4gKHrO0Mtdhpmo","mode":"list","cachedResultUrl":"/workflow/dL4gKHrO0Mtdhpmo","cachedResultName":"JWT Validation Middleware"},"workflowInputs":{"mappingMode":"defineBelow","value":{"headers":"={{ $json.headers }}","body":"={{ $json.body }}"},"matchingColumns":[],"schema":[{"id":"headers","displayName":"headers","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true,"type":"object"},{"id":"body","displayName":"body","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true},{"id":"params","displayName":"params","required":false,"defaultMatch":false,"display":true,"canBeUsedToMatch":true,"type":"object","removed":true}],"attemptToConvertTypes":false,"convertFieldsToString":true},"options":{}},"id":"97fea410-3161-474d-a49e-2dc7804c98db","name":"JWT Validation","type":"n8n-nodes-base.executeWorkflow","typeVersion":1.3,"position":[464,320],"onError":"continueErrorOutput"},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"jwt_error_check","leftValue":"={{ $json.is_valid }}","rightValue":"={{ true }}","operator":{"type":"boolean","operation":"false","singleValue":true}}],"combinator":"and"},"options":{}},"id":"1705f618-2fa2-4d37-8ec5-5f117e4df232","name":"Check JWT Error","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[688,320],"onError":"continueErrorOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ {\n  success: false,\n  data: null,\n  error: 'Unauthorized',\n  metadata: {\n    timestamp: new Date().toISOString()\n  }\n} }}","options":{"responseCode":401}},"id":"dee5bfdc-9a05-4494-80a9-6f36cbcb8d26","name":"JWT Error Response","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[912,192],"onError":"continueRegularOutput"},{"parameters":{"respondWith":"json","responseBody":"={{ {\n  success: false,\n  error: {\n    code: 'UNAUTHORIZED',\n    message: 'Invalid or expired access token'\n  },\n  metadata: {\n    timestamp: new Date().toISOString()\n  }\n} }}","options":{"responseCode":401}},"id":"d0079bd8-15d8-42a8-8418-191fde6dd0f3","name":"Auth Error Response","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[688,512],"onError":"continueRegularOutput"},{"id":"validate-uuid-format","name":"Validate UUID Format","type":"n8n-nodes-base.code","typeVersion":2,"position":[1024,320],"parameters":{"jsCode":"const messageId = $('POST /chat/generate-pdf').first().json.body.message_id;\n\n// UUID v4 regex pattern\nconst uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\nconst isValid = uuidRegex.test(messageId);\n\nreturn [{\n  json: {\n    messageId: messageId,\n    isValidUUID: isValid\n  }\n}];"}},{"id":"check-uuid-valid","name":"Check UUID Valid","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[1248,320],"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"conditions":[{"id":"uuid-valid-condition","leftValue":"={{ $json.isValidUUID }}","rightValue":"={{ true }}","operator":{"type":"boolean","operation":"true","singleValue":true}}],"combinator":"and"},"options":{}},"onError":"continueErrorOutput"},{"id":"return-invalid-uuid","name":"Return Invalid UUID","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1472,240],"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ success: false, error: 'Invalid message_id format. Expected valid UUID.' }) }}","options":{"responseCode":400}}}],"connections":{"POST /chat/generate-pdf":{"main":[[{"node":"JWT Validation","type":"main","index":0}]]},"Query Specific Message":{"main":[[{"node":"Check Message Exists","type":"main","index":0}]]},"Query Latest Message":{"main":[[{"node":"Check Message Exists","type":"main","index":0}]]},"Upload PDF to Storage":{"main":[[{"node":"Generate Signed URL","type":"main","index":0}]]},"Generate Signed URL":{"main":[[{"node":"Format Success Response","type":"main","index":0}]]},"Format Success Response":{"main":[[{"node":"Return Success","type":"main","index":0}]]},"Check Message ID":{"main":[[{"node":"Validate UUID Format","type":"main","index":0}],[{"node":"Query Latest Message","type":"main","index":0}]]},"Check Message Exists":{"main":[[{"node":"Prepare HTML Template","type":"main","index":0}],[{"node":"Return Not Found","type":"main","index":0}]]},"Check PDF Success":{"main":[[{"node":"Download PDF from URL","type":"main","index":0}],[{"node":"Return PDF Error","type":"main","index":0}]]},"Prepare HTML Template":{"main":[[{"node":"call_generate_pdf","type":"main","index":0}]]},"call_generate_pdf":{"main":[[{"node":"Check PDF Success","type":"main","index":0}]]},"Download PDF from URL":{"main":[[{"node":"Upload PDF to Storage","type":"main","index":0}]]},"JWT Validation":{"main":[[{"node":"Check JWT Error","type":"main","index":0}],[{"node":"Auth Error Response","type":"main","index":0}]]},"Check JWT Error":{"main":[[{"node":"JWT Error Response","type":"main","index":0}],[{"node":"Check Message ID","type":"main","index":0}]]},"Validate UUID Format":{"main":[[{"node":"Check UUID Valid","type":"main","index":0}]]},"Check UUID Valid":{"main":[[{"node":"Query Specific Message","type":"main","index":0},{"node":"Return Invalid UUID","type":"main","index":0}]]}},"settings":{"saveManualExecutions":true,"saveDataErrorExecution":"all","saveDataSuccessExecution":"all","errorWorkflow":"","executionOrder":"v1"},"staticData":null,"meta":null,"pinData":{},"versionId":"c69f6fb1-a84c-4a82-8729-b8508cd5cdb6","triggerCount":1,"shared":[{"createdAt":"2025-10-23T22:18:56.436Z","updatedAt":"2025-10-23T22:18:56.436Z","role":"workflow:owner","workflowId":"QMHZ5IAhBvRgyZAc","projectId":"sVGwG1Ss6aXKNorC","project":{"createdAt":"2025-07-30T12:18:11.485Z","updatedAt":"2025-07-30T12:20:06.951Z","id":"sVGwG1Ss6aXKNorC","name":"Rafał Dębski <rdebski90@gmail.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-07-30T12:18:11.486Z","updatedAt":"2025-07-30T12:18:11.486Z","userId":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","projectId":"sVGwG1Ss6aXKNorC","user":{"createdAt":"2025-07-30T12:18:10.851Z","updatedAt":"2025-10-23T22:43:16.000Z","id":"512c6fc4-ef1e-46ec-99da-b435fcbf2339","email":"rdebski90@gmail.com","firstName":"Rafał","lastName":"Dębski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-07-30T12:20:09.619Z","personalization_survey_n8n_version":"1.104.1"},"settings":{"userActivated":true,"easyAIWorkflowOnboarded":true,"firstSuccessfulWorkflowId":"gp796pP6j8IFZodb","userActivatedAt":1753881412699,"npsSurvey":{"responded":true,"lastShownAt":1755785806897},"dismissedCallouts":{"ragStarterCallout":true}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-23","isPending":false}}]}}],"tags":[]}


workflow_id: tEOQjCcTQqbmZTWi
workflow_name: [MCP-TEST] Partial - Add Node 1761392426462
trigger: partial_update
created_at: 2025-10-25 11:40:26
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:26.702Z","updatedAt":"2025-10-25T11:40:26.702Z","id":"tEOQjCcTQqbmZTWi","name":"[MCP-TEST] Partial - Add Node 1761392426462","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"test-webhook"}}],"connections":{},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"9ce24978-ecc1-4e76-8391-8d986755158f","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:26.704Z","updatedAt":"2025-10-25T11:40:26.704Z","role":"workflow:owner","workflowId":"tEOQjCcTQqbmZTWi","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"name":"Set","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[450,300],"parameters":{"assignments":{"assignments":[{"id":"assign-1","name":"test","value":"value","type":"string"}]}}}},{"type":"addConnection","source":"Webhook","target":"Set"}]


workflow_id: XvSQ8jJgAWNUlkG5
workflow_name: [MCP-TEST] Partial - Duplicate Node Name 1761392426924
trigger: partial_update
created_at: 2025-10-25 11:40:27
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:27.008Z","updatedAt":"2025-10-25T11:40:27.008Z","id":"XvSQ8jJgAWNUlkG5","name":"[MCP-TEST] Partial - Duplicate Node Name 1761392426924","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"test-webhook"}}],"connections":{},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"adcdfe39-6c17-42ae-9ecf-97bbe9be15e8","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:27.011Z","updatedAt":"2025-10-25T11:40:27.011Z","role":"workflow:owner","workflowId":"XvSQ8jJgAWNUlkG5","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"name":"Webhook","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[450,300],"parameters":{}}}]


workflow_id: x5lZh7vvGmhaZdnG
workflow_name: [MCP-TEST] Partial - Remove Node 1761392427078
trigger: partial_update
operations: [{"type":"removeNode","nodeName":"HTTP Request"}]
created_at: 2025-10-25 11:40:27
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:27.163Z","updatedAt":"2025-10-25T11:40:27.163Z","id":"x5lZh7vvGmhaZdnG","name":"[MCP-TEST] Partial - Remove Node 1761392427078","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"trigger"}},{"id":"http-1","name":"HTTP Request","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[450,300],"parameters":{"url":"https://httpbin.org/get","method":"GET"}}],"connections":{"Webhook":{"main":[[{"node":"HTTP Request","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"c58dec3e-af8a-48d6-8c08-e5192a3265bf","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:27.164Z","updatedAt":"2025-10-25T11:40:27.164Z","role":"workflow:owner","workflowId":"x5lZh7vvGmhaZdnG","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}


workflow_id: SJkI1UGHoUz5lvBF
workflow_name: [MCP-TEST] Partial - Remove Non-existent 1761392427276
trigger: partial_update
operations: [{"type":"removeNode","nodeName":"NonExistentNode"}]
created_at: 2025-10-25 11:40:27
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:27.360Z","updatedAt":"2025-10-25T11:40:27.360Z","id":"SJkI1UGHoUz5lvBF","name":"[MCP-TEST] Partial - Remove Non-existent 1761392427276","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"test-webhook"}}],"connections":{},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"a3c05c31-66dd-44ca-94a3-695ae1c0617b","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:27.362Z","updatedAt":"2025-10-25T11:40:27.362Z","role":"workflow:owner","workflowId":"SJkI1UGHoUz5lvBF","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}


workflow_id: GmphNodiVGpfTM1X
workflow_name: [MCP-TEST] Partial - Update Node 1761392427416
trigger: partial_update
operations: [{"type":"updateNode","nodeName":"Webhook","updates":{"parameters.path":"updated-path"}}]
created_at: 2025-10-25 11:40:27
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:27.502Z","updatedAt":"2025-10-25T11:40:27.502Z","id":"GmphNodiVGpfTM1X","name":"[MCP-TEST] Partial - Update Node 1761392427416","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"test-webhook"}}],"connections":{},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"cf1cf1e0-a4e5-4967-84ff-89d05957232e","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:27.504Z","updatedAt":"2025-10-25T11:40:27.504Z","role":"workflow:owner","workflowId":"GmphNodiVGpfTM1X","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}


workflow_id: kDf2PEznXmhoMkSR
workflow_name: [MCP-TEST] Partial - Update Nested 1761392427612
trigger: partial_update
created_at: 2025-10-25 11:40:27
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:27.697Z","updatedAt":"2025-10-25T11:40:27.697Z","id":"kDf2PEznXmhoMkSR","name":"[MCP-TEST] Partial - Update Nested 1761392427612","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"test-webhook"}}],"connections":{},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"d96968dd-128f-4c22-bed7-ddfff904d623","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:27.698Z","updatedAt":"2025-10-25T11:40:27.698Z","role":"workflow:owner","workflowId":"kDf2PEznXmhoMkSR","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"updateNode","nodeName":"Webhook","updates":{"parameters.httpMethod":"POST","parameters.path":"new-path"}}]


workflow_id: xnbbAYbhcCHqXjrG
workflow_name: [MCP-TEST] Partial - Move Node 1761392427804
trigger: partial_update
operations: [{"type":"moveNode","nodeName":"Webhook","position":[500,500]}]
created_at: 2025-10-25 11:40:27
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:27.889Z","updatedAt":"2025-10-25T11:40:27.889Z","id":"xnbbAYbhcCHqXjrG","name":"[MCP-TEST] Partial - Move Node 1761392427804","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"test-webhook"}}],"connections":{},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"2435e344-610f-4e2b-be3d-decb624be28c","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:27.890Z","updatedAt":"2025-10-25T11:40:27.890Z","role":"workflow:owner","workflowId":"xnbbAYbhcCHqXjrG","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}


workflow_id: LNZ4ssqwQke2DhdM
workflow_name: [MCP-TEST] Partial - Disable Node 1761392427992
trigger: partial_update
operations: [{"type":"disableNode","nodeName":"Webhook"}]
created_at: 2025-10-25 11:40:28
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:28.076Z","updatedAt":"2025-10-25T11:40:28.076Z","id":"LNZ4ssqwQke2DhdM","name":"[MCP-TEST] Partial - Disable Node 1761392427992","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"test-webhook"}}],"connections":{},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"8b32200e-454b-48b0-93ad-20e15def9e96","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:28.078Z","updatedAt":"2025-10-25T11:40:28.078Z","role":"workflow:owner","workflowId":"LNZ4ssqwQke2DhdM","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}


workflow_id: SYnX6Chkgpetpjr4
workflow_name: [MCP-TEST] Partial - Enable Node 1761392428185
trigger: partial_update
operations: [{"type":"disableNode","nodeName":"Webhook"}]
created_at: 2025-10-25 11:40:28
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:28.268Z","updatedAt":"2025-10-25T11:40:28.268Z","id":"SYnX6Chkgpetpjr4","name":"[MCP-TEST] Partial - Enable Node 1761392428185","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"test-webhook"}}],"connections":{},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"77bef5cd-c1ec-4e0b-a77f-9b2b995c2d67","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:28.270Z","updatedAt":"2025-10-25T11:40:28.270Z","role":"workflow:owner","workflowId":"SYnX6Chkgpetpjr4","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}


workflow_id: SYnX6Chkgpetpjr4
workflow_name: [MCP-TEST] Partial - Enable Node 1761392428185
trigger: partial_update
operations: [{"type":"enableNode","nodeName":"Webhook"}]
created_at: 2025-10-25 11:40:28
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:28.268Z","updatedAt":"2025-10-25T11:40:28.361Z","id":"SYnX6Chkgpetpjr4","name":"[MCP-TEST] Partial - Enable Node 1761392428185","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"test-webhook"},"disabled":true}],"connections":{},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"9cc9710e-db4c-46ca-858d-1000409d9dfb","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:28.270Z","updatedAt":"2025-10-25T11:40:28.270Z","role":"workflow:owner","workflowId":"SYnX6Chkgpetpjr4","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}


workflow_id: TnqEykkfbVNi39We
workflow_name: [MCP-TEST] Partial - Add Connection 1761392428467
trigger: partial_update
operations: [{"type":"addConnection","source":"Webhook","target":"HTTP Request"}]
created_at: 2025-10-25 11:40:28
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:28.550Z","updatedAt":"2025-10-25T11:40:28.550Z","id":"TnqEykkfbVNi39We","name":"[MCP-TEST] Partial - Add Connection 1761392428467","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"trigger"}},{"id":"http-1","name":"HTTP Request","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[450,300],"parameters":{"url":"https://httpbin.org/get","method":"GET"}}],"connections":{},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"b0b25a06-1e19-4bf1-bad6-8f149a463af6","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:28.551Z","updatedAt":"2025-10-25T11:40:28.551Z","role":"workflow:owner","workflowId":"TnqEykkfbVNi39We","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}


workflow_id: D7Ecq8tdF0eEvo6j
workflow_name: [MCP-TEST] Partial - Add Connection Ports 1761392428654
trigger: partial_update
created_at: 2025-10-25 11:40:28
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:28.737Z","updatedAt":"2025-10-25T11:40:28.737Z","id":"D7Ecq8tdF0eEvo6j","name":"[MCP-TEST] Partial - Add Connection Ports 1761392428654","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"trigger"}},{"id":"http-1","name":"HTTP Request","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[450,300],"parameters":{"url":"https://httpbin.org/get","method":"GET"}}],"connections":{},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"c4aa3dcc-f6c3-425d-bac8-d0a5f2a9a01a","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:28.739Z","updatedAt":"2025-10-25T11:40:28.739Z","role":"workflow:owner","workflowId":"D7Ecq8tdF0eEvo6j","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addConnection","source":"Webhook","target":"HTTP Request","sourceOutput":"main","targetInput":"main","sourceIndex":0,"targetIndex":0}]


workflow_id: XGF5ZTm4rynw9TYs
workflow_name: [MCP-TEST] Partial - Remove Connection 1761392428854
trigger: partial_update
operations: [{"type":"removeConnection","source":"Webhook","target":"HTTP Request"}]
created_at: 2025-10-25 11:40:28
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:28.938Z","updatedAt":"2025-10-25T11:40:28.938Z","id":"XGF5ZTm4rynw9TYs","name":"[MCP-TEST] Partial - Remove Connection 1761392428854","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"trigger"}},{"id":"http-1","name":"HTTP Request","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[450,300],"parameters":{"url":"https://httpbin.org/get","method":"GET"}}],"connections":{"Webhook":{"main":[[{"node":"HTTP Request","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"afc3e4c2-b7e8-476e-8b5d-b3b57d4ad275","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:28.940Z","updatedAt":"2025-10-25T11:40:28.940Z","role":"workflow:owner","workflowId":"XGF5ZTm4rynw9TYs","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}


workflow_id: QQ8YF00uyONFNbdo
workflow_name: [MCP-TEST] Partial - Remove Connection Ignore 1761392429001
trigger: partial_update
operations: [{"type":"removeConnection","source":"Webhook","target":"NonExistent","ignoreErrors":true}]
created_at: 2025-10-25 11:40:29
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:29.087Z","updatedAt":"2025-10-25T11:40:29.087Z","id":"QQ8YF00uyONFNbdo","name":"[MCP-TEST] Partial - Remove Connection Ignore 1761392429001","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"test-webhook"}}],"connections":{},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"29327563-1790-4bdd-ab41-c26875cb99aa","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:29.089Z","updatedAt":"2025-10-25T11:40:29.089Z","role":"workflow:owner","workflowId":"QQ8YF00uyONFNbdo","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}


workflow_id: Sv7Az2aXHdWSxaD4
workflow_name: [MCP-TEST] Partial - Replace Connections 1761392429216
trigger: partial_update
operations: [{"type":"replaceConnections","connections":{}}]
created_at: 2025-10-25 11:40:29
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:29.298Z","updatedAt":"2025-10-25T11:40:29.298Z","id":"Sv7Az2aXHdWSxaD4","name":"[MCP-TEST] Partial - Replace Connections 1761392429216","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"trigger"}},{"id":"http-1","name":"HTTP Request","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[450,300],"parameters":{"url":"https://httpbin.org/get","method":"GET"}}],"connections":{"Webhook":{"main":[[{"node":"HTTP Request","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"7353115c-a3c1-487e-acbd-f91380ce2c11","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:29.300Z","updatedAt":"2025-10-25T11:40:29.300Z","role":"workflow:owner","workflowId":"Sv7Az2aXHdWSxaD4","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}


workflow_id: Q95wmKqMQT69oVR5
workflow_name: [MCP-TEST] Partial - Clean Stale Dry Run 1761392429359
trigger: partial_update
operations: [{"type":"removeNode","nodeName":"HTTP Request"}]
created_at: 2025-10-25 11:40:29
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:29.442Z","updatedAt":"2025-10-25T11:40:29.442Z","id":"Q95wmKqMQT69oVR5","name":"[MCP-TEST] Partial - Clean Stale Dry Run 1761392429359","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"trigger"}},{"id":"http-1","name":"HTTP Request","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[450,300],"parameters":{"url":"https://httpbin.org/get","method":"GET"}}],"connections":{"Webhook":{"main":[[{"node":"HTTP Request","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"f4bb36b6-84fb-4575-a206-7f315ccc59a3","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:29.445Z","updatedAt":"2025-10-25T11:40:29.445Z","role":"workflow:owner","workflowId":"Q95wmKqMQT69oVR5","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}


workflow_id: Qfs3QQkNJB6ndvIy
workflow_name: [MCP-TEST] Partial - Update Settings 1761392429599
trigger: partial_update
operations: [{"type":"updateSettings","settings":{"timezone":"America/New_York","executionOrder":"v1"}}]
created_at: 2025-10-25 11:40:29
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:29.681Z","updatedAt":"2025-10-25T11:40:29.681Z","id":"Qfs3QQkNJB6ndvIy","name":"[MCP-TEST] Partial - Update Settings 1761392429599","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"test-webhook"}}],"connections":{},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"cb5de305-5985-4c2b-8597-932217e4b8ff","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:29.685Z","updatedAt":"2025-10-25T11:40:29.685Z","role":"workflow:owner","workflowId":"Qfs3QQkNJB6ndvIy","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}


workflow_id: XoQcodikQ4QKN8Ij
workflow_name: [MCP-TEST] Partial - Update Name Original 1761392429791
trigger: partial_update
operations: [{"type":"updateName","name":"[MCP-TEST] Partial - Update Name Modified 1761392429838"}]
created_at: 2025-10-25 11:40:29
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:29.875Z","updatedAt":"2025-10-25T11:40:29.875Z","id":"XoQcodikQ4QKN8Ij","name":"[MCP-TEST] Partial - Update Name Original 1761392429791","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"test-webhook"}}],"connections":{},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"2f5218e4-ebde-4516-b7db-2146e1f7ddc0","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:29.877Z","updatedAt":"2025-10-25T11:40:29.877Z","role":"workflow:owner","workflowId":"XoQcodikQ4QKN8Ij","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}


workflow_id: N7Ymj0IxLEvitWxy
workflow_name: [MCP-TEST] Partial - Add Tag 1761392429981
trigger: partial_update
operations: [{"type":"addTag","tag":"new-tag"}]
created_at: 2025-10-25 11:40:30
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:30.066Z","updatedAt":"2025-10-25T11:40:30.066Z","id":"N7Ymj0IxLEvitWxy","name":"[MCP-TEST] Partial - Add Tag 1761392429981","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"test-webhook"}}],"connections":{},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"855e897d-6086-400a-83d4-8feabc2038c9","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:30.068Z","updatedAt":"2025-10-25T11:40:30.068Z","role":"workflow:owner","workflowId":"N7Ymj0IxLEvitWxy","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}


workflow_id: dBovDUwkpPeD5Oki
workflow_name: [MCP-TEST] Partial - Remove Tag 1761392430179
trigger: partial_update
operations: [{"type":"removeTag","tag":"to-remove"}]
created_at: 2025-10-25 11:40:30
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:30.261Z","updatedAt":"2025-10-25T11:40:30.261Z","id":"dBovDUwkpPeD5Oki","name":"[MCP-TEST] Partial - Remove Tag 1761392430179","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"test-webhook"}}],"connections":{},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"caeac7ce-0b55-4104-8ecf-c98e43c80b66","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:30.263Z","updatedAt":"2025-10-25T11:40:30.263Z","role":"workflow:owner","workflowId":"dBovDUwkpPeD5Oki","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}


workflow_id: JTBj0st8DBdowUNQ
workflow_name: [MCP-TEST] Partial - Multiple Ops 1761392430373
trigger: partial_update
created_at: 2025-10-25 11:40:30
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:30.454Z","updatedAt":"2025-10-25T11:40:30.454Z","id":"JTBj0st8DBdowUNQ","name":"[MCP-TEST] Partial - Multiple Ops 1761392430373","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"test-webhook"}}],"connections":{},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"3a195387-e7c6-4ef9-a88d-d95420b1c90b","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:30.456Z","updatedAt":"2025-10-25T11:40:30.456Z","role":"workflow:owner","workflowId":"JTBj0st8DBdowUNQ","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"name":"Set","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[450,300],"parameters":{"assignments":{"assignments":[]}}}},{"type":"addConnection","source":"Webhook","target":"Set"},{"type":"updateName","name":"[MCP-TEST] Partial - Multiple Ops Updated 1761392430420"}]


workflow_id: sOzfdFrmnK5aHDjH
workflow_name: [MCP-TEST] Partial - Continue On Error 1761392430756
trigger: partial_update
created_at: 2025-10-25 11:40:30
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:30.840Z","updatedAt":"2025-10-25T11:40:30.840Z","id":"sOzfdFrmnK5aHDjH","name":"[MCP-TEST] Partial - Continue On Error 1761392430756","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"test-webhook"}}],"connections":{},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"2435fdbb-b536-4da4-9d09-3176ddc6289f","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:30.844Z","updatedAt":"2025-10-25T11:40:30.844Z","role":"workflow:owner","workflowId":"sOzfdFrmnK5aHDjH","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"updateName","name":"[MCP-TEST] Partial - Continue On Error Updated 1761392430808"},{"type":"removeNode","nodeName":"NonExistentNode"},{"type":"addTag","tag":"new-tag"}]


workflow_id: nJJVir7PG57JhTq4
workflow_name: [MCP-TEST] Partial - Reject Empty Connections 1761392430956
trigger: partial_update
operations: [{"type":"removeConnection","source":"Webhook","target":"HTTP Request"}]
created_at: 2025-10-25 11:40:31
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:31.039Z","updatedAt":"2025-10-25T11:40:31.039Z","id":"nJJVir7PG57JhTq4","name":"[MCP-TEST] Partial - Reject Empty Connections 1761392430956","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"trigger"}},{"id":"http-1","name":"HTTP Request","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[450,300],"parameters":{"url":"https://httpbin.org/get","method":"GET"}}],"connections":{"Webhook":{"main":[[{"node":"HTTP Request","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"704bfada-081a-46d2-840b-280ea159bbfe","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:31.041Z","updatedAt":"2025-10-25T11:40:31.041Z","role":"workflow:owner","workflowId":"nJJVir7PG57JhTq4","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}


workflow_id: mO7irUQ1epWhEtof
workflow_name: [MCP-TEST] Partial - Reject Single Non-Webhook 1761392431100
trigger: partial_update
created_at: 2025-10-25 11:40:31
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:31.183Z","updatedAt":"2025-10-25T11:40:31.183Z","id":"mO7irUQ1epWhEtof","name":"[MCP-TEST] Partial - Reject Single Non-Webhook 1761392431100","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"POST","path":"multi-node"}},{"id":"set-1","name":"Set 1","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[450,200],"parameters":{"assignments":{"assignments":[{"id":"assign-1","name":"branch","value":"top","type":"string"}]},"options":{}}},{"id":"set-2","name":"Set 2","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[450,400],"parameters":{"assignments":{"assignments":[{"id":"assign-2","name":"branch","value":"bottom","type":"string"}]},"options":{}}},{"id":"merge-1","name":"Merge","type":"n8n-nodes-base.merge","typeVersion":3,"position":[650,300],"parameters":{"mode":"append","options":{}}}],"connections":{"Webhook":{"main":[[{"node":"Set 1","type":"main","index":0},{"node":"Set 2","type":"main","index":0}]]},"Set 1":{"main":[[{"node":"Merge","type":"main","index":0}]]},"Set 2":{"main":[[{"node":"Merge","type":"main","index":1}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"fe1c50df-70bb-4307-887c-7fdacbf4c239","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:31.185Z","updatedAt":"2025-10-25T11:40:31.185Z","role":"workflow:owner","workflowId":"mO7irUQ1epWhEtof","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"removeNode","nodeName":"Webhook"},{"type":"removeNode","nodeName":"Set 1"},{"type":"removeNode","nodeName":"Set 2"}]


workflow_id: JhiU5Z0esLj0cLrm
workflow_name: [MCP-TEST] Partial - Valid Update 1761392431244
trigger: partial_update
created_at: 2025-10-25 11:40:31
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:31.329Z","updatedAt":"2025-10-25T11:40:31.329Z","id":"JhiU5Z0esLj0cLrm","name":"[MCP-TEST] Partial - Valid Update 1761392431244","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"POST","path":"multi-node"}},{"id":"set-1","name":"Set 1","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[450,200],"parameters":{"assignments":{"assignments":[{"id":"assign-1","name":"branch","value":"top","type":"string"}]},"options":{}}},{"id":"set-2","name":"Set 2","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[450,400],"parameters":{"assignments":{"assignments":[{"id":"assign-2","name":"branch","value":"bottom","type":"string"}]},"options":{}}},{"id":"merge-1","name":"Merge","type":"n8n-nodes-base.merge","typeVersion":3,"position":[650,300],"parameters":{"mode":"append","options":{}}}],"connections":{"Webhook":{"main":[[{"node":"Set 1","type":"main","index":0},{"node":"Set 2","type":"main","index":0}]]},"Set 1":{"main":[[{"node":"Merge","type":"main","index":0}]]},"Set 2":{"main":[[{"node":"Merge","type":"main","index":1}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"90c75695-98af-40c7-b20b-c85e8a1b5792","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:31.331Z","updatedAt":"2025-10-25T11:40:31.331Z","role":"workflow:owner","workflowId":"JhiU5Z0esLj0cLrm","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"name":"Process Data","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[850,300],"parameters":{"assignments":{"assignments":[]}}}},{"type":"addConnection","source":"Merge","target":"Process Data"}]


workflow_id: XgAuOcxc7AfY6bDM
workflow_name: [MCP-TEST] Partial - Reject Disconnected Node 1761392431437
trigger: partial_update
created_at: 2025-10-25 11:40:31
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:31.522Z","updatedAt":"2025-10-25T11:40:31.522Z","id":"XgAuOcxc7AfY6bDM","name":"[MCP-TEST] Partial - Reject Disconnected Node 1761392431437","active":false,"isArchived":false,"nodes":[{"id":"webhook-1","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[250,300],"parameters":{"httpMethod":"GET","path":"trigger"}},{"id":"http-1","name":"HTTP Request","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[450,300],"parameters":{"url":"https://httpbin.org/get","method":"GET"}}],"connections":{"Webhook":{"main":[[{"node":"HTTP Request","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"4446d585-6931-4bf0-9f56-9ebba4ad1dae","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:31.524Z","updatedAt":"2025-10-25T11:40:31.524Z","role":"workflow:owner","workflowId":"XgAuOcxc7AfY6bDM","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"name":"Disconnected Set","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[800,300],"parameters":{"assignments":{"assignments":[]}}}}]


workflow_id: ir1TQ2UNHOGRh6mN
workflow_name: [MCP-TEST] Smart Params - IF True Branch 1761392431732
trigger: partial_update
created_at: 2025-10-25 11:40:31
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:31.816Z","updatedAt":"2025-10-25T11:40:31.816Z","id":"ir1TQ2UNHOGRh6mN","name":"[MCP-TEST] Smart Params - IF True Branch 1761392431732","active":false,"isArchived":false,"nodes":[{"id":"manual-1","name":"Manual","type":"n8n-nodes-base.manualTrigger","typeVersion":1,"position":[250,300],"parameters":{}},{"id":"if-1","name":"IF","type":"n8n-nodes-base.if","typeVersion":2,"position":[450,300],"parameters":{"conditions":{"conditions":[{"id":"cond-1","leftValue":"={{ $json.value }}","rightValue":"test","operation":"equal"}]}}}],"connections":{"Manual":{"main":[[{"node":"IF","type":"main","index":0}]]}},"settings":{"executionOrder":"v1","saveDataErrorExecution":"all","saveDataSuccessExecution":"all","saveManualExecutions":true,"saveExecutionProgress":true},"staticData":null,"meta":null,"pinData":null,"versionId":"517407ba-e6b1-4616-9fca-8728c9f8b923","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:31.817Z","updatedAt":"2025-10-25T11:40:31.817Z","role":"workflow:owner","workflowId":"ir1TQ2UNHOGRh6mN","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"name":"TrueHandler","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[650,200],"parameters":{"assignments":{"assignments":[{"id":"assign-1","name":"handled","value":"true","type":"string"}]}}}},{"type":"addConnection","source":"IF","target":"TrueHandler","branch":"true"}]


workflow_id: bT9KIE6RLoJRNwJV
workflow_name: [MCP-TEST] Smart Params - IF False Branch 1761392432101
trigger: partial_update
created_at: 2025-10-25 11:40:32
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:32.187Z","updatedAt":"2025-10-25T11:40:32.187Z","id":"bT9KIE6RLoJRNwJV","name":"[MCP-TEST] Smart Params - IF False Branch 1761392432101","active":false,"isArchived":false,"nodes":[{"id":"manual-1","name":"Manual","type":"n8n-nodes-base.manualTrigger","typeVersion":1,"position":[250,300],"parameters":{}},{"id":"if-1","name":"IF","type":"n8n-nodes-base.if","typeVersion":2,"position":[450,300],"parameters":{"conditions":{"conditions":[{"id":"cond-1","leftValue":"={{ $json.value }}","rightValue":"test","operation":"equal"}]}}}],"connections":{"Manual":{"main":[[{"node":"IF","type":"main","index":0}]]}},"settings":{"executionOrder":"v1","saveDataErrorExecution":"all","saveDataSuccessExecution":"all","saveManualExecutions":true,"saveExecutionProgress":true},"staticData":null,"meta":null,"pinData":null,"versionId":"84f3768d-e54f-483f-a6f4-e22856a13678","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:32.189Z","updatedAt":"2025-10-25T11:40:32.189Z","role":"workflow:owner","workflowId":"bT9KIE6RLoJRNwJV","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"name":"FalseHandler","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[650,400],"parameters":{"assignments":{"assignments":[{"id":"assign-1","name":"handled","value":"false","type":"string"}]}}}},{"type":"addConnection","source":"IF","target":"FalseHandler","branch":"false"}]


workflow_id: 7adKbYSUn8wtsGRp
workflow_name: [MCP-TEST] Smart Params - IF Both Branches 1761392432351
trigger: partial_update
created_at: 2025-10-25 11:40:32
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:32.436Z","updatedAt":"2025-10-25T11:40:32.436Z","id":"7adKbYSUn8wtsGRp","name":"[MCP-TEST] Smart Params - IF Both Branches 1761392432351","active":false,"isArchived":false,"nodes":[{"id":"manual-1","name":"Manual","type":"n8n-nodes-base.manualTrigger","typeVersion":1,"position":[250,300],"parameters":{}},{"id":"if-1","name":"IF","type":"n8n-nodes-base.if","typeVersion":2,"position":[450,300],"parameters":{"conditions":{"conditions":[{"id":"cond-1","leftValue":"={{ $json.value }}","rightValue":"test","operation":"equal"}]}}}],"connections":{"Manual":{"main":[[{"node":"IF","type":"main","index":0}]]}},"settings":{"executionOrder":"v1","saveDataErrorExecution":"all","saveDataSuccessExecution":"all","saveManualExecutions":true,"saveExecutionProgress":true},"staticData":null,"meta":null,"pinData":null,"versionId":"7ac20b2a-4be8-4611-b4f5-1b2d0fbef52b","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:32.440Z","updatedAt":"2025-10-25T11:40:32.440Z","role":"workflow:owner","workflowId":"7adKbYSUn8wtsGRp","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"name":"TrueHandler","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[650,200],"parameters":{"assignments":{"assignments":[{"id":"assign-1","name":"branch","value":"true","type":"string"}]}}}},{"type":"addNode","node":{"name":"FalseHandler","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[650,400],"parameters":{"assignments":{"assignments":[{"id":"assign-2","name":"branch","value":"false","type":"string"}]}}}},{"type":"addConnection","source":"IF","target":"TrueHandler","branch":"true"},{"type":"addConnection","source":"IF","target":"FalseHandler","branch":"false"}]


workflow_id: FklKu6wMA4G0ythd
workflow_name: [MCP-TEST] Smart Params - Switch Cases 1761392432594
trigger: partial_update
created_at: 2025-10-25 11:40:32
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:32.680Z","updatedAt":"2025-10-25T11:40:32.680Z","id":"FklKu6wMA4G0ythd","name":"[MCP-TEST] Smart Params - Switch Cases 1761392432594","active":false,"isArchived":false,"nodes":[{"id":"manual-1","name":"Manual","type":"n8n-nodes-base.manualTrigger","typeVersion":1,"position":[250,300],"parameters":{}},{"id":"switch-1","name":"Switch","type":"n8n-nodes-base.switch","typeVersion":3,"position":[450,300],"parameters":{"mode":"rules","rules":{"rules":[{"id":"rule-1","conditions":{"conditions":[{"id":"cond-1","leftValue":"={{ $json.case }}","rightValue":"a","operation":"equal"}]},"output":0},{"id":"rule-2","conditions":{"conditions":[{"id":"cond-2","leftValue":"={{ $json.case }}","rightValue":"b","operation":"equal"}]},"output":1},{"id":"rule-3","conditions":{"conditions":[{"id":"cond-3","leftValue":"={{ $json.case }}","rightValue":"c","operation":"equal"}]},"output":2}]}}}],"connections":{"Manual":{"main":[[{"node":"Switch","type":"main","index":0}]]}},"settings":{"executionOrder":"v1","saveDataErrorExecution":"all","saveDataSuccessExecution":"all","saveManualExecutions":true,"saveExecutionProgress":true},"staticData":null,"meta":null,"pinData":null,"versionId":"a7ea07de-d845-43eb-9d81-aaeff4d973df","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:32.688Z","updatedAt":"2025-10-25T11:40:32.688Z","role":"workflow:owner","workflowId":"FklKu6wMA4G0ythd","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}

operations:
  [{"type":"addNode","node":{"name":"Handler0","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[650,100],"parameters":{"assignments":{"assignments":[{"id":"assign-1","name":"case","value":"0","type":"string"}]}}}},{"type":"addNode","node":{"name":"Handler1","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[650,300],"parameters":{"assignments":{"assignments":[{"id":"assign-2","name":"case","value":"1","type":"string"}]}}}},{"type":"addNode","node":{"name":"Handler2","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[650,500],"parameters":{"assignments":{"assignments":[{"id":"assign-3","name":"case","value":"2","type":"string"}]}}}},{"type":"addConnection","source":"Switch","target":"Handler0","case":0},{"type":"addConnection","source":"Switch","target":"Handler1","case":1},{"type":"addConnection","source":"Switch","target":"Handler2","case":2}]


workflow_id: A9C8X0jnteLaUHRI
workflow_name: [MCP-TEST] Smart Params - Rewire IF True 1761392432854
trigger: partial_update
operations: [{"type":"rewireConnection","source":"IF","from":"Handler1","to":"Handler2","branch":"true"}]
created_at: 2025-10-25 11:40:32
workflow_snapshot:
  {"createdAt":"2025-10-25T11:40:32.938Z","updatedAt":"2025-10-25T11:40:32.938Z","id":"A9C8X0jnteLaUHRI","name":"[MCP-TEST] Smart Params - Rewire IF True 1761392432854","active":false,"isArchived":false,"nodes":[{"id":"manual-1","name":"Manual","type":"n8n-nodes-base.manualTrigger","typeVersion":1,"position":[250,300],"parameters":{}},{"id":"if-1","name":"IF","type":"n8n-nodes-base.if","typeVersion":2,"position":[450,300],"parameters":{"conditions":{"conditions":[{"id":"cond-1","leftValue":"={{ $json.value }}","rightValue":"test","operation":"equal"}]}}},{"id":"handler1","name":"Handler1","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[650,200],"parameters":{"assignments":{"assignments":[{"id":"assign-1","name":"handler","value":"1","type":"string"}]}}},{"id":"handler2","name":"Handler2","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[650,400],"parameters":{"assignments":{"assignments":[{"id":"assign-2","name":"handler","value":"2","type":"string"}]}}}],"connections":{"Manual":{"main":[[{"node":"IF","type":"main","index":0}]]},"IF":{"main":[[{"node":"Handler1","type":"main","index":0}],[]]}},"settings":{"executionOrder":"v1","saveDataErrorExecution":"all","saveDataSuccessExecution":"all","saveManualExecutions":true,"saveExecutionProgress":true},"staticData":null,"meta":null,"pinData":null,"versionId":"ed4587fb-a909-4d78-9b4c-30d601241505","triggerCount":0,"shared":[{"createdAt":"2025-10-25T11:40:32.940Z","updatedAt":"2025-10-25T11:40:32.940Z","role":"workflow:owner","workflowId":"A9C8X0jnteLaUHRI","projectId":"K0HtvGddtPI24Iyt","project":{"createdAt":"2025-10-03T09:48:05.062Z","updatedAt":"2025-10-03T09:49:33.347Z","id":"K0HtvGddtPI24Iyt","name":"Romuald Członkowski <romuald@n8n-mcp.com>","type":"personal","icon":null,"description":null,"projectRelations":[{"createdAt":"2025-10-03T09:48:05.063Z","updatedAt":"2025-10-03T09:48:05.063Z","userId":"ebb1bcfe-d103-4506-a994-9b18ef25e289","projectId":"K0HtvGddtPI24Iyt","user":{"createdAt":"2025-10-03T09:48:04.462Z","updatedAt":"2025-10-25T01:33:33.000Z","id":"ebb1bcfe-d103-4506-a994-9b18ef25e289","email":"romuald@n8n-mcp.com","firstName":"Romuald","lastName":"Członkowski","personalizationAnswers":{"version":"v4","personalization_survey_submitted_at":"2025-10-03T09:49:36.595Z","personalization_survey_n8n_version":"1.113.3"},"settings":{"userActivated":true,"firstSuccessfulWorkflowId":"DWyvSVPDFSSo9jwN","userActivatedAt":1759494619257,"easyAIWorkflowOnboarded":true,"npsSurvey":{"waitingForResponse":true,"ignoredCount":0,"lastShownAt":1760865506670}},"disabled":false,"mfaEnabled":false,"lastActiveAt":"2025-10-24","isPending":false}}]}}],"tags":[]}


