{
  "id": "ZtkkWwiBICaiGc4g",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Code Comment-to-FAQ Sync (GitHub)",
  "tags": [],
  "nodes": [
    {
      "id": "5b60a73e-3918-4730-b195-ac429b2f5acf",
      "name": "Configure GPT-4o Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
      "position": [
        144,
        144
      ],
      "parameters": {
        "model": "gpt-4o",
        "options": {}
      },
      "credentials": {
        "azureOpenAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2b63fa67-e389-43a5-ab07-0a54a890dd57",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -944,
        -400
      ],
      "parameters": {
        "height": 448,
        "content": "## Node Name: GitHub PR Comment Trigger\n**Action**: Starts the workflow when a pull-request comment event occurs in GitHub.\n**Description**:\nThis node listens for the `pull_request_review_comment` webhook from a specified repository (`weather-app`) and user.  \nWhenever a developer comments on a PR, this node captures the event payload \u2014 including comment text, file path, PR number, and author \u2014 to start the automation chain.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "49031929-9cdb-4a5e-97e4-cfbcaa93fd1f",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -496,
        144
      ],
      "parameters": {
        "height": 368,
        "content": "## Node Name: Validate GitHub Webhook Payload\n**Action**: Checks if the incoming PR comment data is valid and complete.\n**Description**:\nBefore processing, this node verifies that the GitHub payload includes a valid comment URL.  \nIf the webhook is malformed or missing fields, the workflow routes execution to the error-logging path to prevent failed AI or Notion operations.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "7df85bda-9810-4dc0-97c6-4280bffcf513",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        448
      ],
      "parameters": {
        "height": 384,
        "content": "## Node Name: Log Errors in Google Sheets\n**Action**: Records any webhook or processing errors in a shared Google Sheet.\n**Description**:\nIf validation fails or data parsing encounters issues, this node logs the error details (error ID + message) in the \u201cerror log sheet.\u201d  \nThis ensures complete visibility into failed webhook events and AI generation errors for future troubleshooting.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "9eae3668-e27a-46ec-925b-e187ebb38d39",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        -528
      ],
      "parameters": {
        "height": 432,
        "content": "## Node Name: Generate AI Response for Developer Question\n**Action**: Uses GPT-4o to draft a clear, concise reply to the developer\u2019s PR comment.\n**Description**:\nThis agent node sends the extracted GitHub comment text and PR context to GPT-4o.  \nThe AI analyzes the query and returns a brief (2\u20133 line) technical answer that can later be stored or displayed for review.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "7298a7db-60d9-4891-99d4-17ab86e2eb26",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        -512
      ],
      "parameters": {
        "height": 416,
        "content": "## Node Name: Extract GitHub Comment Metadata\n**Action**: Parses and structures key GitHub comment details into a clean JSON object.\n**Description**:\nUsing a JavaScript Code node, this step extracts repository name, comment content, author username, file path, and PR number from the original webhook payload.  \nIt standardizes the data so it can be easily stored in Notion.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "b149f1f2-65a2-4a0b-8736-e556a6caf632",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        704,
        160
      ],
      "parameters": {
        "height": 432,
        "content": "## Node Name: Save Comment Insight to Notion Database\n**Action**: Appends the processed comment data and AI response into a Notion database.\n**Description**:\nThis node creates a new page entry in a Notion database (\u201ctest db\u201d) capturing details like repository, username, comment body, file path, and PR number.  \nIt serves as a living documentation hub for tracking developer queries and AI answers from GitHub PRs.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "5d286fc7-9919-4102-8afc-c6f12933c510",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        224,
        272
      ],
      "parameters": {
        "height": 352,
        "content": "## Node Name: Configure GPT-4o Model\n**Action**: Establishes the Azure OpenAI GPT-4o model connection for AI processing.\n**Description**:\nThis node defines and connects to the GPT-4o model hosted on Azure OpenAI.  \nIt serves as the language engine for generating short, precise, and context-aware technical responses to developer comments.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "f035aa9a-2f76-4de6-a451-84a00dbb690e",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -176,
        -464
      ],
      "parameters": {
        "height": 400,
        "content": "## Node Name: Detect Developer Question in PR Comment\n**Action**: Evaluates whether a PR comment contains a question like \u201chow do I\u2026\u201d or \u201chow to\u2026\u201d.\n**Description**:\nThis conditional node scans the text of the GitHub comment for help-related keywords.  \nIf the comment is a technical query, it routes the flow to the AI assistant for generating a concise answer. Otherwise, the workflow ends silently.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "c6e89357-de32-4be6-bbe0-f486751ead92",
      "name": " GitHub PR Comment Trigger",
      "type": "n8n-nodes-base.githubTrigger",
      "position": [
        -672,
        -32
      ],
      "parameters": {
        "owner": {
          "__rl": true,
          "mode": "name",
          "value": "saurabhg97"
        },
        "events": [
          "pull_request_review_comment"
        ],
        "options": {},
        "repository": {
          "__rl": true,
          "mode": "name",
          "value": "weather-app"
        },
        "authentication": "oAuth2"
      },
      "credentials": {
        "githubOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c4f82baa-ca82-4858-8d2f-2e9dd7febe3c",
      "name": "Validate GitHub Webhook Payload",
      "type": "n8n-nodes-base.if",
      "position": [
        -400,
        -32
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e2adb005-2b3c-4d1e-8445-442df1fe925a",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.body.comment.url }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "a739f228-5357-4ab7-bee6-62b7929d08df",
      "name": "Detect Developer Question in PR Comment",
      "type": "n8n-nodes-base.if",
      "position": [
        -112,
        -48
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "2ad8bc15-beaa-4606-9a8d-ecfd38e446cb",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ \n  (\n    $json[\"body\"][\"comment\"][\"body\"].toLowerCase().includes(\"how do i\") ||\n    $json[\"body\"][\"comment\"][\"body\"].toLowerCase().includes(\"how to\")\n  ).toString()\n}}\n",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "5b0d7c5e-cc2d-44fd-9cf2-b6edfc5e08bc",
      "name": "Generate AI Response for Developer Question",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        192,
        -64
      ],
      "parameters": {
        "text": "={{ \n`Question: ${$json[\"body\"][\"comment\"][\"body\"]}\n\nContext: PR Link - ${$json[\"body\"][\"comment\"][\"html_url\"]}\nRepository: ${$json[\"body\"][\"repository\"][\"full_name\"]}\n` \n}}\n",
        "options": {
          "systemMessage": "=You are a helpful developer assistant. \nProvide short, clear, and technically correct answers (2\u20133 lines max) to developer questions found in GitHub PR comments.\n"
        },
        "promptType": "define"
      },
      "typeVersion": 2.1
    },
    {
      "id": "433930c9-f10d-4db5-b419-9ed8a1adb5d0",
      "name": "Extract GitHub Comment Metadata",
      "type": "n8n-nodes-base.code",
      "position": [
        544,
        -64
      ],
      "parameters": {
        "jsCode": "// Access the original webhook data\nconst webhookData = $(' GitHub PR Comment Trigger').first().json;\n\nreturn [\n  {\n    json: {\n      repository: webhookData.body.repository.full_name,\n      comment: webhookData.body.comment.body,\n      username: webhookData.body.comment.user.login,\n      file_path: webhookData.body.comment.path,\n      pr_number: webhookData.body.pull_request.number\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "3c1ef780-1b15-4932-9aa9-99cb89f4195b",
      "name": "Save Comment Insight to Notion Database",
      "type": "n8n-nodes-base.notion",
      "position": [
        784,
        -64
      ],
      "parameters": {
        "title": "={{ $json.repository }}",
        "simple": false,
        "options": {},
        "resource": "databasePage",
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "value": "265802b9-1fa0-806f-a52a-e6d71d9ff2e0",
          "cachedResultUrl": "https://www.notion.so/265802b91fa0806fa52ae6d71d9ff2e0",
          "cachedResultName": "test db"
        },
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Name|title",
              "title": "={{ $json.comment }}"
            },
            {
              "key": "Name|title",
              "title": "={{ $json.username }}"
            },
            {
              "key": "Name|title",
              "title": "={{ $now }}"
            },
            {
              "key": "Name|title",
              "title": "={{ $json.file_path }}"
            },
            {
              "key": "Name|title",
              "title": "={{ String($json.pr_number) }}\n"
            }
          ]
        }
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "828abb32-ab14-4a13-aaf8-2d0723df639d",
      "name": "Log Errors in Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -128,
        256
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "error_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "error_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "error",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "error",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "error_id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1338537721,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Uldk_4BxWbdZTDZxFUeohIfeBmGHHqVEl9Ogb0l6R8Y/edit#gid=1338537721",
          "cachedResultName": "error log sheet"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1Uldk_4BxWbdZTDZxFUeohIfeBmGHHqVEl9Ogb0l6R8Y",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Uldk_4BxWbdZTDZxFUeohIfeBmGHHqVEl9Ogb0l6R8Y/edit?usp=drivesdk",
          "cachedResultName": "Interviewer Brief Pack "
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "5f0bdf64-2400-416f-a2b0-5b8a19bba710",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1024,
        160
      ],
      "parameters": {
        "height": 576,
        "content": "## Node Name: Post AI Answer & PR Link to Slack\n**Action**: Sends the generated AI response and the GitHub PR comment link to a Slack channel or user.\n**Description**:\nThis node posts the AI-generated technical answer (from \u201cGenerate AI Response for Developer Question\u201d) directly to Slack, followed by the original GitHub PR comment link for quick context.  \nIt ensures that the internal team (or reviewer) is instantly notified whenever a developer\u2019s query is processed by the AI system \u2014 allowing faster review and collaboration inside Slack.  \nTypically used to streamline developer feedback loops and keep AI-assisted responses visible to the engineering team in real time.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "945e97e6-b51a-4771-931b-02ab81ef902b",
      "name": " Post AI Answer & PR Link to Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        1056,
        -64
      ],
      "parameters": {
        "text": "={{ $('Generate AI Response for Developer Question').item.json.output }}{{ $('Detect Developer Question in PR Comment').item.json.body.comment.url }}",
        "user": {
          "__rl": true,
          "mode": "list",
          "value": "U09HMPVD466",
          "cachedResultName": "newscctv22"
        },
        "select": "user",
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "9f9ae9c5-9555-4e6d-94e6-2891348064ae",
  "connections": {
    "Configure GPT-4o Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate AI Response for Developer Question",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    " GitHub PR Comment Trigger": {
      "main": [
        [
          {
            "node": "Validate GitHub Webhook Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract GitHub Comment Metadata": {
      "main": [
        [
          {
            "node": "Save Comment Insight to Notion Database",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate GitHub Webhook Payload": {
      "main": [
        [
          {
            "node": "Detect Developer Question in PR Comment",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log Errors in Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Detect Developer Question in PR Comment": {
      "main": [
        [
          {
            "node": "Generate AI Response for Developer Question",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Comment Insight to Notion Database": {
      "main": [
        [
          {
            "node": " Post AI Answer & PR Link to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate AI Response for Developer Question": {
      "main": [
        [
          {
            "node": "Extract GitHub Comment Metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}