Salesforce
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
Setup
This integration uses Salesforce OAuth 2.0 Client Credentials for authentication. You will need to create an External Client App in Salesforce.
Create an External Client App
- Log into your Salesforce org as an administrator
- Go to Setup > External Client App Manager
- Click New External Client App
- Fill in the External Client App Name (e.g.,
ElevenLabs Agents), API Name, and Contact Email - 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
- Click Create
- On the app page, open the Settings tab, go to OAuth Settings, and click Consumer Key and Secret
- Copy the Consumer Key and Consumer Secret — you will need these for authentication
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.
- In your External Client App, click Edit
- Check Enable Client Credentials Flow — a Run As field will appear
- 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
- Set Permitted Users to Admin approved users are pre-authorized
- 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.
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)
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.
How it works
High-level overview
Detailed system prompt
Initial customer inquiry
The agent gathers customer information and asks relevant questions to identify their business requirements and current challenges.
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.
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
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:
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.
salesforce_search_records
salesforce_get_record
salesforce_create_record
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:
Common Salesforce objects
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
Search for leads by email or phone
Search for accounts by name
Search for recent opportunities
Search for opportunities by account
Integration testing
After setting up your External Client App and connecting the integration, test it before deploying to production:
- Search functionality: Ask your agent to search for existing contacts.
- Record creation: Have your agent create a new lead or contact.
- 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 (itsToaddress), 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):
- In Setup > Flows, deactivate and delete
ElevenLabs_Case_Flow_<id>,ElevenLabs_Email_Flow_<id>andElevenLabs_Comment_Flow_<id>. - Delete the Apex classes
ElevenLabs_Webhook_<id>,ElevenLabs_EmailReply_<id>andElevenLabs_Test_<id>. Production orgs don’t allow deleting Apex in Setup, so use a destructive deployment (Salesforce CLI or your release tool). - 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. ExcludeElevenLabs_*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.