🔬 Assess contract risk from Google Drive with Groq, Salesforce and Slack

⚡ 21 views · 🔬 Document Extraction & Analysis

Description

Quick overview

This workflow monitors a Google Drive folder for new PDF contracts, extracts and cleans the text, uses Groq-hosted LLMs to extract clauses and assess risk, then writes the final risk summary to a Salesforce custom object and posts a notification to Slack.

How it works

  1. Triggers when a new file is created in a specific Google Drive folder.
  2. Checks that the new file is a PDF, then downloads it and derives a contract name from the filename.
  3. Extracts text from the PDF, normalizes whitespace, and splits the contract into smaller chunks.
  4. Uses a Groq LLM to extract and classify key clauses from each chunk and parses the model output into structured JSON.
  5. Sends the extracted clauses to a Groq LLM to assign risk levels, identify issues, and recommend improvements, then generates an overall risk report (overall risk, summary, top risks, and recommendations).
  6. Searches Salesforce for an existing Contract_AI__c record by contract name, creates one if missing, and updates the record with the final report fields.
  7. Posts a Slack message to the selected channel with the overall risk level, summary, and the top risk and recommendation.

Setup

  1. Connect your Google Drive credentials and set the folder ID to watch for incoming contract PDFs.
  2. Add Groq credentials (or equivalent supported configuration) for the three LLM steps used for clause extraction, risk analysis, and final report generation.
  3. Connect Salesforce credentials and ensure the Contract_AI__c custom object and fields (Risk_Level_c__c, Summary__c, Top_Risks__c, Recommendations__c) exist and match the workflow mappings.
  4. Connect Slack credentials and select the channel where the risk summary should be posted.
  5. Verify the Salesforce search query and update field mappings (especially the contract name used for lookup) to match your naming conventions.

Additional info

How To Customize Nodes

Add‑ons

Here are a few ways you can extend this workflow:

Use Case Examples

  1. Vendor Agreement Vetting: Automatically scan incoming software subscriptions or supplier contracts for hidden auto-renewal clauses or high-risk indemnities.
  2. NDA Risk Screening: Ensure non-disclosure agreements match your company’s standard terms and don’t contain unusually long confidentiality periods.
  3. Sales Contract Review: Allow sales reps to drop drafted contracts into a Drive folder and automatically get a Slack message confirming if the terms meet the legal baseline before sending to clients.
  4. Employment Agreement Checks: Scan HR documents to ensure required clauses (like IP assignment or dispute resolution) are present and properly worded.
  5. Lease Agreement Audits: Extract and log payment terms, liability shifts, and termination windows for commercial real estate leases directly into your CRM.

There are many more such use cases of this workflow across finance, operations, and compliance departments!

Troubleshooting Guide

IssuePossible CauseSolution
Workflow isn’t triggering when a file is uploadedThe Drive folder ID is wrong, or the file isn’t a PDF.Double-check the selected folder in the Google Drive Trigger node. Ensure the uploaded file extension is exactly .pdf.
”Invalid JSON from OpenAI/Groq” Error in Code NodesThe AI model returned extra conversational text instead of raw JSON data.The parsing code nodes already try to strip markdown. If it still fails, try swapping the Groq model to a more rigid one (like Llama 3 70B) or adjust the prompt to strictly forbid conversational text.
Salesforce Node throws a missing field errorThe Contract_AI__c object or its custom fields do not exist in your Salesforce org.Log into Salesforce, go to Object Manager, and ensure the object and exact custom field API names (like Risk_Level_c__c) match the node mapping.
Slack message doesn’t sendThe Slack bot doesn’t have permission to post in the channel.Ensure your n8n Slack app is invited to the #general channel, or change the destination to a channel the bot is explicitly added to.

Need Help?

Setting up AI agents, custom Salesforce objects and text chunking can sometimes be tricky depending on your specific business rules and document structures.

If you need a helping hand to set up this workflow, customize the Add-Ons or build similar advanced AI workflows tailored to your exact business processes, feel free to reach out!

Our n8n workflow developers at WeblineIndia are available for expert assistance in bringing your business process automation goals to life.

đź”— Nodes Used

Slack, Google Drive, Salesforce, Google Drive Trigger, AI Agent, Extract from File

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup