Every chat conversation is an opportunity to capture a lead. When a visitor shares their name, email, company, or phone number during a chat, your AI chatbot can automatically create a contact or lead record in your CRM - no manual data entry, no copy-paste, no leads slipping through the cracks. Social Intents supports CRM lead capture through AI Actions that call the HubSpot, Salesforce, or Microsoft Dynamics 365 APIs directly from the chat. Below is the complete setup for all three CRM platforms.
How CRM Lead Capture Works
CRM lead capture uses the Call API Request action type. Here is the flow:
- During a conversation, the visitor shares information like their name and email address.
- The AI engine detects that the visitor's message matches the lead capture action's trigger (the When to use description).
- The AI checks the conversation history for the required data fields (email, name, company, etc.) defined in the action's Collect data inputs parameters.
- If any required data is missing, the AI conversationally asks the visitor for it.
- Once all required fields are collected, the action sends a POST request to your CRM's API endpoint, creating a new contact or lead record.
- The visitor sees a confirmation message (the Triggered response), such as "Thanks! I've saved your information."
The entire process happens naturally within the conversation. The visitor is not filling out a form - they are chatting. The AI extracts the relevant data and sends it to your CRM behind the scenes.
Prerequisites
Before setting up CRM lead capture, you need:
- A CRM account - An active HubSpot, Salesforce, or Microsoft Dynamics 365 account with API access.
- An API key or access token - You will need authentication credentials to call your CRM's API. The specific credential depends on the CRM platform (details in each platform section below).
- A Social Intents widget with AI chatbot enabled - Lead capture requires an AI chatbot to detect visitor intent and collect data conversationally. See Build Your First AI Chatbot.
HubSpot Setup
Step 1: Get Your HubSpot API Key
HubSpot uses private app access tokens for API authentication. To create one:
- Log in to your HubSpot account.
- Go to Settings → Integrations → Private Apps.
- Click Create a private app.
- Name it something like "Social Intents Lead Capture."
- Under Scopes, select crm.objects.contacts.write and crm.objects.contacts.read.
- Click Create app and copy the access token that is generated.
Step 2: Create the AI Action
Add a New Action
Go to My Widgets → select your widget → AI Actions → Add Action.
Select Call API Request
Choose Call API Request from the Action Type dropdown.
Name the Action
Enter Create_HubSpot_Contact as the action name.
Write the Trigger
In the When to use field, enter:
"Use this action when the visitor provides their email address and wants to be contacted, requests more information, asks to be added to a mailing list, signs up for updates, or provides their contact details for follow-up. Also trigger when the visitor explicitly asks to be connected with the sales team and provides their email."
Set the Triggered Response
Enter: "Thanks! I've saved your contact information. Our team will follow up with you shortly."
Configure the API Request
Set the following:
- HTTP Method: POST
- Endpoint URL:
https://api.hubapi.com/crm/v3/objects/contacts
Add Data Input Parameters
Click Add parameter to define the fields the AI should collect from the conversation:
| Name | Type | Description | Required |
|---|---|---|---|
| Text | The visitor's email address | Yes | |
| firstname | Text | The visitor's first name | Yes |
| lastname | Text | The visitor's last name | No |
| company | Text | The visitor's company or organization name | No |
| phone | Text | The visitor's phone number | No |
Set the Request JSON Template
Enter the following JSON body template:
{
"properties": {
"email": "{email}",
"firstname": "{firstname}",
"lastname": "{lastname}",
"company": "{company}",
"phone": "{phone}",
"lifecyclestage": "lead",
"hs_lead_status": "NEW",
"leadsource": "Live Chat"
}
}
The {email}, {firstname}, etc. placeholders are replaced with the actual values the AI collected from the conversation. You can add any additional HubSpot contact properties here - for example, lifecyclestage and leadsource are static values set to "lead" and "Live Chat" to tag contacts created from chat conversations.
Add Request Headers
Click Add header and add:
| Header Name | Header Value |
|---|---|
| Authorization | Bearer YOUR_HUBSPOT_ACCESS_TOKEN |
| Content-Type | application/json |
Replace YOUR_HUBSPOT_ACCESS_TOKEN with the private app access token you created in Step 1.
Save and Test
Click Save Action. Test by opening your chat widget and saying something like "Hi, I'd like to learn more. My name is Jane Smith and my email is jane@example.com." Verify the AI creates a contact in HubSpot with the correct details.
Salesforce Setup
Step 1: Get Salesforce API Credentials
Salesforce uses OAuth 2.0 for API authentication. For server-to-server integrations, use the Connected App flow with a security token:
- Log in to Salesforce Setup.
- Go to App Manager → New Connected App.
- Enable OAuth Settings and select the Full access (full) scope or Manage user data via APIs (api).
- Save and copy the Consumer Key and Consumer Secret.
- Use the Salesforce OAuth token endpoint to get an access token, or use your user's security token for direct API calls.
For simpler setups, you can also use the Salesforce username-password OAuth flow to generate a bearer token. Consult the Salesforce REST API documentation for details.
Step 2: Create the AI Action
Follow the same general process as HubSpot, with these Salesforce-specific settings:
- Action Name:
Create_Salesforce_Lead - HTTP Method: POST
- Endpoint URL:
https://YOUR_INSTANCE.salesforce.com/services/data/v58.0/sobjects/Lead/
Replace YOUR_INSTANCE with your Salesforce instance domain (e.g., na1, eu5, or your custom domain).
Data Input Parameters
| Name | Type | Description | Required |
|---|---|---|---|
| Text | The visitor's email address | Yes | |
| FirstName | Text | The visitor's first name | No |
| LastName | Text | The visitor's last name | Yes |
| Company | Text | The visitor's company name | Yes |
| Phone | Text | The visitor's phone number | No |
Request JSON Template
{
"Email": "{Email}",
"FirstName": "{FirstName}",
"LastName": "{LastName}",
"Company": "{Company}",
"Phone": "{Phone}",
"LeadSource": "Live Chat",
"Status": "New"
}
Request Headers
| Header Name | Header Value |
|---|---|
| Authorization | Bearer YOUR_SALESFORCE_ACCESS_TOKEN |
| Content-Type | application/json |
Microsoft Dynamics 365 Setup
Step 1: Get Dynamics 365 API Credentials
Dynamics 365 uses Azure Active Directory (Azure AD) for authentication. To set up API access:
- Go to the Azure Portal → Azure Active Directory → App registrations.
- Click New registration and name the app "Social Intents Lead Capture."
- Under API permissions, add Dynamics CRM → user_impersonation.
- Create a client secret under Certificates & secrets.
- Use the client credentials flow to obtain an access token. The token endpoint is
https://login.microsoftonline.com/YOUR_TENANT_ID/oauth2/v2.0/token.
Step 2: Create the AI Action
- Action Name:
Create_Dynamics_Lead - HTTP Method: POST
- Endpoint URL:
https://YOUR_ORG.crm.dynamics.com/api/data/v9.2/leads
Replace YOUR_ORG with your Dynamics 365 organization URL.
Data Input Parameters
| Name | Type | Description | Required |
|---|---|---|---|
| emailaddress1 | Text | The visitor's email address | Yes |
| firstname | Text | The visitor's first name | No |
| lastname | Text | The visitor's last name | Yes |
| companyname | Text | The visitor's company name | No |
| telephone1 | Text | The visitor's phone number | No |
Request JSON Template
{
"emailaddress1": "{emailaddress1}",
"firstname": "{firstname}",
"lastname": "{lastname}",
"companyname": "{companyname}",
"telephone1": "{telephone1}",
"leadsourcecode": 8,
"subject": "Live Chat Lead"
}
Request Headers
| Header Name | Header Value |
|---|---|
| Authorization | Bearer YOUR_DYNAMICS_ACCESS_TOKEN |
| Content-Type | application/json |
| OData-MaxVersion | 4.0 |
| OData-Version | 4.0 |
Writing Effective Trigger Descriptions
The trigger description determines when the lead capture action fires. Here are examples for different scenarios:
General Lead Capture
"Use this action when the visitor provides their email address and wants to be contacted for follow-up. Trigger when the visitor asks to receive more information, sign up for updates, or requests that their contact details be saved. Also trigger when the visitor says they want to hear from the team."
Demo Request Lead Capture
"Use this action when the visitor requests a product demo or trial and provides their email. Only trigger if the visitor explicitly shares their email address - do not ask for it unprompted unless they have expressed interest in being contacted."
Newsletter Signup
"Use this action when the visitor wants to subscribe to the newsletter, receive email updates, or join the mailing list. Collect their email address and first name."
Handling Duplicate Contacts
Each CRM platform handles duplicates differently:
HubSpot
HubSpot automatically deduplicates contacts by email address. If a POST request creates a contact with an email that already exists, HubSpot returns an error with status code 409 (Conflict). The contact will not be duplicated. To update an existing contact instead of creating a new one, use the HubSpot batch upsert endpoint or the PATCH method on the specific contact.
Salesforce
Salesforce does not automatically deduplicate Leads. A POST request creates a new Lead even if a Lead with the same email already exists. To avoid duplicates, you can use Salesforce's upsert endpoint with an external ID field, or create a Salesforce duplicate rule that catches duplicates on the Salesforce side.
Dynamics 365
Dynamics 365 does not automatically prevent duplicate leads. Use Dynamics' built-in duplicate detection rules to catch duplicates, or use the PATCH method targeting an existing record by alternate key.
Adding Custom Fields
You can capture and send any custom CRM fields by adding them to both the data input parameters and the request JSON template. For example, to capture the visitor's job title in HubSpot:
- Add a new parameter: Name =
jobtitle, Type = Text, Description = "The visitor's job title or role", Required = No. - Add the field to the JSON template:
"jobtitle": "{jobtitle}"
For Salesforce, use the API field name (e.g., Title for job title). For Dynamics 365, use the schema name (e.g., jobtitle). Check your CRM's API documentation for the exact field names.
Combining with Other Actions
CRM lead capture pairs naturally with other action types:
- Calendly booking + lead capture - Capture the lead in your CRM, then show the calendar for scheduling. The visitor's contact record exists before the meeting even starts.
- Escalation routing + lead capture - Capture the lead first, then route the chat to the appropriate team. Agents can see the CRM record before they start the conversation.
- Auto-trigger on escalation + lead capture - Use the Auto Trigger on Chat Escalation action type to automatically create a CRM lead whenever the chatbot hands off to a human, without requiring a specific trigger phrase.
Troubleshooting
Lead is not created in the CRM
Check the following:
- Verify the API endpoint URL is correct and includes the correct API version.
- Verify the access token or API key is valid and not expired.
- Check that the Content-Type header is set to
application/json. - Verify all required CRM fields are included in the JSON template (e.g., Salesforce requires LastName and Company for Leads).
- Check your CRM's API error logs for detailed error messages.
AI does not collect the required fields
Make sure the data input parameters have clear descriptions. The AI uses the description field to understand what to ask for and how to extract it from the conversation. "The visitor's email address" is more helpful than just "email."
Action fires too often or not often enough
Adjust the trigger description. Too broad: add more specific intent signals. Too narrow: add more trigger phrases. Use Trigger only once per session to prevent duplicate CRM records from the same conversation.
Frequently Asked Questions
Can I capture leads into multiple CRMs simultaneously?
Yes. Create a separate Call API Request action for each CRM. Each action has its own endpoint, headers, and JSON template. The same conversation can trigger both - the AI collects the data once and sends it to both CRMs.
What if the visitor does not share all the required fields?
The AI asks for missing required fields before executing the action. If a visitor provides their email but you also require first name, the AI will ask "What is your first name?" before sending the API request. Optional fields are sent if available but do not block the action.
Can I use Zapier instead of direct API calls?
Yes. Create a Zapier webhook trigger, copy the webhook URL, and use it as the endpoint URL in your Call API Request action. Zapier receives the data and can route it to any CRM or tool in the Zapier ecosystem. This is a good approach if your CRM's direct API is complex to set up.
Are API tokens stored securely?
API tokens entered in the request headers configuration are stored on the Social Intents server and are never exposed to visitors or in client-side code. They are used only when the server executes the API call on behalf of the action.
Does this work with CRM sandbox environments?
Yes. Use your sandbox API endpoint and sandbox credentials during testing. Once verified, switch to production endpoints and credentials. This is the recommended approach for testing CRM integrations without creating test records in your live CRM.
What to Read Next
- What Are AI Actions? - Overview of all action types.
- Custom API Actions - Build API integrations beyond CRM lead capture.
- Booking Meetings with Calendly - Combine lead capture with meeting booking.
- Escalation Routing - Route conversations to specific teams after capturing leads.