← Back to Blog
OpenAI · n8n · CRM

OpenAI + n8n: Building AI-Powered CRM Automation That Actually Works

✍️ Hamza Bilal 📅 February 2025 ⏱ 10 min read
OpenAIn8nCRMAI Agents

One of the most powerful automation stacks I've built for clients is OpenAI + n8n for CRM automation. The workflow reads incoming leads, classifies intent using GPT-4o, auto-drafts a personalised reply, and routes the deal to the right sales rep — all without a human touching it.

This is the exact workflow I built for a Retell AI client that was receiving 100+ inbound calls daily. Here's how it works.

The Workflow Overview

The full pipeline has 5 stages:

  1. Trigger — Webhook from CRM (new lead created) or email received
  2. Enrich — Pull full lead details from CRM via HTTP node
  3. Classify — OpenAI node classifies intent (hot/warm/cold, pain points)
  4. Draft — OpenAI drafts a personalised outreach email
  5. Route — Based on classification, assign to rep + create task in CRM

Step 1: The Webhook Trigger

In n8n, create a Webhook node and set it to receive POST requests. In your CRM (Close, HubSpot, etc.), set up a webhook that fires whenever a new lead is created.

The webhook payload typically looks like:

{
  "lead_id": "lead_xyz123",
  "name": "James Carter",
  "email": "james@acmecorp.com",
  "message": "We're a 50-person team using Salesforce. Looking to automate our
               lead routing and follow-up sequences. Need someone ASAP.",
  "source": "website_form"
}

Step 2: Classify Intent with OpenAI

Add an OpenAI node → Chat Message operation. Use gpt-4o. Here's the system prompt I use:

You are a CRM intelligence assistant. Analyze this inbound lead message
and return a JSON object with the following fields:

{
  "intent": "hot" | "warm" | "cold",
  "urgency": "immediate" | "within_week" | "exploring",
  "pain_points": ["string", ...],
  "company_size_guess": "startup" | "smb" | "enterprise",
  "recommended_rep": "closer" | "nurturer" | "technical",
  "summary": "One sentence summary for the sales rep"
}

Respond ONLY with valid JSON. No explanation.

In the user message, pass: {{$json.message}}

Tip: Use a Set node after the OpenAI response to parse the JSON string: JSON.parse($json.choices[0].message.content)

Step 3: Auto-Draft the Outreach Email

Chain a second OpenAI call to draft the reply. Now that you have the classification, you can give GPT rich context:

You are writing a sales outreach email on behalf of Hamza Bilal,
an AI Automation Engineer.

Lead info:
- Name: {{$json.name}}
- Company size: {{$json.company_size_guess}}
- Pain points: {{$json.pain_points}}
- Intent: {{$json.intent}}

Write a concise (3 paragraphs max), personalized reply that:
1. Acknowledges their specific pain point
2. Briefly explains how we've solved this before
3. Proposes a 20-minute call

Tone: professional but conversational. No fluff. No generic phrases.

Step 4: Route Based on Intent

Use a Switch node in n8n to branch based on {{$json.recommended_rep}}:

Each branch makes an HTTP request to your CRM's API to update the lead and create the appropriate task.

Step 5: Post to Slack

Final step: send a Slack message to the assigned rep's DM with the summary:

🔥 Hot lead assigned to you: *{{$json.name}}* from {{$json.email}}
Intent: {{$json.intent}} | Urgency: {{$json.urgency}}
Summary: {{$json.summary}}
Draft reply ready in CRM — review before sending.

Results from a Real Deployment

For the Retell AI client, this workflow processed 847 leads in the first month. The sales team's response time went from an average of 4.2 hours to under 8 minutes (the time it took a rep to review the draft and hit send).

Total cost to run: ~$0.002 per lead (GPT-4o pricing). For 1,000 leads/month = $2. The n8n server costs $8/month. Total: $10/month to fully automate CRM intake for 1,000+ leads.

Want this built for your business? I set these up start-to-finish. Get in touch.

Hire Me For This

I build OpenAI-powered n8n workflows that automate your CRM — lead scoring, AI follow-up, deal tracking, and revenue reporting.