{
  "id": "dlSaktSpjNmnRa19",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Auto-Assign Jira Issues from Google Sheets with Azure OpenAI (GPT-4o-mini) \ud83d\ude80",
  "tags": [],
  "nodes": [
    {
      "id": "e4492d7d-a417-481b-9a22-edb34409ad44",
      "name": "Google Sheets Trigger",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "position": [
        0,
        96
      ],
      "parameters": {
        "event": "rowAdded",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1aXin2bvkoNYIARJZeYjWDl8wTVVbSYc1A0kud2Mo21Y/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1aXin2bvkoNYIARJZeYjWDl8wTVVbSYc1A0kud2Mo21Y",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1aXin2bvkoNYIARJZeYjWDl8wTVVbSYc1A0kud2Mo21Y/edit?usp=drivesdk",
          "cachedResultName": "new tasks for the week"
        }
      },
      "credentials": {
        "googleSheetsTriggerOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ae918733-f905-4d5b-a43f-80efeb574edc",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        280,
        96
      ],
      "parameters": {
        "text": "=Task Name: {{ $json['Task Name'] }}\nRelated Area: {{ $json.Area }}",
        "options": {
          "batching": {
            "delayBetweenBatches": 500
          },
          "systemMessage": "=You are an AI Assignment Agent. Your job is to read a task\u2019s name and its related area, consult the Google Sheets tool to find the best-fit employee based on expertise, and return a structured result with exactly five items.\n\nInputs:\n- Task Name: a short title describing the task.\n- Related Area: the domain/category the task falls into (e.g., backend, frontend, DevOps, security, QA, data).\n\nAvailable Tool:\n- Google Sheets: The sheet contains employee roster rows with at least these columns:\n  - Name\n  - Expertise (one or more skills, areas, or domains; may be comma-separated)\n  - ID (unique employee identifier)\n\nGoal:\n- Select the single best-fit employee for the task based on matching Related Area to employee Expertise.\n\nOperating Rules:\n1. Extract Task Name and Related Area from the user message. Normalize to lowercase and trim whitespace.\n2. Use the Google Sheets tool to read all rows from the configured employee roster sheet.\n3. Parse each row\u2019s Expertise into a set of normalized keywords (split by commas, slashes, or semicolons; trim; lowercase).\n4. Scoring:\n   - Exact match: Related Area equals any expertise keyword \u2192 3 points.\n   - Close match: Related Area appears as a substring in an expertise keyword or vice versa \u2192 2 points.\n   - Semantic/alias match: common synonyms (e.g., \u201cbackend\u201d ~ \u201cserver-side\u201d, \u201cfrontend\u201d ~ \u201cUI\u201d, \u201cdevops\u201d ~ \u201cSRE\u201d, \u201cdata\u201d ~ \u201canalytics\u201d, \u201csecurity\u201d ~ \u201cinfosec\u201d, \u201cQA\u201d ~ \u201ctesting\u201d) \u2192 2 points.\n   - Broader category match (e.g., \u201cweb\u201d with \u201cfrontend\u201d/\u201cbackend\u201d) \u2192 1 point.\n5. Choose the employee with the highest score. Tie-break in order:\n   - More specific expertise (shorter keyword length).\n   - More exact matches (count).\n   - Stable ordering by ID ascending.\n6. Do not invent employees or expertise. Only select from the rows returned by Google Sheets.\n7. If no employee scores \u22651 point, return null values for the person fields.\n8. Determine item type (\u201cbug\u201d or \u201ctask\u201d):\n   - If the Related Area or Task Name includes bug-like keywords (e.g., \u201cbug\u201d, \u201cfix\u201d, \u201cissue\u201d, \u201cerror\u201d, \u201cdefect\u201d, \u201cfailure\u201d, \u201cbroken\u201d, \u201ctimeout\u201d), set item_type = \"bug\".\n   - Otherwise, set item_type = \"task\"."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "retryOnFail": true,
      "typeVersion": 2.2
    },
    {
      "id": "00ab5a23-4a96-4224-9e1c-979f302d2d49",
      "name": "Azure OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
      "position": [
        224,
        320
      ],
      "parameters": {
        "model": "gpt-4o-mini",
        "options": {}
      },
      "credentials": {
        "azureOpenAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "076f832a-b000-419a-8379-aa91667754e0",
      "name": "Get row(s) in sheet in Google Sheets",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        352,
        320
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Qtw6wd_bT51-wPrDIgZdwqWb5JxkkdE0d4Fh14HP8sE/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1Qtw6wd_bT51-wPrDIgZdwqWb5JxkkdE0d4Fh14HP8sE",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Qtw6wd_bT51-wPrDIgZdwqWb5JxkkdE0d4Fh14HP8sE/edit?usp=drivesdk",
          "cachedResultName": "JIRA Tracking Account IDs"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "05ce4d67-3e8a-4b59-9732-ebd4ce415205",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        480,
        320
      ],
      "parameters": {
        "jsonSchemaExample": "{\n\t\"task_name\": \"Fix login API timeout\",\n  \"assignee_name\": \"Priya Sharma\",\n  \"expertise\": \"backend, API performance\",\n  \"employee_id\": \"712020:67676669-f944-4347-a465-81096c2a85ca\",\n  \"item_type\": \"bug\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "815bcddd-898a-448e-ad65-1d1ab5bd0c96",
      "name": "Create an issue",
      "type": "n8n-nodes-base.jira",
      "position": [
        912,
        0
      ],
      "parameters": {
        "project": {
          "__rl": true,
          "mode": "list",
          "value": "10000",
          "cachedResultName": "My Scrum Project"
        },
        "summary": "={{ $json.output.task_name }}",
        "issueType": {
          "__rl": true,
          "mode": "list",
          "value": "10005",
          "cachedResultName": "Bug"
        },
        "additionalFields": {
          "assignee": {
            "__rl": true,
            "mode": "id",
            "value": "={{ $json.output.employee_id }}"
          }
        }
      },
      "credentials": {
        "jiraSoftwareCloudApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7465acca-43da-48fd-9d64-3ec187d84513",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        688,
        96
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "34be92a7-20bd-4741-a84e-b7f4da5101cf",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.item_type }}",
                    "rightValue": "bug"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "116c85b0-ec2b-45e1-8752-b9554f382a32",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.item_type }}",
                    "rightValue": "task"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.3
    },
    {
      "id": "64c2aa34-f415-4383-b3fa-460e1cf48372",
      "name": "Create an issue1",
      "type": "n8n-nodes-base.jira",
      "position": [
        912,
        192
      ],
      "parameters": {
        "project": {
          "__rl": true,
          "mode": "list",
          "value": "10000",
          "cachedResultName": "My Scrum Project"
        },
        "summary": "={{ $json.output.task_name }}",
        "issueType": {
          "__rl": true,
          "mode": "list",
          "value": "10004",
          "cachedResultName": "Task"
        },
        "additionalFields": {
          "assignee": {
            "__rl": true,
            "mode": "id",
            "value": "={{ $json.output.employee_id }}"
          }
        }
      },
      "credentials": {
        "jiraSoftwareCloudApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "89fbfd63-c1c4-49e5-900e-80229844e7b9",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -336,
        64
      ],
      "parameters": {
        "height": 192,
        "content": "## Google Sheets Trigger\u00a0 \nWatches a sheet for newly added rows and passes the Task Name and Related Area into the workflow for processing."
      },
      "typeVersion": 1
    },
    {
      "id": "ed1ad258-9580-4f3a-897a-54b57c43530d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        -160
      ],
      "parameters": {
        "height": 224,
        "content": "## AI Agent (Azure OpenAI Chat Model)\u00a0 \nEvaluates the task and area, compares against employee expertise from Sheets, and outputs the structured assignment fields."
      },
      "typeVersion": 1
    },
    {
      "id": "f40e5efe-53f5-4ad7-9ecb-8b613b2ea150",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        624,
        272
      ],
      "parameters": {
        "height": 144,
        "content": "## Switch (Rules)\u00a0 \nRoutes workflow logic based on item_type to apply different handling or fields for a bug versus a task."
      },
      "typeVersion": 1
    },
    {
      "id": "98101c77-67d7-485b-9aef-1e566bffd9d6",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        -224
      ],
      "parameters": {
        "height": 192,
        "content": "## Create an issue (Jira)\u00a0 \nCreates the Jira issue with the chosen assignee and metadata from the parsed output, completing the intake-to-ticket flow."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "7248046c-82d9-4feb-91f8-170732718007",
  "connections": {
    "Switch": {
      "main": [
        [
          {
            "node": "Create an issue",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create an issue1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets Trigger": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Azure OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet in Google Sheets": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}