We have all heard the sales mantra: “Speed to lead is everything.”

If a potential client fills out a form on your website at 2:00 AM, and you wait until 9:00 AM to call them back, that lead has likely already moved on to a competitor. But let’s be real—nobody wants to stay awake 24/7 just to field inquiry calls.

I used to struggle with this balance. I wanted the high-touch personalization of a phone call but needed the scalability of automation. The solution isn’t hiring an expensive 24/7 sales team; it’s building a digital employee.

In this guide, I’m going to show you exactly how to build an AI voice agent using n8n and Vapi. This system will detect a new lead, call them instantly, qualify them, and log all the data into a spreadsheet—all without you lifting a finger.

Share by Nate Herk

The strategy: Beyond simple chatbots

Before we start connecting nodes, we need to understand the architecture. Most people think of AI as just a text chatbot. We are going a step further. We are creating a system that speaks, listens, and understands.

Here is the high-level wireframe of what we are building based on the workflow:

  1. The Trigger: A lead submits an n8n Form (Name, Phone, Company, Request).
  2. Data Normalization: We clean the phone number to ensure the format is valid for dialing.
  3. The Filter: If the number is invalid, we log it immediately and stop. If valid, we proceed.
  4. The Call: We trigger Vapi (our voice AI) to call the prospect.
  5. The Polling Loop: The system waits and periodically checks if the call is finished.
  6. The Result: If it went to voicemail, we log it separately. If the conversation completed, we extract the structured data (budget, urgency, intent) and log it to Google Sheets.
Download workflow: https://romhub.io/n8n/Outbound_Lead_Qualifier

Step 1: Setting up the automation logic (n8n)

We are using n8n as the brain of this operation. It handles the logic, moves the data, and tells the voice agent what to do.

Triggering the workflow

For this setup, we are using the n8n Form Trigger node. This gives us a hosted URL where leads can enter their:

  • Name
  • Phone Number
  • Email
  • Company Name
  • Role
  • Request
  • Company Size

Standardizing your data (The Code Node)

This is where most automations break. Humans are messy data entry machines. Some people type (555) 123-4567, others type 555.123.4567. If you send a messy number to the Vapi API, it will fail.

To fix this, we use a Code Node running JavaScript. The logic inside performs a specific cleanup:

  1. It strips all non-digit characters (parentheses, dashes, spaces).
  2. It checks the length:
    • 10 digits: Keeps it as is.
    • 11 digits (starting with 1): Strips the leading ‘1’ (US country code adjustment).
    • Anything else: Returns “incorrect format”.

An If Node then checks this output. If the phone number is flagged as “incorrect format,” the workflow branches to a Google Sheets node to log the error and stops there, saving you from failed API calls.

Step 2: Configuring the voice agent (Vapi)

Now for the fun part. We are using Vapi to create our voice assistant. Think of Vapi as the “mouth and ears” of the operation.

Prompting the persona

In the Vapi dashboard, we define who the agent is. In our system prompt, we configure it to accept dynamic variables. Instead of hardcoding a script, we use placeholders like {{lead_name}} and {{lead_company_name}}.

This allows the agent to say:
“Hey, is this Richard? I’m calling about Green Grass Landscaping.”

The secret sauce: Structured Outputs

This is the most critical part of the configuration. We don’t just want a recording; we want data.

In Vapi, we configure “Structured Outputs” to extract specific information during the call. Based on our workflow, we are extracting:

  • Intent: Are they actually interested?
  • Past Experience: Have they used similar services before?
  • Budget: What is their price range?
  • Motivation: Why are they looking now?
  • Urgency: How soon do they need this?
  • Service Interest: What specific service do they want?

The AI conducts the conversation naturally, but in the background, it fills out this checklist.

Step 3: Integrating the API and Polling

Back in n8n, we use an HTTP Request node to initiate the call.

The API handshake

We send a POST request to Vapi’s /call endpoint. In the body of this request, we pass:

  1. Assistant ID: The ID of the bot we created.
  2. Phone Number ID: The ID of the number calling out.
  3. Customer Number: The standardized number from Step 1.
  4. Variable Overrides: We inject the Name, Company, and Request from our form.

The Polling Loop (Handling the Async nature)

When n8n tells Vapi to call, Vapi says “Okay, started” and the node finishes immediately. It doesn’t wait for the conversation to end.

To capture the results, we build a loop:

  1. Initial Wait: A Wait Node pauses the workflow for 60 seconds to allow the conversation to begin.
  2. Get Call Details: An HTTP Request (GET) asks Vapi for the current status.
  3. Ended Check: An If Node checks if status is equal to ended.
    • If No: The workflow moves to a Polling Wait (10 seconds), loops back, and checks again.
    • If Yes: We proceed to processing.

Note: The workflow includes a Limit node to prevent infinite loops if something goes wrong.

Step 4: Analyzing and logging results

Once the call is confirmed as “ended,” we have one final logic check.

We use an If Node to check the endedReason.

  • If “voicemail”: We route this to a specific “Log Voicemail” Google Sheet node. We don’t want to mark a voicemail as a qualified lead.
  • If NOT “voicemail”: We assume the call was completed successfully.

For completed calls, the final Google Sheets node maps the Structured Outputs we configured in Vapi (Budget, Urgency, etc.) directly into the spreadsheet columns.

The Result

Instead of a messy list of missed calls, you wake up to a Google Sheet that looks like this:

NameUrgencyBudgetMotivationStatus
RichardASAP$5k-10kSlow holiday seasonComplete

You are no longer chasing leads; you are analyzing qualified opportunities.

The technology to do this isn’t coming “someday.” It is here right now. With this n8n workflow, you have a standardized, automated system that filters bad numbers, calls leads instantly, and captures the data that actually matters.

You may also like

Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments