Imagine the buzz of a high-energy sales floor. Keyboards clicking, calls being made, deals being closed. Yet, amidst this flurry of activity, a critical gap often exists—the silent delay between a digital event and human awareness. A hot lead, freshly qualified and assigned in Salesforce, might sit unnoticed for minutes, or even hours, simply because the right person was looking at the wrong screen. This is the paradox of the modern CRM: we have more data than ever, but our ability to act on it in the crucial moments is often hampered by the very noise of the systems designed to help us. Sales teams are inundated with visual notifications, email alerts, and dashboard widgets, leading to a form of ‘data blindness’ where the most urgent updates get lost in the shuffle. The cost of this delay isn’t just measured in minutes; it’s measured in lost opportunities and revenue left on the table.
But what if we could break free from the screen? What if a critical update could be broadcast into the physical environment, creating an ambient awareness that doesn’t require anyone to refresh a dashboard or check a notification? This isn’t a futuristic concept; it’s a practical solution you can build today. By combining the powerful, low-code automation of Salesforce Flow with the hyper-realistic text-to-speech AI from ElevenLabs, you can create a real-time lead update announcer. This system can automatically generate and broadcast a voice message across your sales floor the instant a lead’s status changes. This article is your step-by-step technical guide to building this transformative tool. We will walk through everything from the initial API setup to the Salesforce Flow configuration, empowering Salesforce administrators, developers, and operations professionals to turn silent data points into immediate, actionable intelligence that your entire team can hear.
The Foundation: Preparing Salesforce and ElevenLabs
Before we can build the automation, we need to lay the groundwork by preparing both our Salesforce environment and our ElevenLabs account. This involves securing API keys, authorizing Salesforce to communicate with an external service, and creating the foundational code that will handle the logic.
Setting Up Your ElevenLabs Account
First, you’ll need an ElevenLabs account to access their advanced voice synthesis API. ElevenLabs offers a range of incredibly lifelike voices and even allows for voice cloning, giving you the flexibility to choose a voice that fits your company culture.
- Navigate to the ElevenLabs website and sign up.
- Once your account is created, locate your API Key in your profile settings. This key is your credential for accessing the API, so keep it secure.
- Take a moment to browse the Voice Lab to select a pre-made voice or design a custom one for your announcements. Note the Voice ID of your chosen voice, as you will need it later.
Configuring Salesforce for API Callouts
To ensure our API requests to ElevenLabs are secure and manageable, we will use a Salesforce feature called Named Credentials. This allows you to store the API endpoint and authentication details in one place, so you don’t have to hardcode sensitive information in your Apex code.
- In Salesforce Setup, search for “Named Credentials”.
- Click on the “External Credentials” tab, and then “New”.
- Label it something intuitive like
ElevenLabs_API. Set the “Authentication Protocol” toCustom. - Next, click on the “Principals” tab. Create a new principal with a name like
ElevenLabs API Key. - For the authentication parameters, add a Header named
xi-api-keyand for the value, paste your ElevenLabs API key. - Now, go back to the main “Named Credentials” tab and click “New”.
- Name this
ElevenLabs. For the URL, enterhttps://api.elevenlabs.io. - For the External Credential, select the
ElevenLabs_APIyou just created. Ensure “Generate Authorization Header” is unchecked.
Creating the Apex Class for the API Callout
With the credentials configured, we can now write a small piece of Apex code that will be responsible for sending the text to ElevenLabs and receiving the audio. This class will be invoked by our Salesforce Flow later.
public class ElevenLabsController {
@InvocableMethod(label='Generate ElevenLabs Audio' description='Sends text to ElevenLabs API to generate audio and saves it as a file in Salesforce.')
public static void generateAudio(List<Requests> requests) {
for (Requests req : requests) {
// Construct the API request body
String body = '{
"text": "' + req.text + '",
"model_id": "eleven_multilingual_v2",
"voice_settings": {
"stability": 0.5,
"similarity_boost": 0.75
}
}';
HttpRequest httpRequest = new HttpRequest();
// The Named Credential URL is combined with the specific API endpoint path
httpRequest.setEndpoint('callout:ElevenLabs/v1/text-to-speech/{VOICE_ID}'); // Replace {VOICE_ID} with your actual voice ID
httpRequest.setMethod('POST');
httpRequest.setHeader('Content-Type', 'application/json');
httpRequest.setHeader('Accept', 'audio/mpeg');
httpRequest.setBody(body);
Http http = new Http();
HttpResponse httpResponse = http.send(httpRequest);
if (httpResponse.getStatusCode() == 200) {
// If successful, save the audio as a File (ContentVersion)
ContentVersion cv = new ContentVersion();
cv.VersionData = httpResponse.getBodyAsBlob();
cv.Title = 'Lead Update Announcement';
cv.PathOnClient = 'lead_announcement.mp3';
insert cv;
// Link the file to the Lead record
ContentDocumentLink cdl = new ContentDocumentLink();
cdl.ContentDocumentId = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:cv.Id].ContentDocumentId;
cdl.LinkedEntityId = req.recordId;
cdl.ShareType = 'V'; // 'V' means Viewer permission
insert cdl;
} else {
System.debug('ElevenLabs API Error: ' + httpResponse.getBody());
}
}
}
// Inner class to define the inputs for the InvocableMethod
public class Requests {
@InvocableVariable(label='Text to Synthesize' required=true)
public String text;
@InvocableVariable(label='Record ID' required=true)
public Id recordId;
}
}
This Apex code defines an InvocableMethod, which means it can be called directly from Flow. It takes a record ID and a string of text, sends it to the ElevenLabs Text-to-Speech API endpoint, and then saves the resulting MP3 audio as a new File linked to the original Lead record.
Building the Automation: A Step-by-Step Salesforce Flow
Now for the fun part. We will create a Record-Triggered Flow that automates the entire process. This Flow will monitor changes to Lead records and, when the right conditions are met, will call our Apex class to generate the voice announcement.
Creating the Record-Triggered Flow
- In Salesforce Setup, search for “Flows” and create a new “Record-Triggered Flow”.
- Select the
Leadobject. Configure the trigger to fire whenever “A record is updated”. - Set the Condition Requirements to “All Conditions Are Met (AND)”.
Defining the Trigger Conditions
We don’t want this Flow to run for every single edit to a Lead. We only want it to fire for a specific status change. Let’s configure it to trigger when a Lead becomes “Hot”.
- Condition 1:
StatusIs ChangedTrue - Condition 2:
StatusEqualsOpen - Not Contacted(Or whatever your desired trigger status is).
Optimize the Flow for “Actions and Related Records”. This ensures the Flow runs after the record is saved to the database, which is required for making API callouts.
Calling the Apex Action
- Click the ‘+’ icon on the Flow canvas to add a new element.
- Select the “Action” element.
- In the Action search box, look for “ElevenLabs” or the label you gave your InvocableMethod, “Generate ElevenLabs Audio”.
- Label the action
Generate Voice Announcement. - You will now see the input variables we defined in our Apex class: “Record ID” and “Text to Synthesize”.
Crafting the Dynamic Announcement
This is where we make the announcement informative. We will use formulas and resource variables from the Flow to construct a dynamic sentence.
- For the
recordIdinput, pass the ID of the record that triggered the flow:{!$Record.Id}. - For the
textinput, we will create a dynamic string. You can make this whatever you want. For example:New hot lead assigned. Name: {!$Record.FirstName} {!$Record.LastName} from company {!$Record.Company}.
Once configured, save and activate your Flow. Now, every time a Lead is updated to meet your criteria, this Flow will automatically call the Apex class, which in turn calls the ElevenLabs API, and a new audio file will be generated and attached to that Lead’s record in the “Files” related list.
From a File to the Sales Floor
With the core integration complete, you have a system that automatically generates an audio file and attaches it to the relevant Salesforce record. This is already a powerful tool, allowing a sales manager or rep to click and play the announcement directly from the Lead page for context. For instance, when a lead is reassigned, the new owner can instantly hear the status update as it was announced. This provides a clear, audible audit trail directly on the record.
But to realize the full vision of an ambient announcer, you need a way to play the audio in a shared space. While building a full-blown broadcasting system is a more advanced project, a simple and effective approach involves using a dedicated device on the sales floor (like a tablet or a computer connected to speakers). You could create a simple Lightning Web Component on a homepage layout that polls for new audio files linked to high-priority leads and plays them automatically. As Jason Zhou, a leading expert in applied AI, notes, “When critical information moves from the screen to the air, you reduce cognitive load and accelerate reaction time. It’s about creating a truly data-driven environment where insights proactively find your team, not the other way around.” The step from a file attached to a record to an announcement played over a speaker is the final leap toward this proactive, data-driven environment.
In summary, we’ve seen how to connect Salesforce and ElevenLabs to transform a simple data change into a powerful, audible event. By setting up our API credentials securely, writing a reusable Apex action, and building a declarative Salesforce Flow, we’ve created a fully automated system for generating real-time voice announcements. This moves your team from a state of passive data consumption to active, event-driven awareness.
We’ve returned to our busy sales floor, but now, instead of silent updates getting lost in the digital noise, a clear voice cuts through: “New hot lead assigned. Name: Jane Doe from Globex Corporation.” The nearest available rep hears it, instantly pulls up the record, and makes the call. That’s the power of turning your data into a conversation. This is just one of countless ways generative AI can be integrated into your core business processes to drive efficiency and action. Ready to bring the power of real-time voice AI to your workflows? try for free now and start building your own custom voice solutions with ElevenLabs.



