{
  "name": "Procore RFI AI Analysis Notification",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "companyId": 36736,
        "projectId": 38830
      },
      "type": "CUSTOM.procoreTrigger",
      "typeVersion": 1,
      "position": [
        180,
        370
      ],
      "id": "0310689a-8253-4a19-ade4-3781117d531b",
      "name": "RFI Created Trigger",
      "credentials": {
        "procoreOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "event": "rfiReplyCreated",
        "companyId": 36736,
        "projectId": 38830
      },
      "type": "CUSTOM.procoreTrigger",
      "typeVersion": 1,
      "position": [
        180,
        570
      ],
      "id": "3d727916-c78f-454e-b781-5583a5a90794",
      "name": "RFI Reply Trigger",
      "credentials": {
        "procoreOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Determine the trigger type and prepare data\nconst triggerType = $input.first().json.event || 'rfiCreated';\nconst rfiData = $input.first().json;\n\n// Add metadata for processing\nconst enrichedData = {\n  ...rfiData,\n  triggerType,\n  timestamp: new Date().toISOString(),\n  processingId: Math.random().toString(36).substr(2, 9)\n};\n\nreturn [{\n  json: enrichedData\n}];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        400,
        470
      ],
      "id": "1d0b3c33-d735-477d-8996-375c4adbd706",
      "name": "Enrich RFI Data"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "trigger-type-check",
              "leftValue": "={{ $json.triggerType }}",
              "rightValue": "rfiCreated",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        620,
        470
      ],
      "id": "f17764fa-48af-4212-9808-613ae49ceeca",
      "name": "Route by Trigger Type"
    },
    {
      "parameters": {
        "resource": "rfis",
        "operation": "show",
        "companyId": "={{ $json.company_id }}",
        "projectId": "={{ $json.project_id }}",
        "rfiId": "={{ $json.id }}"
      },
      "type": "CUSTOM.procore",
      "typeVersion": 1,
      "position": [
        840,
        170
      ],
      "id": "0f9dd659-72e1-4c85-bf87-b66e711c8eab",
      "name": "Get Full RFI Details",
      "credentials": {
        "procoreOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "Analyze this RFI and provide:\n\n1. **Priority Assessment**: Rate urgency (1-5, 5 being highest)\n2. **Category Classification**: What type of RFI is this? (Design, Construction, Coordination, etc.)\n3. **Impact Analysis**: Potential schedule/cost impact\n4. **Recommended Actions**: Next steps for the team\n5. **Response Template**: Professional response draft\n\nRFI Details:\n- Number: {{ $json.number }}\n- Question: {{ $json.question }}\n- Due Date: {{ $json.due_date }}\n- Status: {{ $json.status }}\n- Priority: {{ $json.priority }}\n- Assigned To: {{ $json.assigned_to?.name }}\n\nProvide a structured analysis in JSON format.",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.9,
      "position": [
        1060,
        170
      ],
      "id": "4216ae04-9e6b-457b-8101-fc583b6dd884",
      "name": "AI RFI Analyzer"
    },
    {
      "parameters": {
        "jsCode": "// Parse AI analysis and prepare notification data\nconst aiAnalysis = $input.first().json;\nconst rfiData = $input.first().json.rfiData || $input.first().json;\n\n// Extract key information\nconst notificationData = {\n  rfiNumber: rfiData.number,\n  question: rfiData.question,\n  dueDate: rfiData.due_date,\n  priority: rfiData.priority,\n  status: rfiData.status,\n  assignedTo: rfiData.assigned_to?.name || 'Unassigned',\n  aiAnalysis: aiAnalysis,\n  projectId: rfiData.project_id,\n  companyId: rfiData.company_id,\n  rfiId: rfiData.id\n};\n\nreturn [{\n  json: notificationData\n}];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1436,
        170
      ],
      "id": "a452e7a8-ddaa-4bab-8fda-281fc12b628d",
      "name": "Prepare Notification Data"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "priority-check",
              "leftValue": "={{ $json.aiAnalysis.priority || $json.priority }}",
              "rightValue": 4,
              "operator": {
                "type": "number",
                "operation": "gte"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1734,
        170
      ],
      "id": "616104a4-c9f1-41f2-95f7-01c7523f70e8",
      "name": "High Priority Check"
    },
    {
      "parameters": {
        "operation": "sendAndWait",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "responseType": "freeText",
        "options": {}
      },
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        2032,
        20
      ],
      "id": "caec86a1-67f8-4f0f-bec0-2a6a3838c1fb",
      "name": "Slack High Priority Alert"
    },
    {
      "parameters": {
        "operation": "sendAndWait",
        "options": {}
      },
      "type": "n8n-nodes-base.microsoftOutlook",
      "typeVersion": 2,
      "position": [
        2032,
        220
      ],
      "id": "9b63366d-a005-477e-ad8e-9d736814bc26",
      "name": "Email High Priority Alert"
    },
    {
      "parameters": {
        "operation": "sendAndWait",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "responseType": "freeText",
        "options": {}
      },
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        2032,
        420
      ],
      "id": "cd9a4862-c485-4816-a692-bffd415414c5",
      "name": "Slack Standard Notification"
    },
    {
      "parameters": {
        "resource": "replies",
        "operation": "create",
        "companyId": "={{ $json.companyId }}",
        "projectId": "={{ $json.projectId }}",
        "rfiId": "={{ $json.rfiId }}",
        "reply": {
          "body": "={{ $json.aiAnalysis.responseTemplate }}"
        }
      },
      "type": "CUSTOM.procore",
      "typeVersion": 1,
      "position": [
        2252,
        220
      ],
      "id": "b0c9135b-d7b4-488a-a504-6e8b2c93d326",
      "name": "Create Draft Reply",
      "credentials": {
        "procoreOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Handle RFI reply processing\nconst replyData = $input.first().json;\nconst rfiData = replyData.rfi || replyData;\n\n// Extract reply information\nconst replyInfo = {\n  rfiNumber: rfiData.number,\n  replyBody: replyData.body,\n  replyAuthor: replyData.created_by?.name,\n  replyDate: replyData.created_at,\n  projectId: rfiData.project_id,\n  companyId: rfiData.company_id,\n  rfiId: rfiData.id\n};\n\nreturn [{\n  json: replyInfo\n}];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1436,
        670
      ],
      "id": "c518e001-b5cb-41a0-8686-342bc7f22cfc",
      "name": "Process Reply Data"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "Review this RFI reply and provide:\n\n1. **Quality Assessment**: Rate the reply quality (1-5)\n2. **Completeness Check**: Does it address all aspects of the question?\n3. **Professional Tone**: Is the response appropriate?\n4. **Suggestions**: Any improvements needed?\n5. **Approval Recommendation**: Should this be approved or need revision?\n\nRFI Reply:\n- RFI Number: {{ $json.rfiNumber }}\n- Reply: {{ $json.replyBody }}\n- Author: {{ $json.replyAuthor }}\n- Date: {{ $json.replyDate }}\n\nProvide analysis in JSON format.",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.9,
      "position": [
        1656,
        670
      ],
      "id": "33502509-072d-4d5f-a6a6-c4de54700f70",
      "name": "AI Reply Analyzer"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "approval-check",
              "leftValue": "={{ $json.aiAnalysis.approvalRecommendation }}",
              "rightValue": "approve",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        2032,
        670
      ],
      "id": "6c30d509-ff2a-4dc9-9189-770f433556ff",
      "name": "Approval Check"
    },
    {
      "parameters": {
        "operation": "sendAndWait",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "responseType": "freeText",
        "options": {}
      },
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        2252,
        570
      ],
      "id": "75488907-990b-44f0-ad93-0087f20f199b",
      "name": "Slack Approval Request"
    },
    {
      "parameters": {
        "operation": "sendAndWait",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "responseType": "freeText",
        "options": {}
      },
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        2252,
        770
      ],
      "id": "c68d1643-fbe2-47c7-b714-f4ee6dca5944",
      "name": "Slack Revision Request"
    },
    {
      "parameters": {
        "jsCode": "// Log RFI processing activity\nconst activityData = {\n  timestamp: new Date().toISOString(),\n  event: 'rfi_processed',\n  rfiNumber: $input.first().json.rfiNumber,\n  triggerType: $input.first().json.triggerType,\n  processingStatus: 'completed',\n  aiAnalysis: $input.first().json.aiAnalysis\n};\n\n// You could send this to a logging service or database\nconsole.log('RFI Activity Log:', JSON.stringify(activityData, null, 2));\n\nreturn $input.all();"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2472,
        570
      ],
      "id": "a9ccdd2a-829b-4a27-85bd-c34f12fac515",
      "name": "Activity Logger"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        1208,
        390
      ],
      "id": "97fe4f7e-e551-4991-b692-6be92ab5af9d",
      "name": "Memory Buffer"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        1088,
        390
      ],
      "id": "03c1e664-e682-4618-b2f0-2c1dd348bbd7",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "height": 800,
        "width": 1320
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        60,
        20
      ],
      "typeVersion": 1,
      "id": "1e3b666b-1392-49a0-ab17-ae5ff6ccd6f6",
      "name": "Enhanced RFI Management Workflow"
    }
  ],
  "connections": {
    "RFI Created Trigger": {
      "main": [
        [
          {
            "node": "Enrich RFI Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RFI Reply Trigger": {
      "main": [
        [
          {
            "node": "Enrich RFI Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enrich RFI Data": {
      "main": [
        [
          {
            "node": "Route by Trigger Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Trigger Type": {
      "main": [
        [
          {
            "node": "Get Full RFI Details",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Process Reply Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Full RFI Details": {
      "main": [
        [
          {
            "node": "AI RFI Analyzer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI RFI Analyzer": {
      "main": [
        [
          {
            "node": "Prepare Notification Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Notification Data": {
      "main": [
        [
          {
            "node": "High Priority Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "High Priority Check": {
      "main": [
        [
          {
            "node": "Slack High Priority Alert",
            "type": "main",
            "index": 0
          },
          {
            "node": "Email High Priority Alert",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Slack Standard Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Slack High Priority Alert": {
      "main": [
        [
          {
            "node": "Create Draft Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email High Priority Alert": {
      "main": [
        [
          {
            "node": "Create Draft Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Slack Standard Notification": {
      "main": [
        [
          {
            "node": "Create Draft Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Draft Reply": {
      "main": [
        [
          {
            "node": "Activity Logger",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Reply Data": {
      "main": [
        [
          {
            "node": "AI Reply Analyzer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Reply Analyzer": {
      "main": [
        [
          {
            "node": "Approval Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Approval Check": {
      "main": [
        [
          {
            "node": "Slack Approval Request",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Slack Revision Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Slack Approval Request": {
      "main": [
        [
          {
            "node": "Activity Logger",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Slack Revision Request": {
      "main": [
        [
          {
            "node": "Activity Logger",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Memory Buffer": {
      "ai_memory": [
        [
          {
            "node": "AI RFI Analyzer",
            "type": "ai_memory",
            "index": 0
          },
          {
            "node": "AI Reply Analyzer",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI RFI Analyzer",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "AI Reply Analyzer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "2981f3ec-b40d-4fc4-afde-f4b412f40650",
  "id": "nzwUcIp5hAq0gOIP",
  "tags": [
    {
      "name": "Enhanced RFI Management",
      "id": "1zsFW8yocsb2XpOU",
      "createdAt": "2025-06-25T23:55:47.737Z",
      "updatedAt": "2025-06-25T23:55:47.737Z"
    }
  ]
}