HubSpot Collect Leads AI Action
Use the following AI Custom Action to push new leads directly into HubSpot when a chat starts or is complete. This guide shows you how to collect lead or contact fields in the chat then pass them directly to HubSpot’s Contact API either when a chat starts, ends, or based on lead qualification criteria.
What this Hubspot AI Integration Does
When your bot identifies a qualified visitor, it calls HubSpot’s Contacts or Leads API with the visitor’s details and transcript information. The result is a new or updated Contact record in HubSpot without leaving the chat. You can automatically trigger the contact or lead creation when a chat is completed or based on your lead qualification rules you set up in your AI Chatbot.
Prerequisites
You’ll need a HubSpot account and a Private App with scopes that allow creating contacts or leads (for most setups: crm.objects.leads.write; if you instead create Contacts, use crm.objects.contacts.write). Copy the access token from your Private App. You will use this as your Authorization Bearer token header in the Custom Action settings.
Data You’ll Collect From the Chat
Configure your AI action to collect fields like: email, first name, last name, phone, company, and any campaign or channel info you want to track (e.g., channel, campaign, pageUrl). These become variables in your Custom Action body (e.g., {{email}}).
Add a Custom Action in Social Intents
Create a new Custom Action → Call API Request. Give it a descriptive name (e.g., create_hubspot_lead) and write a short “When to use” description (for example, “When a visitor asks to be contacted or requests a demo”).
API Configuration
- Action Type: Auto Trigger on Chat End
- Action Name: A descriptive name like create_hubspot_lead
- When to use: Example: “This action is triggered when a chat is completed.”
- Triggered response: Example: “Sure, let me look up the weather for you.”
- Collect data inputs for action: Any parameters on the request like firstname, lastname, email, transcript
- API request: The endpoint URL in our case we are creating or updating leads (e.g.
https://api.hubapi.com/crm/v3/objects/contacts/batch/upsert
- API Method: Choose POST.
- Request Headers: Add an Authorization header with a header value of "Bearer pat-****". This is your API token you generate in Hubspot.
- Request JSON template:
{ "inputs": [ { "idProperty":"email", "id":"{{email}}", "properties": { "firstname": "{{firstName}}", "lastname": "{{lastName}}", "email": "{{email}}", "si_transcript": "{{transcript}}" } } ] }
Here is what your Custom Action details will look like in Social Intents. This configuration will send the lead data as well as the transcript to Hubspot
Use Case Examples
Create a Contact in Hubspot when a chat is completed
This custom action will always trigger as soon as a live chat conversation ends so you always have your chat transcripts pushed over to Hubspot. You can alternately set up the Custom Action to trigger based on qualification criteria within the context of your AI chat.