TL;DR
- HubSpot now has a native "Use a custom LLM" workflow action. You connect your own API key for OpenAI, Anthropic (Claude), Cohere, xAI (Grok) or Google (Gemini). It requires an Enterprise subscription (HubSpot KB).
- Without Enterprise, or for multi-step processing such as documents, run the AI step in n8n or Make (or your own service) and write results back to HubSpot.
- The guardrail that matters most: make the model return structured data. OpenAI's Structured Outputs enforces a JSON Schema you supply (OpenAI Docs).
- Keep a human in the loop for anything that changes money, ownership or lifecycle stage.
What "AI in the CRM" should mean
Most AI experiments in CRMs fail the same way: a model writes free text into a property, nobody trusts it, and it's quietly turned off.
The automations that survive share three traits:
- A narrow job. Classify, extract or summarise, not "be smart".
- A structured result. A picklist value, a number or a date that HubSpot can filter, report and branch on.
- A clear owner for mistakes. A person reviews low-confidence results, or everything that matters.
Good first use cases
- Classify inbound requests. Route a form message to the right pipeline or team.
- Extract fields from documents. Pull dates, amounts and parties from a contract into properties.
- Summarise activity. Write a short summary of a record's recent notes for the owner.
- Normalise messy data. Map free-text job titles or industries to your picklists.
A real example: contract processing
My portfolio includes AI Contract Processing for HubSpot Deals, built with n8n, HubSpot, OpenAI (o1-mini) and JavaScript. Document work like this, where a file goes in, fields come out and land on a deal, is a typical case for running the AI step in an automation tool rather than in a single workflow action. The options below explain why.
Option A — HubSpot's native "Use a custom LLM" action
What it does. Inside a workflow, you pick a connected LLM provider and model, write a prompt, and use the response in later steps. HubSpot's own examples include summarising record information, classifying incoming data and generating personalised content (HubSpot KB).
Requirements.
- An Enterprise subscription of Marketing, Sales, Service, Data, Content, Smart CRM or Revenue Hub.
- An API key from your LLM provider. For OpenAI, HubSpot notes that a user with the owner role in the OpenAI account must retrieve it. Keep the key secure.
Best for. Single-step classify, summarise or generate tasks on records already in HubSpot.
Option B — Custom code action calling OpenAI
If you have Data Hub Professional or Enterprise, a custom code action can call an LLM API directly (HubSpot Developers).
The catch: the action must finish within 20 seconds. LLM calls on long inputs can exceed that. Keep inputs short, or use Option C. String outputs are capped at 65,000 characters.
Option C — n8n or Make (or your own service)
For documents, multi-step chains or retries with review, run the AI work outside HubSpot:
- n8n has an OpenAI node and a HubSpot node, plus an HTTP Request node for any API call the nodes don't cover (n8n Docs — HubSpot node).
- n8n error workflows catch failures so they don't disappear silently (n8n Docs — error handling).
- Make offers the same pattern with its HubSpot CRM app (Make Apps Documentation).
Best for. Document processing, anything over the 20-second window, and teams without Enterprise or Data Hub Pro.
Technical depth: structured outputs
The single best reliability upgrade is to stop parsing free text. With OpenAI's Structured Outputs, the model's response adheres to your JSON Schema, so it doesn't omit required keys or invent enum values. Safety refusals become programmatically detectable (OpenAI Docs).
The shape of a Responses API request, following OpenAI's documented format:
curl https://api.openai.com/v1/responses \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "<MODEL_THAT_SUPPORTS_STRUCTURED_OUTPUTS>",
"input": [
{ "role": "system", "content": "Classify the inbound request." },
{ "role": "user", "content": "<form message text>" }
],
"text": {
"format": {
"type": "json_schema",
"name": "request_classification",
"strict": true,
"schema": {
"type": "object",
"properties": {
"category": { "type": "string", "enum": ["integration", "automation", "cms", "audit", "other"] },
"confidence": { "type": "number" }
},
"required": ["category", "confidence"],
"additionalProperties": false
}
}
}
}'
Model support varies, so check the Structured Outputs guide for which models support json_schema. JSON mode (json_object) produces valid JSON, but only Structured Outputs guarantees schema adherence.
Map the schema to HubSpot properties
enumvalues ↔ the internal values of a dropdown property.- Numbers ↔ number properties.
- Dates ↔ date properties. When writing through workflow outputs, use UNIX milliseconds at midnight UTC for date-only fields (HubSpot Developers).
Then branch on the value in a workflow: confidence < 0.8 → create a review task; otherwise → set the property.
Guardrails that keep CRM data clean
- Write AI results to dedicated properties (for example,
ai_category,ai_summary), not the fields humans own. You can always copy a value over after review. - Store when and how each value was produced (date and model) so you can audit and re-run.
- Never let AI change lifecycle stage, owner or amount without human approval.
- Mind API limits. AI flows often loop over many records. HubSpot's limits apply to every call, and batch endpoints help (HubSpot usage guidelines).
- Protect keys. Store them as HubSpot secrets or credentials in n8n or Make, never in a property or a page.
- Start with one workflow. Measure how often humans correct it before adding more.
Choosing quickly
| Situation | Use |
|---|---|
| Enterprise portal, single-step task on a HubSpot record | Native "Use a custom LLM" action |
| Data Hub Pro, short inputs, need custom logic | Custom code action (≤20 s) |
| Documents, long inputs, multi-step, any plan | n8n / Make / own service |
Sources
- HubSpot KB — Connect an LLM provider (Use a custom LLM action): https://knowledge.hubspot.com/integrations/connect-your-openai-account-to-hubspot
- HubSpot Developers — Custom code actions: https://developers.hubspot.com/docs/api-reference/latest/automation/workflow-actions/custom-code-actions
- HubSpot Developers — Usage guidelines: https://developers.hubspot.com/docs/developer-tooling/platform/usage-guidelines
- OpenAI Docs — Structured Outputs: https://platform.openai.com/docs/guides/structured-outputs
- n8n Docs — HubSpot node: https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.hubspot/
- n8n Docs — Error handling: https://docs.n8n.io/flow-logic/error-handling/
- Make Apps Documentation — HubSpot CRM: https://apps.make.com/hubspotcrm
FAQ
Can HubSpot workflows call OpenAI natively? Yes, through the "Use a custom LLM" action, which requires an Enterprise subscription and your own provider API key.
Which AI providers does HubSpot's custom LLM action support? OpenAI, Anthropic (Claude), Cohere, xAI (Grok) and Google (Gemini), per HubSpot's KB.
How do I stop AI from writing messy data into HubSpot? Use Structured Outputs with a JSON Schema whose enums match your property values. Write to dedicated AI properties, and review low-confidence results.
Why run AI in n8n instead of HubSpot? For documents, long inputs and multi-step flows. HubSpot custom code actions must finish within 20 seconds.