This workflow corresponds to n8n.io template #16718 — we link there as the canonical source.
This workflow follows the Agent → Groq Chat recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"id": "WFNuWGv0un3viRZD",
"meta": {
"templateCredsSetupCompleted": true
},
"name": "Deal Complexity Classification Engine",
"tags": [],
"nodes": [
{
"id": "29456623-f6e1-4f16-90d8-aed4f4a3c94f",
"name": "Trigger - New Opportunity",
"type": "n8n-nodes-base.salesforceTrigger",
"position": [
-688,
96
],
"parameters": {
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
},
"triggerOn": "opportunityCreated"
},
"credentials": {
"salesforceOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "09582548-cb8a-4f8c-a240-4ce89b4b1f3b",
"name": "Fetch Opportunity Details",
"type": "n8n-nodes-base.salesforce",
"position": [
-448,
96
],
"parameters": {
"query": "SELECT Id, Name, Amount, OwnerId, Customization__c, AccountId, Processed__c \nFROM Opportunity \nWHERE OwnerId = '005gL00000HJCmrQAH' \nLIMIT 1",
"resource": "search"
},
"credentials": {
"salesforceOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "f221f2b1-a0f4-45d4-9280-70d73b6940d6",
"name": "Check If Not Processed",
"type": "n8n-nodes-base.if",
"position": [
-240,
96
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 3,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "b4fa15db-5618-4a83-b720-b36f30bb3ea6",
"operator": {
"type": "boolean",
"operation": "equals"
},
"leftValue": "={{ $json.Processed__c }}",
"rightValue": false
}
]
}
},
"typeVersion": 2.3
},
{
"id": "04713c6a-f6cf-4dec-83fa-1e2bf22db0e3",
"name": "Prepare Opportunity Data",
"type": "n8n-nodes-base.code",
"position": [
80,
80
],
"parameters": {
"jsCode": "return items;"
},
"typeVersion": 2
},
{
"id": "6be85e37-11dd-4f12-9013-c00cbd666e45",
"name": "Fetch Related Contacts",
"type": "n8n-nodes-base.salesforce",
"position": [
320,
240
],
"parameters": {
"limit": 10,
"options": {
"conditionsUi": {
"conditionValues": [
{
"field": "AccountId",
"value": "={{$json[\"AccountId\"]}}",
"operation": "=equal"
}
]
}
},
"resource": "contact",
"operation": "getAll"
},
"credentials": {
"salesforceOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "1aa2d904-fbc5-4c85-aa7d-2d609d696303",
"name": "Fetch Opportunity Products",
"type": "n8n-nodes-base.salesforce",
"position": [
320,
-32
],
"parameters": {
"query": "=SELECT Id, Quantity, UnitPrice, OpportunityId FROM OpportunityLineItem WHERE OpportunityId = '{{$json[\"Id\"]}}'",
"resource": "search"
},
"credentials": {
"salesforceOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "5755783b-babc-4581-9496-95e511295b16",
"name": "Combine Contacts & Products",
"type": "n8n-nodes-base.merge",
"position": [
528,
96
],
"parameters": {},
"typeVersion": 3.2
},
{
"id": "3e2965b8-2b93-4f10-be38-445e0661169f",
"name": "Calculate Deal Metrics",
"type": "n8n-nodes-base.code",
"position": [
768,
96
],
"parameters": {
"jsCode": "// Separate data\nconst contacts = items.filter(i => i.json.Id && !i.json.UnitPrice);\nconst products = items.filter(i => i.json.UnitPrice !== undefined);\n\n// Calculations\nconst contactsCount = contacts.length;\nconst productsCount = products.length;\n\nconst totalProductValue = products.reduce((sum, p) => {\n return sum + (p.json.UnitPrice || 0);\n}, 0);\n\n// Return only calculated values\nreturn [{\n json: {\n contacts: contactsCount,\n products: productsCount,\n totalProductValue\n }\n}];"
},
"typeVersion": 2
},
{
"id": "0dfba128-1354-46ea-994e-7371257d23cc",
"name": "Classify Deal Complexity (AI)",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
976,
96
],
"parameters": {
"text": "=You are a sales operations expert.\n\nClassify deal complexity based on:\n- Deal amount\n- Number of stakeholders\n- Number of products\n- Total product value\n- Customization level\n\nGuidelines:\n- High: Large deal OR many stakeholders OR many products OR high total product value OR high customization\n- Medium: Moderate deal size, moderate stakeholders/products/value, or medium customization\n- Low: Small deal with few stakeholders/products/value and low customization\n\nInput:\nDeal Name: {{ $('Fetch Opportunity Details').item.json.Name }}\nAmount: {{ $('Fetch Opportunity Details').item.json.Amount }}\nStakeholders: {{$json[\"contacts\"]}}\nProducts: {{$json[\"products\"]}}\nTotal Product Value: {{$json[\"totalProductValue\"]}}\nCustomization:{{ $('Fetch Opportunity Details').item.json.Customization__c }}\n\nReturn STRICT JSON:\n{\n \"complexity\": \"Low/Medium/High\",\n \"reason\": \"short explanation\",\n \"actions\": [\"action1\", \"action2\"]\n}",
"options": {},
"promptType": "define"
},
"typeVersion": 3.1
},
{
"id": "564dde57-9ac1-4657-a815-3f6cc850cc15",
"name": "AI Model (Groq)",
"type": "@n8n/n8n-nodes-langchain.lmChatGroq",
"position": [
976,
288
],
"parameters": {
"model": "openai/gpt-oss-20b",
"options": {}
},
"credentials": {
"groqApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "cbdef8ab-5157-4e92-818d-2ff684982a41",
"name": "Parse AI Response",
"type": "n8n-nodes-base.code",
"position": [
1312,
96
],
"parameters": {
"jsCode": "const response = $json.output || $json.text || \"\";\n\n// Extract JSON safely\nlet parsed;\n\ntry {\n parsed = JSON.parse(response);\n} catch (e) {\n // fallback if AI adds extra text\n const match = response.match(/\\{[\\s\\S]*\\}/);\n parsed = match ? JSON.parse(match[0]) : {};\n}\n\nreturn [{\n json: {\n complexity: parsed.complexity || \"Medium\",\n reason: parsed.reason || \"No clear reason provided\",\n actions: parsed.actions || [\"Review deal manually\"]\n }\n}];"
},
"typeVersion": 2
},
{
"id": "83c3a236-62d2-4a3f-9a8e-be3a8b2e6ef0",
"name": "Mark Opportunity as Processed",
"type": "n8n-nodes-base.salesforce",
"position": [
1824,
96
],
"parameters": {
"resource": "opportunity",
"operation": "update",
"updateFields": {
"customFieldsUi": {
"customFieldsValues": [
{
"value": "={{ true }}",
"fieldId": "=Processed__c"
}
]
}
},
"opportunityId": "={{$node[\"Fetch Opportunity Details\"].json[\"Id\"]}}"
},
"credentials": {
"salesforceOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "d4bb1b71-749c-442e-8309-515a17791780",
"name": "Create Follow-up Task",
"type": "n8n-nodes-base.salesforce",
"position": [
2032,
96
],
"parameters": {
"status": "Not Started",
"resource": "task",
"additionalFields": {
"whatId": "={{ $('Fetch Opportunity Details').item.json.Id }}",
"subject": "=Deal Complexity: {{ $('Parse AI Response').item.json.complexity }}",
"description": "=Deal:{{ $('Fetch Opportunity Details').item.json.Name }}\n\nAmount: {{ $('Fetch Opportunity Details').item.json.Amount }}\n\nComplexity:{{ $('Parse AI Response').item.json.complexity }}\n\nReason: {{ $('Parse AI Response').item.json.reason }}\n\nActions: {{ $('Parse AI Response').item.json.actions }}"
}
},
"credentials": {
"salesforceOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "05c928ff-0843-4748-a4d1-26448f324859",
"name": "Send Success Notification (Slack)",
"type": "n8n-nodes-base.slack",
"position": [
2208,
96
],
"parameters": {
"text": "=Deal Processed Successfully\n\nDeal: {{ $('Fetch Opportunity Details').item.json.Name }}\nAmount: {{ $('Fetch Opportunity Details').item.json.Amount }}\n\nComplexity:{{ $('Parse AI Response').item.json.complexity }}\n\nReason: {{ $('Parse AI Response').item.json.reason }}\n\nActions: {{ $('Parse AI Response').item.json.actions }}\n\n{{$now}}",
"select": "channel",
"channelId": {
"__rl": true,
"mode": "list",
"value": "C0AQEPGASKC",
"cachedResultName": "automation"
},
"otherOptions": {},
"authentication": "oAuth2"
},
"credentials": {
"slackOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 2.4
},
{
"id": "c8ce122b-c93f-429c-9ea1-26679d400571",
"name": "Send No Data Notification (Slack)",
"type": "n8n-nodes-base.slack",
"position": [
-160,
368
],
"parameters": {
"text": "= No New Opportunities to Process \nAll deals are already processed \nChecked at: {{ $now }}",
"select": "channel",
"channelId": {
"__rl": true,
"mode": "list",
"value": "C0AQEPGASKC",
"cachedResultName": "automation"
},
"otherOptions": {},
"authentication": "oAuth2"
},
"credentials": {
"slackOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 2.4
},
{
"id": "f8556fe4-9575-4cfb-9d4b-aac4f79bd57a",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1344,
-112
],
"parameters": {
"width": 528,
"height": 752,
"content": "# Deal Complexity Classification Engine\n\n# How It Works\n\nThis workflow automates the classification of deal complexity from Salesforce opportunities. It fetches opportunity details, checks if the deal is already processed, and gathers related data like contacts and products. It then calculates key deal metrics such as number of stakeholders, products, and total product value.\n\nBased on these inputs, AI classifies the deal into Low, Medium, or High complexity with a reason and suggested actions. The workflow updates the opportunity as processed, creates a follow-up task, and sends a Slack notification with the final output. This reduces manual effort and ensures consistent deal evaluation.\n\n# Setup Steps\n\n 1. Connect Salesforce\nAuthenticate Salesforce and configure trigger\n\n 2. Configure Opportunity Fetch\n Ensure required fields are included\n\n 3. Configure Data Processing\n Set logic for contacts and products\n\n 4. Configure AI Model\n Connect model and define prompt\n\n 5. Setup Task & Notifications\n Configure Salesforce task and Slack\n\n 6. Test Workflow\n Run and verify classification output"
},
"typeVersion": 1
},
{
"id": "70b92102-4d11-44a0-8623-623a2f8ed8dc",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-720,
-64
],
"parameters": {
"color": 7,
"width": 720,
"height": 608,
"content": "## Opportunity Fetch & Validation\n\nTriggers when a new opportunity is created in Salesforce and fetches all required deal details. It ensures that only unprocessed opportunities are considered to avoid duplication. If no new or unprocessed data is found, a Slack notification is sent indicating no deals to process. This step prepares the base data required for further processing in the workflow."
},
"typeVersion": 1
},
{
"id": "a9268a64-f741-45e8-8420-7e8ca2ab8fd7",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
48,
-192
],
"parameters": {
"color": 7,
"width": 624,
"height": 608,
"content": "## Data Collection & Combination\n\nFetches related contacts (stakeholders) and opportunity products linked to the deal. It combines both datasets into a single flow to ensure all relevant deal information is available in one place for analysis."
},
"typeVersion": 1
},
{
"id": "6a7ec192-e6f9-4a44-bfcb-23ff1b9f7496",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
720,
-96
],
"parameters": {
"color": 7,
"width": 720,
"height": 512,
"content": "## Deal Metrics, AI Classification & Parsing\n\nCalculates key deal metrics such as number of stakeholders, number of products, and total product value to understand deal scale. These inputs are passed to AI for classifying deal complexity into Low, Medium, or High along with reason and actions. The response is then parsed to extract structured fields for further processing."
},
"typeVersion": 1
},
{
"id": "79472fa6-a38e-47b6-9630-a124658e5376",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
1600,
-48
],
"parameters": {
"color": 7,
"width": 736,
"height": 448,
"content": "## Final Processing & Notifications\n\nMarks the opportunity as processed in Salesforce to avoid reprocessing. Creates a follow-up task with complexity details, reason, and actions for the sales team. Finally, sends a Slack notification with complete deal insights to ensure visibility and quick decision-making."
},
"typeVersion": 1
},
{
"id": "11290418-7f01-431c-a45f-bc77a388d448",
"name": "Format AI Output",
"type": "n8n-nodes-base.set",
"position": [
1632,
96
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "088ac02a-15cf-4bbb-9ce9-998b0c068b70",
"name": "complexity",
"type": "string",
"value": "={{ $json.complexity }}"
},
{
"id": "411d7110-d811-4540-9e92-5577d1531639",
"name": "reason",
"type": "string",
"value": "={{ $json.reason }}"
},
{
"id": "b24a3f47-6fe6-4f3d-b1da-3dc28dc1e195",
"name": "actions",
"type": "array",
"value": "={{ $json.actions }}"
}
]
},
"includeOtherFields": true
},
"typeVersion": 3.4
}
],
"active": false,
"settings": {
"binaryMode": "separate",
"executionOrder": "v1"
},
"versionId": "7650d66e-8ffb-4bab-aea5-a1aff2c7594f",
"connections": {
"AI Model (Groq)": {
"ai_languageModel": [
[
{
"node": "Classify Deal Complexity (AI)",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Format AI Output": {
"main": [
[
{
"node": "Mark Opportunity as Processed",
"type": "main",
"index": 0
}
]
]
},
"Parse AI Response": {
"main": [
[
{
"node": "Format AI Output",
"type": "main",
"index": 0
}
]
]
},
"Create Follow-up Task": {
"main": [
[
{
"node": "Send Success Notification (Slack)",
"type": "main",
"index": 0
}
]
]
},
"Calculate Deal Metrics": {
"main": [
[
{
"node": "Classify Deal Complexity (AI)",
"type": "main",
"index": 0
}
]
]
},
"Check If Not Processed": {
"main": [
[
{
"node": "Prepare Opportunity Data",
"type": "main",
"index": 0
}
],
[
{
"node": "Send No Data Notification (Slack)",
"type": "main",
"index": 0
}
]
]
},
"Fetch Related Contacts": {
"main": [
[
{
"node": "Combine Contacts & Products",
"type": "main",
"index": 1
}
]
]
},
"Prepare Opportunity Data": {
"main": [
[
{
"node": "Fetch Related Contacts",
"type": "main",
"index": 0
},
{
"node": "Fetch Opportunity Products",
"type": "main",
"index": 0
}
]
]
},
"Fetch Opportunity Details": {
"main": [
[
{
"node": "Check If Not Processed",
"type": "main",
"index": 0
}
]
]
},
"Trigger - New Opportunity": {
"main": [
[
{
"node": "Fetch Opportunity Details",
"type": "main",
"index": 0
}
]
]
},
"Fetch Opportunity Products": {
"main": [
[
{
"node": "Combine Contacts & Products",
"type": "main",
"index": 0
}
]
]
},
"Combine Contacts & Products": {
"main": [
[
{
"node": "Calculate Deal Metrics",
"type": "main",
"index": 0
}
]
]
},
"Classify Deal Complexity (AI)": {
"main": [
[
{
"node": "Parse AI Response",
"type": "main",
"index": 0
}
]
]
},
"Mark Opportunity as Processed": {
"main": [
[
{
"node": "Create Follow-up Task",
"type": "main",
"index": 0
}
]
]
},
"Send Success Notification (Slack)": {
"main": [
[]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
groqApisalesforceOAuth2ApislackOAuth2Api
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow monitors new Salesforce opportunities, enriches them with related contacts and products, uses Groq-hosted LLM analysis to classify deal complexity, then updates Salesforce with a processed flag, creates a follow-up task, and posts the outcome to a Slack channel.…
Source: https://n8n.io/workflows/16718/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
> Automate Your Entire RFP Lifecycle
This workflow automatically analyzes newly uploaded proposals by comparing them with past winning proposals using AI. It extracts proposal content, identifies the client, fetches reference data from G
How it works:
This workflow captures incoming leads from Gmail, validates and stores them in Supabase, then uses AI to score and classify each lead. Based on the classification, leads are automatically routed to th
This workflow monitors a Gmail inbox for procurement requests, uses Groq (Llama 3.1) to classify and route each ticket with SLA logic, escalates high-risk items to Slack, creates a ticket via HTTP, se