Back to Play 2 Resources
Play 2: Lead Qualification

How to Build a Custom Chatbot (No Code Guide)

Using Claude Code / GPT Codex to generate a chat widget, then connecting to n8n via webhook.

How to Build a Custom Chatbot (No Code Guide)

You need a chatbot that qualifies leads while you sleep. Not a generic "How can I help you?" widget that visitors close in three seconds, but a conversation engine that captures contact details, identifies high-intent prospects, and routes them to the right partner.

This guide shows you how to build one in 90 minutes using Claude's API and n8n's workflow automation. No developers required.

What You're Building

A chat widget embedded on your website that:

  • Asks qualifying questions based on practice area (litigation, tax advisory, M&A, etc.)
  • Captures name, email, company, and budget range
  • Sends qualified leads directly to your CRM
    or Slack
  • Stores conversation transcripts for follow-up

Total cost: $20-40/month for typical professional services traffic (500-1000 conversations).

What You Need Before Starting

Claude API

Access
Sign up at console.anthropic.com. You'll get $5 in free credits. Upgrade to a paid plan once you're live. Cost: ~$0.02 per conversation.

n8n Account
Create a free cloud account at n8n.io or self-host (Docker setup takes 10 minutes). Cloud plan starts at $20/month for 2,500 workflow executions.

Chatbase Account (for the widget)
Sign up at chatbase.co. Free plan allows 30 messages/month. Paid plan ($19/month) gives you 2,000 messages and removes branding.

Website Access
You need permission to add a JavaScript snippet to your site footer. If you're on WordPress, Webflow, or Squarespace, this takes 60 seconds.

Step 1: Design Your Qualification Flow

Open a text editor and map out exactly what your chatbot needs to learn about each visitor.

Example for a law firm:

  1. What brings you here today? (Practice area identification)
  2. What type of organization are you with? (Company size/type)
  3. What's your timeline for needing help? (Urgency scoring)
  4. What's your name and email? (Contact capture)

Example for an accounting firm:

  1. What service are you looking for? (Tax, audit, advisory, fractional CFO)
  2. What's your annual revenue range? (Budget qualification)
  3. Are you currently working with another firm? (Competitive intel)
  4. Best email to send our service overview? (Lead capture)

Write this out as a simple numbered list. This becomes your system prompt in Step 3.

Step 2: Set Up Your n8n Webhook

Log into n8n and create a new workflow.

Add a Webhook

node:

  1. Click the "+" button, search for "Webhook
    "
  2. Select "Webhook
    " from the list
  3. Set HTTP Method to "POST"
  4. Set Path to "/chatbot-lead" (or any unique identifier)
  5. Click "Execute Node" - this generates your webhook
    URL
  6. Copy this URL. It looks like: https://yourinstance.app.n8n.cloud/webhook/chatbot-lead

Add a Claude node:

  1. Click "+" after the Webhook
    node
  2. Search for "HTTP Request" (we'll call Claude's API
    directly)
  3. Set Method to "POST"
  4. Set URL to https://api.anthropic.com/v1/messages
  5. Under Authentication, select "Header Auth"
  6. Add header: x-api-key with your Claude API
    key
  7. Add header: anthropic-version with value 2023-06-01
  8. Add header: content-type with value application/json

Configure the request body:

In the Body section, select "JSON" and paste:

{
  "model": "claude-3-5-sonnet-20241022",
  "max_tokens": 1024,
  "messages": [
    {
      "role": "user",
      "content": "`{{ $json.body.message }}`"
    }
  ],
  "system": "You are a lead qualification assistant for [YOUR FIRM NAME]. Your job is to ask visitors these questions in a natural conversation: 1) What service do they need? 2) What's their company size? 3) What's their timeline? 4) Their name and email. Keep responses under 40 words. Be professional but conversational."
}

Replace [YOUR FIRM NAME] with your actual firm name.

Add a response node:

  1. Add another "Respond to Webhook
    " node after the HTTP Request
  2. Set Response Body to {{ $json.content[0].text }}

Click "Execute Workflow" to test. Your webhook

is now live.

Step 3: Create the Chat Widget in Chatbase

Log into Chatbase and click "New Chatbot."

Connect to your n8n webhook

:

  1. Select "Custom API
    " as your data source
  2. Paste your n8n webhook
    URL from Step 2
  3. Set Request Method to "POST"
  4. Under "Message Field," enter message
  5. Under "Response Field," enter the JSON path to Claude's response (this varies - test and adjust)

Configure the widget appearance:

  1. Go to Settings > Widget
  2. Set your brand color (use your firm's primary color)
  3. Upload your logo (square format, 200x200px minimum)
  4. Set initial message: "Hi, I'm here to help you find the right [service type] for your needs. What brings you here today?"
  5. Set suggested prompts: "I need tax help," "Tell me about your services," "I want to schedule a call"

Set up lead capture:

  1. Go to Settings > Lead Collection
  2. Enable "Collect email before chat" (optional but recommended)
  3. Add custom fields: Name, Company, Phone (mark as optional)

Step 4: Add Lead Routing to n8n

Go back to your n8n workflow. After the Claude response node, add routing logic.

Add a conditional node:

  1. Insert an "IF" node after the Respond to Webhook
    node
  2. Set condition: {{ $json.content[0].text }} contains "email"
  3. This triggers when the visitor provides their email

Add a CRM

node (true branch):

For HubSpot:

  1. Add "HubSpot" node
  2. Select "Create or Update Contact"
  3. Map fields: Email = {{ $json.body.email }}, Name = {{ $json.body.name }}
  4. Add custom property: "Lead Source" = "Website Chatbot"

For Salesforce:

  1. Add "Salesforce" node
  2. Select "Create Lead"
  3. Map fields similarly

For a simple solution, add a "Send Email" node:

  1. Add "Send Email" node
  2. To: your intake email
  3. Subject: "New Chatbot Lead: {{ $json.body.name }}"
  4. Body: Include all captured fields

Add a Slack notification (optional):

  1. Add "Slack" node on the true branch
  2. Select your channel (create a #leads channel if needed)
  3. Message: "New qualified lead from chatbot: {{ $json.body.email }}"

Step 5: Embed the Widget on Your Site

In Chatbase, go to Settings > Embed.

Copy the JavaScript snippet. It looks like:

<script>
  window.embeddedChatbotConfig = {
    chatbotId: "YOUR_CHATBOT_ID",
    domain: "www.chatbase.co"
  }
</script>
<script src="https://www.chatbase.co/embed.min.js" defer></script>

For WordPress:

  1. Go to Appearance > Theme File Editor
  2. Open footer.php
  3. Paste the snippet before the closing </body> tag
  4. Save

For Webflow:

  1. Go to Project Settings > Custom Code
  2. Paste in Footer Code section
  3. Publish

For Squarespace:

  1. Go to Settings > Advanced > Code Injection
  2. Paste in Footer section
  3. Save

Test by visiting your site in an incognito window. The chat widget should appear in the bottom right corner.

Step 6: Test the Complete Flow

Run through a full conversation:

  1. Open your website
  2. Click the chat widget
  3. Answer the qualification questions
  4. Provide your email
  5. Check that the lead appears in your CRM
    or email
  6. Verify the Slack notification fired (if configured)

Common issues:

  • Widget doesn't appear: Check browser console for JavaScript errors. Verify the snippet is in the footer, not header.
  • Webhook
    fails: Check your n8n execution log. Verify the Claude API
    key is correct.
  • Leads not routing: Check the IF condition logic. Add a "Set" node before the IF to inspect the exact data structure.

Improving Response Quality

Your chatbot will sound generic at first. Refine the system prompt in your n8n HTTP Request node.

Better system prompt template:

You are a lead qualification assistant for [FIRM NAME], a [practice area] firm serving [target market]. 

Your goal: Determine if the visitor needs [service 1], [service 2], or [service 3], then collect their contact info.

Ask these questions in order:
1. What challenge are you trying to solve?
2. What's your company's annual revenue? (Options: Under $5M, $5M-$20M, $20M+)
3. What's your timeline? (Options: Urgent - within 2 weeks, Soon - within 2 months, Exploring options)
4. What's your name and best email?

Rules:
- Keep each response under 35 words
- If they ask about pricing, say: "Our fees depend on scope. Let's get you connected with the right partner to discuss specifics."
- If they ask about credentials, mention: [your key differentiator - e.g., "We're a top 50 firm with 15 years in M&A tax"]
- Never make up information about services you don't offer

Test variations. Check your conversation logs in Chatbase to see where visitors drop off.

What This Costs at Scale

500 conversations/month:

  • Chatbase: $19/month
  • n8n: $20/month
  • Claude API
    : ~$10/month
  • Total: $49/month

2,000 conversations/month:

  • Chatbase: $99/month
  • n8n: $50/month (higher tier)
  • Claude API
    : ~$40/month
  • Total: $189/month

Compare this to a full-time intake coordinator ($50k+ annually) or a enterprise chatbot platform ($500-2000/month).

Next Steps

Once your chatbot is live and collecting leads:

  1. Review conversation logs weekly. Identify questions the bot handles poorly.
  2. A/B test different opening messages. "What brings you here?" vs. "Looking for tax help or advisory services?"
  3. Add a calendar booking link for qualified leads. Use Calendly's API
    in n8n to auto-schedule.
  4. Create separate chatbots for different practice areas with unique qualification flows.

You now have a 24/7 lead qualification system that costs less than one business lunch per month.

Revenue Institute

Reviewed by Revenue Institute

This guide is actively maintained and reviewed by the implementation experts at Revenue Institute. As the creators of The AI Workforce Playbook, we test and deploy these exact frameworks for professional services firms scaling without new headcount.

Revenue Institute

Need help turning this guide into reality? Revenue Institute builds and implements the AI workforce for professional services firms.

RevenueInstitute.com