{
  "id": "0UZ2TKWlMje5ITdH",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "AI-Powered Proposal Gap Analyzer",
  "tags": [],
  "nodes": [
    {
      "id": "8800319a-b8e4-4946-a6b9-7db1f6a43788",
      "name": "Groq Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGroq",
      "position": [
        2112,
        576
      ],
      "parameters": {
        "model": "openai/gpt-oss-20b",
        "options": {}
      },
      "credentials": {
        "groqApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "658652e5-9eee-4d67-bd7b-e2568a7a5ba4",
      "name": "Format Analysis Output",
      "type": "n8n-nodes-base.set",
      "position": [
        2576,
        352
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "17c3cdce-afed-4863-b7b5-9097ac161c85",
              "name": "clientName",
              "type": "string",
              "value": "={{ $('Extract Client Info').item.json.clientName }}"
            },
            {
              "id": "c8077acf-fdbc-45e5-9d7f-f0f7ef9d20b3",
              "name": "analysisSummary",
              "type": "string",
              "value": "={{ $json.output }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "45abf90c-b987-4944-a656-a60223adac49",
      "name": "New Proposal Upload Trigger",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        912,
        272
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1_s-Nn0K0tORr8zHieiKP2gVAqR0rqJtc",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1_s-Nn0K0tORr8zHieiKP2gVAqR0rqJtc",
          "cachedResultName": "Proposals"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9842819f-14a3-44c5-91da-428f05ad7008",
      "name": "Download Proposal",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1216,
        176
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "d0776d44-4ab3-42b8-ae0d-9c56bf87c388",
      "name": "Read Proposal Text",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        1456,
        176
      ],
      "parameters": {
        "options": {},
        "operation": "text"
      },
      "typeVersion": 1.1
    },
    {
      "id": "3951d242-ad97-4c46-bc90-aedfe45a32cb",
      "name": "Extract Client Info",
      "type": "n8n-nodes-base.code",
      "position": [
        1696,
        176
      ],
      "parameters": {
        "jsCode": "// Get the full text from previous node\nconst content = $json[\"data\"];  // your node output field\n\n// Use regex to get client name\nconst match = content.match(/Client:\\s*(.*)/);\n\n// Return JSON with clientName and full proposal\nreturn [\n  {\n    json: {\n      clientName: match ? match[1] : \"Unknown Client\",\n      currentProposal: content\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "acbff8a3-00a2-4412-984d-61ab80ba0e50",
      "name": "Get Winning Proposal Data (Knowledge Base)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1328,
        480
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "Won",
              "lookupColumn": "status"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1HplmBBrZpyk2KxHVAqHKi6zNmCUcTB6yVekc5fb9gvQ/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1HplmBBrZpyk2KxHVAqHKi6zNmCUcTB6yVekc5fb9gvQ",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1HplmBBrZpyk2KxHVAqHKi6zNmCUcTB6yVekc5fb9gvQ/edit?usp=drivesdk",
          "cachedResultName": "Winning_Proposals_DB"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "098138ad-2a41-424d-aebd-acee948be0f1",
      "name": "Combine Proposal Data",
      "type": "n8n-nodes-base.merge",
      "position": [
        1936,
        352
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.2
    },
    {
      "id": "874fe6f8-6eb2-4c0f-97b7-613030b01f95",
      "name": "AI Proposal Gap Analyzer",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2144,
        352
      ],
      "parameters": {
        "text": "=You are a proposal analysis expert.\n\nCompare the current proposal with the past winning proposal and identify gaps using historical intelligence.\n\nClient:\n{{$json[\"clientName\"]}}\n\nCurrent Proposal:\n{{$json[\"currentProposal\"]}}\n\nPast Winning Proposal:\n{{$json[\"proposalText\"]}}\n\nOutput Rules:\n- Provide 8\u201310 bullet points\n- Each point must be short (1 line)\n- Start each line with plain labels like:\n  Missing:\n  Positioning:\n  Pricing:\n  Technical:\n  Support:\n  Suggestion:\n- Do NOT use markdown formatting (no **, no bold)\n- Use simple and clear business language\n- Do NOT mention past client names\n- Focus on business impact and improvements\n- Make output suitable for Salesforce CRM and Slack",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "a938ec03-59be-4d2d-9e9d-5a6fe1f76b0c",
      "name": "Save Insights to Salesforce",
      "type": "n8n-nodes-base.salesforce",
      "position": [
        2768,
        496
      ],
      "parameters": {
        "name": "={{$json[\"clientName\"]}}",
        "resource": "opportunity",
        "closeDate": "={{ new Date().toISOString().split('T')[0] }}",
        "stageName": "Prospecting",
        "additionalFields": {
          "description": "={{ $json[\"analysisSummary\"] }}"
        }
      },
      "credentials": {
        "salesforceOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9dc3c054-18f9-49ee-ae3f-71d534e3df16",
      "name": "Prepare Final Output",
      "type": "n8n-nodes-base.merge",
      "position": [
        2976,
        352
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.2
    },
    {
      "id": "c7731eac-8491-45f8-b2b9-d694e7f7f33f",
      "name": "Send Notification to Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        3376,
        352
      ],
      "parameters": {
        "text": "=New Proposal Analysis Completed  \nClient: {{$json[\"clientName\"]}}  \nInsights: {{$json[\"analysisSummary\"]}}  \nStored in Salesforce successfully.",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C0ARNK4FBV1",
          "cachedResultName": "proposal-gap-analyzer"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.4
    },
    {
      "id": "702211c3-cd91-48e2-84cc-058c01da11d0",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        336,
        -64
      ],
      "parameters": {
        "width": 432,
        "height": 944,
        "content": "\n# AI-Powered Proposal Gap Analyzer\n\n# How it works:\nThis workflow automatically analyzes business proposals by comparing them with past winning proposals. When a new proposal is uploaded to Google Drive, the system extracts the content and identifies the client. It then fetches a successful proposal from a knowledge base and combines both datasets. An AI model analyzes the differences to detect missing elements, weak positioning, pricing gaps and improvement opportunities. The insights are formatted and stored in Salesforce for tracking. Finally, the results are sent to Slack, enabling teams to quickly review and improve proposal quality using data-driven intelligence.\n\n# Setup Steps:\n\n## Proposal Upload Trigger\nUse Google Drive Trigger to detect new proposal files uploaded in the selected folder.\n\n## Document Processing\nDownload and extract text from the proposal file and identify client details.\n\n## Knowledge Base Integration\nFetch winning proposals from Google Sheets to use as reference data.\n\n## AI Analysis\nUse AI node to compare proposals and generate actionable insights.\n\n## Data Storage\nStore the analysis results in Salesforce for business tracking.\n\n## Output & Notification\nFormat the results and send them to Slack for team visibility."
      },
      "typeVersion": 1
    },
    {
      "id": "9a8b86c0-1f15-4cb3-b635-96710bbceee0",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        848,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 768,
        "height": 688,
        "content": "\n## Proposal Data Preparation and Analysis\n\nDownload the uploaded proposal file and extract its readable content. Identify the client details and structure the proposal data. Then retrieve past winning proposals from the knowledge base and prepare both datasets for comparison and AI-driven analysis."
      },
      "typeVersion": 1
    },
    {
      "id": "e681028e-dcaf-4dc6-933a-4ff0f50f91a2",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1648,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 816,
        "height": 704,
        "content": "## Client Extraction, Data Combination and AI Analysis\n\nExtract client details from the proposal and structure the data for processing. Combine the current proposal with past winning proposals to create a unified dataset. Then use AI to analyze the data, identify missing elements, weak positioning, pricing gaps and generate actionable insights to improve proposal effectiveness."
      },
      "typeVersion": 1
    },
    {
      "id": "68501fff-b17b-44a1-8362-650d22759b2a",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2512,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 1044,
        "height": 704,
        "content": "\n## Output Formatting, Storage and Notification\n\nFormat the AI-generated insights into a clean and structured output. Save the analysis in Salesforce for tracking and business use. Combine all final data and send a notification to Slack to inform the team about the completed proposal analysis."
      },
      "typeVersion": 1
    },
    {
      "id": "daa66293-a2c0-4cc6-a52a-78a9ca4e880a",
      "name": "Wait for Save",
      "type": "n8n-nodes-base.wait",
      "position": [
        3184,
        352
      ],
      "parameters": {
        "amount": 2
      },
      "typeVersion": 1.1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "7434c3b8-319c-405a-9f68-df33ccee57f4",
  "connections": {
    "Wait for Save": {
      "main": [
        [
          {
            "node": "Send Notification to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Groq Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Proposal Gap Analyzer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Download Proposal": {
      "main": [
        [
          {
            "node": "Read Proposal Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Proposal Text": {
      "main": [
        [
          {
            "node": "Extract Client Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Client Info": {
      "main": [
        [
          {
            "node": "Combine Proposal Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Final Output": {
      "main": [
        [
          {
            "node": "Wait for Save",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine Proposal Data": {
      "main": [
        [
          {
            "node": "AI Proposal Gap Analyzer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Analysis Output": {
      "main": [
        [
          {
            "node": "Prepare Final Output",
            "type": "main",
            "index": 0
          },
          {
            "node": "Save Insights to Salesforce",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Proposal Gap Analyzer": {
      "main": [
        [
          {
            "node": "Format Analysis Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New Proposal Upload Trigger": {
      "main": [
        [
          {
            "node": "Download Proposal",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Winning Proposal Data (Knowledge Base)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Insights to Salesforce": {
      "main": [
        [
          {
            "node": "Prepare Final Output",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Get Winning Proposal Data (Knowledge Base)": {
      "main": [
        [
          {
            "node": "Combine Proposal Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    }
  }
}