Skip to navigation

Salesforce

Connect your ElevenLabs agents with Salesforce CRM

Overview

Connect your ElevenLabs AI agents with Salesforce CRM to access customer data, manage leads, and create opportunities. This integration enables your agents to retrieve existing customer records, create new leads and contacts, and query Salesforce objects during conversations.

Capabilities

CapabilitySupport
Zero retention mode (ZRM)Not supported
Attachments in triggersNot supported — attachments on incoming case comments and emails are not forwarded to the agent
Attachments in toolsNot supported — tools operate on text only

Setup

This integration uses Salesforce OAuth 2.0 Client Credentials for authentication. You will need to create an External Client App in Salesforce.

1

Create an External Client App

  1. Log into your Salesforce org as an administrator
  2. Go to Setup > External Client App Manager
  3. Click New External Client App
  4. Fill in the External Client App Name (e.g., ElevenLabs Agents), API Name, and Contact Email
  5. Under API (Enable OAuth Settings):
    • Check Enable OAuth and Enable Client Credentials Flow
    • Callback URL: https://api.elevenlabs.io/oauth/callback
    • OAuth Start URL: https://api.elevenlabs.io/oauth/start
    • Selected OAuth Scopes: add these scopes:
      • Full access (full)
      • Perform requests on your behalf at any time (refresh_token, offline_access)
      • Manage user data via api
  6. Click Create
  7. On the app page, open the Settings tab, go to OAuth Settings, and click Consumer Key and Secret
  8. Copy the Consumer Key and Consumer Secret — you will need these for authentication
2

Configure OAuth Client Credentials flow

The Client Credentials Flow is recommended for server-to-server integrations where no user interaction is required. Ensure your Salesforce admin has enabled this flow.

  1. In your External Client App, click Edit
  2. Check Enable Client Credentials Flow — a Run As field will appear
  3. Set Run As to a dedicated integration user, not a person’s account — this determines the permissions for all API calls, and the Salesforce Cases trigger ignores the records this user creates or changes
  4. Set Permitted Users to Admin approved users are pre-authorized
  5. Click Save

The Run As user determines the permissions for all API calls. Choose a user with a System Administrator profile or a custom profile that has API access and permission to the objects your agent needs (Contact, Lead, Account, etc.). The API Enabled permission must be checked on the user record.

3

Find your Salesforce domain

Your Salesforce domain is required for API calls.

Method 1: Check your current URL

When logged into Salesforce, look at your browser’s address bar:

  • Lightning Experience: https://acme.lightning.force.com/
  • My Domain: https://acme.my.salesforce.com/

Method 2: Setup > Company Information

Go to Setup > Company Information and look for your My Domain URL or Organization information.

Method 3: Setup > Domain Management

Go to Setup > Domain Management > My Domain. Your domain will be shown at the top of the page.

Common domain formats:

  • https://acme.my.salesforce.com (My Domain)
  • https://acme.lightning.force.com (Lightning)
  • https://acme.develop.my.salesforce.com (Sandbox)
Use the full domain without a trailing slash.
4

Connect in ElevenLabs

In the ElevenLabs integration setup, enter your Salesforce instance hostname (e.g., acme.my.salesforce.com), Client ID (Consumer Key), and Client Secret (Consumer Secret).

Demo video

This demo uses legacy webhook tools. If you’re using the native Salesforce integration, the tools are configured automatically — no manual webhook setup is needed.

Salesforce integration demo

How it works

1

Initial customer inquiry

The agent gathers customer information and asks relevant questions to identify their business requirements and current challenges.

2

Customer data lookup

The agent checks for existing records using salesforce_search_records to find contacts, accounts, or leads. It retrieves full details with salesforce_get_record and uses this information to personalize the conversation.

3

Lead qualification

If the customer is new, the agent collects contact information, assesses their business needs, and determines the appropriate sales process or routing.

4

Record creation

The agent creates the appropriate record (lead, contact, or opportunity) using salesforce_create_record, confirms creation with the customer, and explains next steps.

Tool authorization can be managed using Workplace Auth Connections, which handles token refresh automatically. The tools return human-readable names and descriptions rather than technical IDs to improve conversation quality.

Tool configurations

Three webhook tools are available: salesforce_search_records, salesforce_get_record, and salesforce_create_record. Configure authorization for each using a Workplace Auth Connection.

Authorization - Workplace OAuth2 connection

2

Configure Salesforce connection

Fill in the following fields for your Salesforce integration:

Connection Name: Salesforce CRM

Client ID

  • Your Consumer Key from the External Client App
  • Example: 3MVG9JJlvRU3L4pRiOu8pQt5xXB4xGZGm0yW...

Client Secret

  • Your Consumer Secret from the External Client App
  • Example: 1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF...

Token URL

  • Your Salesforce domain’s OAuth token endpoint
  • Format: https://{domain}.my.salesforce.com/services/oauth2/token
  • Example: https://acme.my.salesforce.com/services/oauth2/token

Scopes (optional)

  • OAuth scopes for Salesforce API access
  • Recommended: full, api, refresh_token
  • Leave blank to use default scopes from your External Client App

Extra Parameters (JSON)

  • Additional OAuth parameters specific to your setup
  • Example for Client Credentials flow:
{
"grant_type": "client_credentials"
}
4

Create auth connection

Click Create auth connection to add your configuration.

5

Use in tool configurations

Once the connection is successful, save it and reference it in your webhook tool configurations in the Authentication section.

Workplace Auth Connections handles token refresh automatically, so you do not need to manage tokens manually.

Webhook tool configurations

Add a Workplace Auth Connection (OAuth2) to each tool in the Authentication section. Use the tabs below to review each tool’s configuration.

Name: salesforce_search_records Description: Searches for existing records in Salesforce using SOQL queries. Always returns human-readable information including Names, not just IDs. Method: GET URL: https://acme.my.salesforce.com/services/data/v58.0/query/?q={soql_query}

Headers:

  • Content-Type: application/json

Query Parameters:

  • q: SOQL query string (e.g., “SELECT Id, Name, Email FROM Contact WHERE Email = ‘example@email.com’”)

Tool JSON:

{
"type": "webhook",
"name": "salesforce_search_records",
"description": "Searches for existing records in Salesforce using SOQL queries. Always returns human-readable names and details, not just IDs.",
"api_schema": {
"url": "https://acme.my.salesforce.com/services/data/v58.0/query/",
"method": "GET",
"path_params_schema": [],
"query_params_schema": [
{
"id": "q",
"type": "string",
"description": "SOQL query string to search for records. Always include Name fields and other human-readable information. Example: SELECT Id, Name, Email, Phone, Company FROM Contact WHERE Email = 'customer@example.com'. For Opportunities, include: SELECT Id, Name, StageName, Amount, CloseDate, Account.Name FROM Opportunity",
"dynamic_variable": "",
"constant_value": "",
"required": true,
"value_type": "llm_prompt"
}
],
"request_body_schema": null,
"request_headers": [
{
"type": "value",
"name": "Content-Type",
"value": "application/json"
}
]
},
"response_timeout_secs": 30,
"dynamic_variables": {
"dynamic_variable_placeholders": {}
}
}

Common Salesforce objects

ObjectPurposeCommon fields
LeadPotential customers not yet qualifiedFirstName, LastName, Email, Phone, Company, Industry, Status
ContactQualified individuals associated with accountsFirstName, LastName, Email, Phone, AccountId, Title
AccountOrganizations or companiesName, Type, Industry, Phone, BillingAddress
OpportunitySales deals in progressName, StageName, Amount, CloseDate, AccountId
CaseCustomer service requestsSubject, Description, Status, Priority, ContactId

Common SOQL queries

Use these SOQL queries as starting points when customizing your agent’s system prompt. All queries return human-readable information rather than technical IDs:

Search for contacts by email

SELECT Id, Name, Email, Phone, Title, Account.Name, Account.Type FROM Contact WHERE Email = 'customer@example.com'

Search for leads by email or phone

SELECT Id, Name, Email, Phone, Company, Industry, Status, LeadSource, Title FROM Lead WHERE Email = 'customer@example.com' OR Phone = '+1234567890'

Search for accounts by name

SELECT Id, Name, Type, Industry, Phone, BillingCity, BillingState, Website FROM Account WHERE Name LIKE '%Company Name%'

Search for recent opportunities

SELECT Id, Name, StageName, Amount, CloseDate, Account.Name, Account.Type, Owner.Name, Description FROM Opportunity WHERE CreatedDate = THIS_MONTH

Search for opportunities by account

SELECT Id, Name, StageName, Amount, CloseDate, Probability, NextStep, Owner.Name FROM Opportunity WHERE Account.Name LIKE '%Company Name%'

Integration testing

After setting up your External Client App and connecting the integration, test it before deploying to production:

  1. Search functionality: Ask your agent to search for existing contacts.
  2. Record creation: Have your agent create a new lead or contact.
  3. Data retrieval: Verify your agent can retrieve detailed customer information.

Salesforce Cases trigger: email replies for Email-to-Case

If you’ve enabled the Salesforce Cases trigger (agent auto-response to Service Cloud Cases), replies to Cases with at least one inbound email are sent back to the customer as a real, threaded email — not just an internal Case Comment. This is based on whether the Case has an inbound email, not on the Case’s Origin picklist value, so it still works correctly if your org uses a customized Origin value like “Email - Returns” rather than the literal “Email”. A Case with no inbound email whose Origin doesn’t start with Email and that has a Web Email (SuppliedEmail), such as a Web-to-Case or site-form Case, is a web-form Case: the agent reads its Description as the customer’s first message and emails its reply to the Web Email, with the Case Subject as the email subject. Other Cases with no inbound email are answered with a public Case Comment. Any addresses CC’d on the customer’s original email are automatically CC’d on the reply as well, matching how a human agent’s “Reply All” would behave — except for your org’s Email-to-Case routing address(es), which are deliberately excluded from CC so the reply doesn’t get re-ingested by Email-to-Case and re-trigger the agent on its own message.

Sending email replies requires some additional setup beyond what’s needed for Case Comments alone:

  • The Run As user’s Profile or Permission Set must have the Send Email system permission enabled (Setup > Users > Profiles, under System Permissions), in addition to the API Enabled permission already required for the integration.
  • Your org’s Email Deliverability setting (Setup > Email > Deliverability) must allow external email — Sandboxes default this to a restricted setting, which silently blocks outbound email.
  • If you want replies to come from a support alias rather than the Run As user’s own mailbox, set the Org-Wide Email Address Id field on the trigger to the Id of an Organization-Wide Email Address (Setup > Organization-Wide Addresses > click the address > copy the Id from the URL). Leave it blank to send from the Run As user’s own address.
  • To have customer replies go somewhere other than the From address, set the Reply-To Address field on the trigger, usually one of your Email-to-Case addresses so replies land back on the Case. Leave it blank to reply to the From address. Changing it means removing and re-adding the trigger.
  • Set the Email-to-Case Routing Address(es) field on the trigger to your org’s Email-to-Case address(es) (comma separated if more than one, Setup > Email-to-Case). Without this, the integration falls back to guessing the routing address from the customer’s email (its To address), which misses cases where your routing address was only CC’d rather than the primary recipient — CC’ing it back on a reply in that situation would re-trigger the agent on its own message.

If a customer’s org doesn’t have these configured, an email send failure falls back to posting a public Case Comment, so a reply is never silently dropped — but the customer won’t receive it by email until the above is set up. On a web-form Case a failed send is not posted as a Case Comment, since the customer would not see it.

Dynamic variables

The Salesforce Cases trigger passes these dynamic variables to the agent, refreshed on every new message:

  • integration__salesforce_case_id: the Case Id.
  • integration__salesforce_case_number: the Case Number.
  • integration__salesforce_case_created_at: when the Case was created.
  • integration__salesforce_case_subject: the Case Subject, when set.
  • integration__salesforce_case_contact_id: the Case’s Contact Id, when set.
  • integration__salesforce_customer_email: the address the agent’s reply goes to. This is the sender of the latest inbound email, or the Case’s Web Email (SuppliedEmail) when there is none. It is left out when neither is set.

integration__salesforce_customer_email is the address Salesforce recorded, not a verified identity: Email-to-Case doesn’t authenticate senders, and web forms accept any typed address. Use it to address or look up the customer, not to authorize account changes.

Queue-scoped mode

A typical support setup keeps a separate queue for Cases the AI agent handles and human queues for Cases after handover or escalation to a person. Set AI Queue Id(s) on the Salesforce Cases trigger (comma separated if more than one) so the agent answers only Cases owned by those queues. If you leave it blank, the agent answers every Case, whichever queue or user owns it, so set it whenever people also work Cases in this org.

Each AI queue must list Case as a supported object, and the Cases the agent should answer have to land in it: make the queue the Case Owner on your Email-to-Case routing address, or route Cases there with an assignment rule or a Flow.

  • To hand a Case over, move it to a human queue (or let the agent escalate it). The agent stops replying, and later customer emails stay on the Case for your team.
  • To hand it back, move it to an AI queue again. The agent answers the customer’s messages it hasn’t replied to yet.
  • A reply already being generated when ownership changes can still be delivered.

Adding the trigger installs three record-triggered Flows (named ElevenLabs_..._Flow_..., visible in Flow Builder), the Apex classes they call and a Remote Site Setting for the ElevenLabs webhook. Removing the trigger deletes them. Each Flow’s label names the agent, and its description lists the agent Id and the trigger connection Id; the label keeps the agent it was installed with if you later point the trigger at another agent.

The agent doesn’t move Cases it never answered, for example after an outage. To catch them, add a Case Escalation Rule or a scheduled Flow that reassigns AI-queue Cases with no reply after a few hours to a human queue.

Run As user permissions

The External Client App’s Run As user installs the trigger and sends the agent’s replies. The System Administrator profile has everything below; a custom profile or permission set needs:

  • API Enabled
  • Modify All Data, or Author Apex and Customize Application, to deploy the Apex classes, Flows and Remote Site Setting
  • Manage Flow, to activate the Flows
  • Send Email, for email replies
  • Read and edit access to Case, Case Comment and Email Message

Set Integration User Id on the trigger to this same user. The Flows ignore records it creates; with a different user, the agent’s own comments wake it again and it answers itself.

Daily limits

Salesforce counts these per org over a rolling 24 hours. Check current usage with GET /services/data/vXX.X/limits.

  • SingleEmailMessage: about 5,000 external recipients per day; CC’d addresses count too. Email-heavy orgs hit this first.
  • Daily API requests: about 4 to 6 per Case event (new Case, email or comment).
  • Daily asynchronous Apex executions: about one per Case event.

Install and removal timing

Adding or removing the trigger runs a Metadata API deployment, which waits in your org’s deployment queue behind other deployments. If it hasn’t finished within about four minutes, ElevenLabs cancels the deployment and adding the trigger fails. Check Setup > Deployment Status and try again when the queue is clear.

Removing leftover components

Removing the trigger deletes the Flows first. If Salesforce returns a temporary error, the trigger stays in ElevenLabs and you can try removing it again; otherwise the trigger is removed and the error lists what’s left in your org. The Apex classes are then deleted without running tests; if Salesforce requires tests, it runs your org’s local tests, and any failing test of yours leaves the classes and the Remote Site Setting behind. They do nothing without the Flows. To clean up by hand, for the trigger’s suffix (the <id> in the names):

  1. In Setup > Flows, deactivate and delete ElevenLabs_Case_Flow_<id>, ElevenLabs_Email_Flow_<id> and ElevenLabs_Comment_Flow_<id>.
  2. Delete the Apex classes ElevenLabs_Webhook_<id>, ElevenLabs_EmailReply_<id> and ElevenLabs_Test_<id>. Production orgs don’t allow deleting Apex in Setup, so use a destructive deployment (Salesforce CLI or your release tool).
  3. In Setup > Remote Site Settings, delete ElevenLabs_Webhook_Site_<id>.

Security considerations

  • Use HTTPS endpoints for all API calls.
  • Ensure proper field-level security is configured in Salesforce.
  • The Run As user’s permissions determine what data the integration can access — scope them appropriately.
  • Regularly audit API access and usage.
  • The ElevenLabs_Webhook_<id> Apex class holds the secret ElevenLabs uses to verify its webhook calls. Exclude ElevenLabs_* components from metadata exports and version control (SFDX, Gearset, Copado). A leaked secret only lets someone make the agent re-read a Case already in its queue; to rotate it, remove and re-add the trigger.