{
  "id": "VcXdoym34pE6BhRP",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Paperclip Task Assigner & Completion Tracker",
  "tags": [],
  "nodes": [
    {
      "id": "9783e313-6810-4ee9-8b3e-52be07bc7f88",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -640,
        -128
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c3b857d7-6153-4f54-9548-7efe0aca6fc9",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -416,
        80
      ],
      "parameters": {
        "path": "939dff15-712c-489a-885f-7912bedf5607",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "6e194de5-fe02-495f-af82-3069b9dfa258",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        544,
        432
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "45261d6b-2fe4-4042-b364-60f80f08992a",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "completed"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "57ba647d-8c6a-4ff7-ae29-5a7b02484176",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -656,
        496
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 10
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "86c3c47c-dda0-40ad-b33c-2c2077acd630",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        96,
        496
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "69cb876e-224f-4ce2-8044-3b5f25067a3c",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        448,
        48
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5-mini",
          "cachedResultName": "gpt-5-mini"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "de8e6692-5079-41ac-9a77-851974165b5b",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        640,
        48
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "={\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"id\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"name\": {\n\t\t\t\"type\": \"string\"\n\t\t}\n\t}\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "e9b3217e-e670-42eb-aea6-81fdcb611548",
      "name": "Task Assignment",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        480,
        -128
      ],
      "parameters": {
        "text": "=Task title: {{ $('Webhook').item.json.title }}\nTask description: {{ $('Webhook').item.json.issue }}\n\n\nAgents: {{JSON.stringify($json.result)}}",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "Return only an array with a single agent, assigning it the most appropriate task for a Paperclip agent."
            }
          ]
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.9
    },
    {
      "id": "b2046c69-7aa7-4a6f-b097-4985e27b8f3d",
      "name": "Set data",
      "type": "n8n-nodes-base.set",
      "position": [
        -416,
        -128
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "12c07b77-410e-4ac3-8ff2-79d493b4a1ec",
              "name": "title",
              "type": "string",
              "value": "xxx"
            },
            {
              "id": "0d169873-fb91-49ae-96ab-a91f02866cbb",
              "name": "issue",
              "type": "string",
              "value": "xxx"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "7343dc0f-c425-41e5-b8fa-615ea641ae46",
      "name": "Get Company ID",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -192,
        -32
      ],
      "parameters": {
        "url": "https://paperclip.xxx.xxx/api/agents/me",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth"
      },
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "8ee55a8c-bded-48cf-be66-f62f149784bd",
      "name": "Get Paperclip Agents",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        32,
        -32
      ],
      "parameters": {
        "url": "=https://paperclip.xxx.xxx/api/companies/{{ $json.companyId }}/agents",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth"
      },
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "dfc9c7dc-bb38-4610-8ec3-a036b2e443d1",
      "name": "Normalize",
      "type": "n8n-nodes-base.code",
      "position": [
        256,
        -32
      ],
      "parameters": {
        "jsCode": "const data = items.map(item => item.json);\n\nconst result = data.map(el => ({\n  id: el.id,\n  name: el.name,\n  title: el.title\n}));\n\nreturn [\n  {\n    json: {\n      result: result\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "fb971aad-13d0-4629-b8c6-05d0ccf5c62b",
      "name": "Create issue",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        832,
        -32
      ],
      "parameters": {
        "url": "=https://paperclip.xxx.xxx/api/companies/{{ $('Get Company ID').item.json.companyId }}/issues",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"title\": \"Scrivi contenuto: {{ $('Webhook').item.json.title }}\",\n  \"description\": \"{{ $('Webhook').item.json.issue }}\",\n  \"status\": \"todo\",\n  \"assigneeAgentId\": \"{{ $json.output.id }}\"\n}\n",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth"
      },
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "2040b9a4-5c61-4853-8b40-00c14469cd41",
      "name": "Add issue to Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1056,
        -32
      ],
      "parameters": {
        "columns": {
          "value": {
            "ID": "={{ $json.id }}",
            "DATE": "={{$now.format('dd/LL/yyyy HH:ii')}}",
            "ISSUE": "={{ $('Webhook').item.json.issue }}",
            "TITLE": "={{ $('Webhook').item.json.title }}",
            "ASSIGN": "={{ $('Task Assignment').item.json.output.name }}"
          },
          "schema": [
            {
              "id": "DATE",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "DATE",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "TITLE",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "TITLE",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ISSUE",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ISSUE",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ASSIGN",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ASSIGN",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "COMPLETED",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "COMPLETED",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1MDJ-SAMiRWdfSpXMXOzH2qiipym-8qhX31ymPMdcz8k/edit#gid=0",
          "cachedResultName": "Foglio1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1MDJ-SAMiRWdfSpXMXOzH2qiipym-8qhX31ymPMdcz8k",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1MDJ-SAMiRWdfSpXMXOzH2qiipym-8qhX31ymPMdcz8k/edit?usp=drivesdk",
          "cachedResultName": "Paperclip issuess Schedule"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "5198b92e-2cc7-47a7-951a-5388599725f1",
      "name": "Get open issues",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -304,
        496
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "COMPLETED"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1MDJ-SAMiRWdfSpXMXOzH2qiipym-8qhX31ymPMdcz8k/edit#gid=0",
          "cachedResultName": "Foglio1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1MDJ-SAMiRWdfSpXMXOzH2qiipym-8qhX31ymPMdcz8k",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1MDJ-SAMiRWdfSpXMXOzH2qiipym-8qhX31ymPMdcz8k/edit?usp=drivesdk",
          "cachedResultName": "Paperclip issuess Schedule"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "fb41b639-e85d-4139-b82b-eee2b37aae89",
      "name": "Get issue",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        320,
        352
      ],
      "parameters": {
        "url": "=https://paperclip.xxx.xxx/api/issues/{{ $json.ID }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth"
      },
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "dfa34d89-341c-4f72-9158-d0f19b55ab8d",
      "name": "Send alert",
      "type": "n8n-nodes-base.gmail",
      "position": [
        848,
        432
      ],
      "parameters": {
        "sendTo": "xxx@xxx.xxx",
        "message": "=Hi,\nThis issue is completed\n\nTitle: {{ $json.title }}\nDescription: {{ $json.description }}",
        "options": {},
        "subject": "=[Paperclip] {{ $json.title }} COMPLETED"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "7ca899ca-72df-4c14-a519-25e439d68a45",
      "name": "Update issue to Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1088,
        496
      ],
      "parameters": {
        "columns": {
          "value": {
            "COMPLETED": "={{$now.format('dd/LL/yyyy HH:ii')}}",
            "row_number": "={{ $('Loop Over Items').item.json.row_number }}"
          },
          "schema": [
            {
              "id": "DATE",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "DATE",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "TITLE",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "TITLE",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ISSUE",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ISSUE",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ASSIGN",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ASSIGN",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "COMPLETED",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "COMPLETED",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1MDJ-SAMiRWdfSpXMXOzH2qiipym-8qhX31ymPMdcz8k/edit#gid=0",
          "cachedResultName": "Foglio1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1MDJ-SAMiRWdfSpXMXOzH2qiipym-8qhX31ymPMdcz8k",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1MDJ-SAMiRWdfSpXMXOzH2qiipym-8qhX31ymPMdcz8k/edit?usp=drivesdk",
          "cachedResultName": "Paperclip issuess Schedule"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "4e00ed6c-70a8-4466-a243-ae8fa201aa36",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        -688
      ],
      "parameters": {
        "width": 1152,
        "height": 400,
        "content": "## AI-Powered Paperclip Task Assigner & Completion Tracker \n\n### How it works\n\nThis workflow manages the full lifecycle of Paperclip issues through two connected automations. The first flow is triggered manually or by webhook, receives a task payload with `title` and `issue`, retrieves the company and available Paperclip agents, normalizes agent data, and uses GPT-5-mini to choose the best agent for the task before creating the issue in Paperclip. It then records the issue details in Google Sheets for centralized tracking.\n\nThe second flow runs on a schedule every 10 minutes to monitor open issues stored in the sheet. For each unresolved record, it checks the current status in the Paperclip API, and when an issue is marked completed, it sends a Gmail notification and writes the completion timestamp back to Google Sheets.\n\n### Setup steps\n\nConfigure all required credentials in n8n first: `httpBearerAuth` for the Paperclip API, `openAiApi` for assignment logic, `gmailOAuth2` for alerts, and `googleSheetsOAuth2Api` for sheet access. Then [clone the provided Google Sheet](https://docs.google.com/spreadsheets/d/1MDJ-SAMiRWdfSpXMXOzH2qiipym-8qhX31ymPMdcz8k/edit?usp=sharing)\n\nNext, replace all placeholder Paperclip base URLs with your real instance URL and confirm the required API endpoints are reachable. Review workflow-specific settings such as the auto-generated webhook path, target Gmail recipient, and schedule interval, then activate the workflow and test it with either the Manual Trigger or a webhook POST request containing `title` and `issue`.\n\n\nView this [Youtube Video Tutorial](https://www.youtube.com/watch?v=vdnyiF92qcY) to setup Paperclip instance and get API Key (subtitles in English)"
      },
      "typeVersion": 1
    },
    {
      "id": "0db41d74-8acb-4ea9-90c4-9e04272556cb",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        -272
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 512,
        "content": "## STEP 1 - Receives an issue\n\nReceives a task with title and issue via webhook or Set Data for testing"
      },
      "typeVersion": 1
    },
    {
      "id": "65dc1fc5-4899-4dbb-9c6f-954d137ed291",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -16,
        -272
      ],
      "parameters": {
        "color": 7,
        "width": 1280,
        "height": 512,
        "content": "## STEP 2 - Create an issue on Paperclip\n\nRetrieves all available Paperclip agents for that company, Creates a new issue in Paperclip with the assigned agent, Logs the issue to a Google Sheet with metadata (date, ID, title, issue, assigned agent)\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "0a370693-1920-429c-ab9d-9d193eba73e1",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -16,
        256
      ],
      "parameters": {
        "color": 7,
        "width": 1296,
        "height": 512,
        "content": "## STEP 4 - Checks the current status\n\nChecks the current status of each issue in Paperclip API. If status is \"completed\", sends a Gmail alert and updates the COMPLETED column in Sheets \n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "4a014ff4-4553-44b0-8d7b-3cda6a8d1ecc",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        256
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 512,
        "content": "## STEP 3 - Fetches all open issues\n\nFetches all open issues (where COMPLETED column is empty) from Google Sheets\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "051cfeb0-3e07-4ed0-a4fb-66ff6324d38c",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        -1024
      ],
      "parameters": {
        "color": 7,
        "width": 736,
        "height": 736,
        "content": "## MY NEW YOUTUBE CHANNEL\n\ud83d\udc49 [Subscribe to my new **YouTube channel**](https://youtube.com/@n3witalia). Here I\u2019ll share videos and Shorts with practical tutorials and **FREE templates for n8n**.\n\n[![image](https://n3wstorage.b-cdn.net/n3witalia/youtube-n8n-cover.jpg)](https://youtube.com/@n3witalia)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "ee1e1c5c-027b-4707-9b05-71ff218e2ac9",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Send alert",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Get Company ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set data": {
      "main": [
        [
          {
            "node": "Get Company ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get issue": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize": {
      "main": [
        [
          {
            "node": "Task Assignment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send alert": {
      "main": [
        [
          {
            "node": "Update issue to Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create issue": {
      "main": [
        [
          {
            "node": "Add issue to Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Company ID": {
      "main": [
        [
          {
            "node": "Get Paperclip Agents",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get open issues": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Get issue",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Task Assignment": {
      "main": [
        [
          {
            "node": "Create issue",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get open issues",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Task Assignment",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Add issue to Sheet": {
      "main": [
        []
      ]
    },
    "Get Paperclip Agents": {
      "main": [
        [
          {
            "node": "Normalize",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update issue to Sheet": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Task Assignment",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Set data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}