Salesforce Collect Leads AI Action
In this guide, we will show you how to use an AI Custom Action to push new leads and the chat transcripts from Social Intents into Salesforce automatically when a chat is completed or when your qualification rules are met. Use AI intents to qualify and intelligently created leads right in Salesforce. No additional software or connectors needed.

What this Salesforce AI Integration Does
When your bot identifies a qualified visitor, it creates a Lead in Salesforce and includes the chat transcript. You can implement this two ways: Web-to-Lead (simplest) or the Salesforce REST API (recommended for scale and richer records such as Tasks or Files).
Prerequisites
- Social Intents account with AI Actions.
- For Web-to-Lead: your Salesforce Org ID.
- For REST API: a Salesforce Connected App and an access token (e.g., via Client Credentials or JWT). Store the token in Social Intents as a secret.
Data You’ll Collect From the Chat
Configure your AI to capture: first name, last name, email, phone, company, and optional context like page URL or campaign. The transcript can be sent as a description, attached as a Task, or uploaded as a File with the REST option.
Add a Custom Action in Social Intents
Create a new Custom Action → Call API Request. Give it a descriptive name (e.g., create_salesforce_lead) and define when to trigger (e.g., on chat end).
Option A — Web-to-Lead (fastest setup)
- Action Type: Auto Trigger on Chat End
- API Method: POST
- Endpoint URL:
https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8 - Content Type:
application/x-www-form-urlencoded - Required fields:
oid(Org Id) and eitherlast_nameorcompany
POST https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8
Content-Type: application/x-www-form-urlencoded
oid=YOUR_ORG_ID
&last_name={{lastName}}
&first_name={{firstName}}
&email={{email}}
&phone={{phone}}
&company={{company|Website Visitor}}
&lead_source=Chat
&description={{transcript}}
Use this when you want a quick, no-auth integration. If you need to exceed daily Web-to-Lead limits or attach richer records, use Option B.
Option B — Salesforce REST API (recommended)
Create the Lead via REST, then optionally add the transcript as a Task (simple and searchable) or upload it as a File. Add an Authorization header with your Bearer token and set Content-Type to application/json.
B1) Create Lead
POST https://YOUR_INSTANCE.salesforce.com/services/data/v60.0/sobjects/Lead
Authorization: Bearer {{secrets.salesforceAccessToken}}
Content-Type: application/json
{
"LastName": "{{lastName}}",
"FirstName": "{{firstName}}",
"Company": "{{company|Website Visitor}}",
"Email": "{{email}}",
"Phone": "{{phone}}",
"LeadSource": "Chat",
"Description": "Chat ended on {{endedAt}} via {{widgetName}}"
}
B2) Attach transcript as a Task
POST https://YOUR_INSTANCE.salesforce.com/services/data/v60.0/sobjects/Task
Authorization: Bearer {{secrets.salesforceAccessToken}}
Content-Type: application/json
{
"WhoId": "{{tools.createLead.id}}",
"Subject": "Chat Transcript",
"Status": "Completed",
"Priority": "Normal",
"Description": "{{transcript}}"
}
B3) (Optional) Upload transcript as a File
POST https://YOUR_INSTANCE.salesforce.com/services/data/v60.0/sobjects/ContentVersion
Authorization: Bearer {{secrets.salesforceAccessToken}}
Content-Type: application/json
{
"Title": "Chat_Transcript_{{chatId}}",
"PathOnClient": "transcript_{{chatId}}.txt",
"VersionData": "{{base64(transcript)}}"
}
POST https://YOUR_INSTANCE.salesforce.com/services/data/v60.0/sobjects/ContentDocumentLink
Authorization: Bearer {{secrets.salesforceAccessToken}}
Content-Type: application/json
{
"ContentDocumentId": "{{tools.uploadTranscript.ContentDocumentId}}",
"LinkedEntityId": "{{tools.createLead.id}}",
"ShareType": "V"
}
Recommended Social Intents Settings
- Trigger: When Chat Ends (or conditional based on lead qualification).
- Collect inputs:
firstName,lastName,email,phone,company,transcript,widgetName,endedAt. - Secrets: store
salesforceAccessToken(REST option). - For REST chaining: save the returned Lead
idfrom the first call and reference it in the second action via{{tools.createLead.id}}.
Use Case Examples
Always create a Lead on chat completion
Configure the action to run automatically when a chat ends so every conversation is captured in Salesforce with its transcript. This is the most foolproof setup for teams that want full chat-to-CRM coverage.
Social Intents settings
- Trigger: When chat ends
- Action name:
create_salesforce_lead - Collected inputs:
firstName,lastName,email,phone,company,transcript,widgetName,endedAt - Secrets:
salesforceAccessToken(if using REST API)
Option A — Web-to-Lead (no auth)
Creates a Lead and stores the chat transcript in the Description field.
POST https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8
Content-Type: application/x-www-form-urlencoded
oid=YOUR_ORG_ID
&last_name={{lastName}}
&first_name={{firstName}}
&email={{email}}
&phone={{phone}}
&company={{company|Website Visitor}}
&lead_source=Chat
&description={{transcript}}
Tip: Add campaign_id=YOUR_CAMPAIGN_ID to attribute chats to campaigns.
Option B — REST API (recommended)
Create the Lead, then log the transcript as a completed Task for better activity tracking.
B1) Create Lead
POST https://YOUR_INSTANCE.salesforce.com/services/data/v60.0/sobjects/Lead
Authorization: Bearer {{secrets.salesforceAccessToken}}
Content-Type: application/json
{
"LastName": "{{lastName}}",
"FirstName": "{{firstName}}",
"Company": "{{company|Website Visitor}}",
"Email": "{{email}}",
"Phone": "{{phone}}",
"LeadSource": "Chat",
"Description": "Chat ended on {{endedAt}} via {{widgetName}}"
}
B2) Create Task with transcript
POST https://YOUR_INSTANCE.salesforce.com/services/data/v60.0/sobjects/Task
Authorization: Bearer {{secrets.salesforceAccessToken}}
Content-Type: application/json
{
"WhoId": "{{tools.createLead.id}}",
"Subject": "Chat Transcript",
"Status": "Completed",
"Priority": "Normal",
"Description": "{{transcript}}"
}
Optional enhancements
- Owner routing: Set
OwnerIdon the Lead (REST) based on region or product collected in chat. - De-duplication: Use Process/Flow or Matching Rules to merge Leads by email.
- Files instead of Description: Upload the transcript as a File via
ContentVersionand link it withContentDocumentLink.
Create a Lead only for qualified visitors
Add intent and qualification checks in your AI flow. Only trigger the action when the visitor matches your criteria (e.g., budget >= threshold, company size, territory, demo intent, work email, etc.).
Qualification logic (example)
In your bot flow, gather fields like useCase, companySize, country, email, and intent.
Then set a condition to run the Salesforce action only when rules are met.
// Pseudocode for your bot's conditional action
IF intent == "book_demo"
AND companySize >= 50
AND email CONTAINS "@"
AND NOT email ENDSWITH ".edu" OR ".gmail.com"
THEN run create_salesforce_lead
ELSE continue chat and offer resources
Web-to-Lead payload (only when qualified)
POST https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8
Content-Type: application/x-www-form-urlencoded
oid=YOUR_ORG_ID
&last_name={{lastName}}
&first_name={{firstName}}
&email={{email}}
&company={{company}}
&lead_source=Chat - Qualified
&description=Intent: {{intent}} | Use case: {{useCase}} | Size: {{companySize}} | Transcript: {{transcript}}
Consider adding hidden fields like utm_source, utm_campaign, or page_url for attribution.
REST API payloads (only when qualified)
B1) Create Lead with qualification fields
POST https://YOUR_INSTANCE.salesforce.com/services/data/v60.0/sobjects/Lead
Authorization: Bearer {{secrets.salesforceAccessToken}}
Content-Type: application/json
{
"LastName": "{{lastName}}",
"FirstName": "{{firstName}}",
"Company": "{{company}}",
"Email": "{{email}}",
"Phone": "{{phone}}",
"LeadSource": "Chat - Qualified",
"Description": "Intent={{intent}} | UseCase={{useCase}} | Size={{companySize}} | From={{pageUrl}}"
}
B2) Add transcript as Task (optional)
POST https://YOUR_INSTANCE.salesforce.com/services/data/v60.0/sobjects/Task
Authorization: Bearer {{secrets.salesforceAccessToken}}
Content-Type: application/json
{
"WhoId": "{{tools.createLead.id}}",
"Subject": "Qualified Chat Transcript",
"Status": "Completed",
"Priority": "Normal",
"Description": "{{transcript}}"
}
Optional: route & scoring
- Territory routing: Set
OwnerIdby country/region collected in chat. - MQL scoring: Include a
Chat_Score__ccustom field derived from intent/size/keywords. - Product interest: Capture
Product__c(e.g., “Service Cloud”) from the conversation for reporting and cadences.
- Test both a qualified and a non-qualified path.
- Verify Leads are created only when rules match.
- Confirm transcript content appears (Task or Description).
- Ensure any owner/assignment or campaign linkage works as expected.