A futuristic command center dashboard showing a network of connections between a CRM logo (like a cloud) and human avatar icons, representing automated personalized video outreach. Data visualizations and glowing lines of code fill the screen. Cinematic, professional, tech-noir aesthetic.

Automating Personalized Sales Outreach: A Technical Guide to Integrating HeyGen with Salesforce

🚀 Agency Owner or Entrepreneur? Build your own branded AI platform with Parallel AI’s white-label solutions. Complete customization, API access, and enterprise-grade AI models under your brand.

Imagine Sarah, a top-performing sales development representative (SDR) at a fast-growing SaaS company. She’s sharp, driven, and knows her product inside and out. Yet, she starts her day with a sense of dread, staring at a list of 100 new leads in her Salesforce queue. Her task is to make a genuine connection with each one. The reality? She spends eight hours sending nearly identical outreach emails, swapping out {{first_name}} and {{company_name}} and hoping something sticks. Most of her emails sink without a trace, lost in the digital noise. Sarah knows that a personalized video message could cut through, but creating one for every lead is simply impossible. She’s caught in the classic sales paradox: the need for genuine, personalized connection at an impossibly large scale.

This is the challenge plaguing modern sales teams. We live in an era of data-driven sales, yet our outreach methods often feel impersonal and automated in the worst way. Standard email templates have abysmal engagement rates because prospects have developed an immunity to them. They crave authenticity. Research consistently shows that video is the key—it can boost reply rates by over 200% and build trust exponentially faster than text alone. But the manual effort required creates a bottleneck that stifles growth. How can a team contact hundreds of leads per day with the kind of high-touch, personalized video that actually converts? The answer isn’t to work harder; it’s to build smarter systems.

This is where Retrieval-Augmented Generation (RAG) and AI-driven automation change the game entirely. By integrating a powerful AI video generation platform like HeyGen directly with your Salesforce CRM, you can automate the creation of hyper-personalized video messages. Picture a new lead entering your Salesforce instance and, within minutes, a custom video is generated featuring an AI avatar addressing the lead by name, referencing their company, and speaking to their specific pain points. This isn’t science fiction; it’s a practical, achievable workflow that combines the scalability of automation with the impact of personalization. In this technical walkthrough, we’ll dive deep and show you exactly how to build this integration, from configuring the APIs to writing the Apex code and designing the Salesforce Flow that powers it all.

The Power of Hyper-Personalization at Scale

The fundamental goal of any sales outreach is to start a conversation. However, the channels we use are oversaturated. The average professional receives over 120 emails per day, making it incredibly difficult to stand out with text alone.

Why Standard Outreach Fails

Generic templates are easy to spot and even easier to ignore. They lack the human element that builds rapport and signals that you’ve done your homework. This leads to low open rates, even lower reply rates, and a pipeline that feels more like a lottery than a predictable system.

According to sales engagement platform reports, personalized emails see significantly higher engagement, but manual personalization at scale is a myth. Reps either burn out trying to customize every message or fall back on generic templates to meet their quotas, creating a cycle of diminishing returns.

The Video Advantage

Video flips the script. It captures attention, conveys emotion, and communicates complex ideas more effectively than text. According to Vidyard, businesses incorporating video into their sales strategies experience a 41% higher close rate. When that video is personalized, the impact is magnified.

A video that opens with, “Hi John, I saw you downloaded our guide on AI implementation at Acme Corp,” is infinitely more powerful than a generic email. It proves you’re not just spamming a list; you’re paying attention. This is the key to breaking through the noise and earning a prospect’s time.

The Automation Imperative

This is where programmatic video generation becomes a strategic necessity. By connecting an AI video platform to your CRM, you create a system that works for you. Your team sets the strategy—the messaging, the avatar, the triggers—and the technology handles the execution, freeing your reps to do what they do best: sell.

Laying the Groundwork: Your Tech Stack

Before we dive into the code, we need to prepare our tools. This integration requires setting up accounts and templates in both HeyGen and Salesforce. The process is straightforward and lays the foundation for a seamless automation workflow.

Setting Up Your HeyGen Account and API Key

First, you’ll need a HeyGen account to access their powerful video generation API. The platform allows you to create realistic AI avatars, design video templates, and generate videos programmatically.

  1. Sign Up for HeyGen: If you don’t have an account, you can create one. They offer plans that include API access, which is essential for this integration. You can explore their features and find the right fit for your team. Try for free now.
  2. Locate Your API Key: Once logged in, navigate to your account settings or the developer section to find your API key. This key is your unique identifier for authenticating requests. Treat it like a password and store it securely.

Preparing Your Salesforce Environment

For this walkthrough, a free Salesforce Developer Edition org is perfect for building and testing. Inside your org, we will primarily use two features: Apex for making the API call and Salesforce Flow for orchestrating the automation.

No special licenses are required beyond standard Salesforce access, but you will need administrator permissions to configure the system settings and create the necessary code and automation rules.

Crafting Your Reusable Video Template in HeyGen

This is the most critical preparatory step. Inside the HeyGen platform, you’ll design a video template that will be the basis for all your automated outreach. This template should include your chosen AI avatar, a background, and most importantly, variables for personalization.

Create a new video and add text elements that use double curly braces to define variables, like {{name}} and {{company}}. These are placeholders that our Salesforce integration will dynamically populate with lead data. Once you are satisfied with your template, save it and note its unique Template ID. You’ll need this ID for the API call.

Technical Walkthrough: Connecting Salesforce to the HeyGen API

With the groundwork laid, it’s time to build the bridge between Salesforce and HeyGen. This involves authorizing the API endpoint, writing a small Apex class to handle the communication, and making it available to our automation tools.

Step 1: Authorizing the API Endpoint in Salesforce

For security reasons, Salesforce prohibits API callouts to external sites by default. You must first whitelist the HeyGen API domain.

  1. In Salesforce, navigate to Setup > Security > Remote Site Settings.
  2. Click New Remote Site.
  3. Enter a Remote Site Name (e.g., HeyGen_API).
  4. For the Remote Site URL, enter https://api.heygen.com.
  5. Ensure the Active checkbox is checked and click Save.

This simple step tells Salesforce to trust requests sent to the HeyGen API.

Step 2: Writing the Apex Callout Class

Next, we’ll write the Apex code that constructs and sends the request to HeyGen. This class will be responsible for taking lead data, formatting it into the JSON payload HeyGen expects, and sending it to the video generation endpoint.

Create a new Apex class named HeyGenService.cls and paste in the following code:

public class HeyGenService {

    @InvocableMethod(label='Generate HeyGen Video' description='Generates a personalized video using HeyGen API.')
    public static void generateVideo(List<Request> requests) {
        // We only process the first request in the list for this example
        if (requests.isEmpty()) {
            return;
        }

        Request req = requests[0];
        sendRequest(req.leadName, req.companyName, req.leadId);
    }

    @future(callout=true)
    private static void sendRequest(String leadName, String companyName, String leadId) {
        // Construct the HTTP request
        HttpRequest httpRequest = new HttpRequest();
        httpRequest.setEndpoint('https://api.heygen.com/v2/video/generate');
        httpRequest.setMethod('POST');
        httpRequest.setHeader('Content-Type', 'application/json');
        // IMPORTANT: Replace 'YOUR_API_KEY' with your actual HeyGen API key
        httpRequest.setHeader('X-Api-Key', 'YOUR_API_KEY');

        // Construct the JSON body
        Map<String, Object> bodyMap = new Map<String, Object>();
        // IMPORTANT: Replace 'YOUR_TEMPLATE_ID' with your actual HeyGen Template ID
        bodyMap.put('template_id', 'YOUR_TEMPLATE_ID');

        Map<String, String> variables = new Map<String, String>();
        variables.put('name', leadName);
        variables.put('company', companyName);
        bodyMap.put('variables', variables);

        httpRequest.setBody(JSON.serialize(bodyMap));

        // Send the request
        try {
            Http http = new Http();
            HttpResponse httpResponse = http.send(httpRequest);

            if (httpResponse.getStatusCode() == 200) {
                System.debug('HeyGen video generation initiated successfully.');
                // Optional: Process the response. The response body contains the video ID.
                // You could save this ID to the lead record to check generation status later.
            } else {
                System.debug('HeyGen API Error: ' + httpResponse.getBody());
            }
        } catch (Exception e) {
            System.debug('Error calling HeyGen API: ' + e.getMessage());
        }
    }

    // Wrapper class for Flow inputs
    public class Request {
        @InvocableVariable(label='Lead Name' required=true)
        public String leadName;

        @InvocableVariable(label='Company Name' required=true)
        public String companyName;

        @InvocableVariable(label='Lead ID' required=true)
        public String leadId;
    }
}

Important: Remember to replace YOUR_API_KEY and YOUR_TEMPLATE_ID with your actual credentials from HeyGen.

This code uses an @InvocableMethod, which makes it accessible to Salesforce Flow, and a @future(callout=true) method to perform the API call asynchronously, which is a best practice for callouts from triggers.

Building the Automation Trigger with Salesforce Flow

Now for the final piece: creating a Flow that automatically runs our Apex code whenever a new lead is created.

Step 1: Designing the Record-Triggered Flow

  1. Go to Setup > Process Automation > Flows and click New Flow.
  2. Select Record-Triggered Flow and click Create.
  3. Configure the trigger:
    • Object: Lead
    • Trigger the Flow When: A record is created
    • Condition Requirements: None (or you could add criteria, e.g., LeadSource = 'Web').
    • Optimize the Flow for: Actions and Related Records.

Step 2: Adding the Apex Action

  1. On the Flow canvas, click the + icon on the path and select Action.
  2. In the Action search box, find and select Generate HeyGen Video (the label we defined in our Apex code).
  3. Give the action a Label (e.g., Create Personalized Video).

Step 3: Mapping the Lead Data

This is where you connect the lead’s data to the inputs of our Apex method.

  1. Under Set Input Values, you’ll see the three variables we defined: Lead Name, Company Name, and Lead ID.
  2. For Company Name, click in the value field and select $Record > Company.
  3. For Lead Name, select $Record > First Name.
  4. For Lead ID, select $Record > Id.
  5. Click Done.

Step 4: Save and Activate

Save your Flow with a descriptive name (e.g., New Lead - HeyGen Video Generation) and click Activate. That’s it! Your automation is now live. Every time a new lead is created in Salesforce, this Flow will trigger, sending the lead’s details to HeyGen to generate a personalized video.

This process transforms your sales outreach from a manual, repetitive chore into a powerful, automated system. Sarah, our SDR from the introduction, is no longer bogged down by sending generic emails. Instead, she’s alerted when a new personalized video is ready. She can review it, send it with a brief personal note, and spend the rest of her day engaging in meaningful conversations with warm, receptive prospects. This isn’t just an efficiency gain; it’s a strategic shift that empowers your sales team to build genuine connections at scale.

Ready to transform your sales outreach and leave generic templates behind? The first step is to arm yourself with the right tools. Explore what’s possible with AI-driven video by setting up your own templates. Try for free now and start building the future of sales engagement today.

Transform Your Agency with White-Label AI Solutions

Ready to compete with enterprise agencies without the overhead? Parallel AI’s white-label solutions let you offer enterprise-grade AI automation under your own brand—no development costs, no technical complexity.

Perfect for Agencies & Entrepreneurs:

For Solopreneurs

Compete with enterprise agencies using AI employees trained on your expertise

For Agencies

Scale operations 3x without hiring through branded AI automation

💼 Build Your AI Empire Today

Join the $47B AI agent revolution. White-label solutions starting at enterprise-friendly pricing.

Launch Your White-Label AI Business →

Enterprise white-labelFull API accessScalable pricingCustom solutions


Posted

in

by

Tags: