Short answer
There are three common ways to use OpenAI models with a CRM: call the API from a HubSpot workflow custom code action, bring an OpenAI model into Salesforce through Agentforce's model options, or run your own service that reads the CRM, calls the API and writes back. Pick by who maintains it, how much volume it handles and where you need the audit trail.
Pattern 1: HubSpot custom code actions
A workflow step runs a short Node.js or Python function that calls the OpenAI API, for example to classify an inbound inquiry or summarize a form submission, then writes the result to a property.
- Needs: a HubSpot subscription that includes custom code actions (Data Hub Professional or higher, formerly Operations Hub).
- Store the API key as a secret in the action, never in the code.
- Good for: low to moderate volume, admin-maintained automation.
- Watch: execution time limits and API rate limits; add retries and a fallback value.
Pattern 2: OpenAI models inside Salesforce
Agentforce and Einstein features run through the Einstein Trust Layer, and Salesforce lets you choose or bring certain models, including OpenAI models, through its model management tools. This keeps prompts, grounding and audit inside Salesforce.
- Good for: agents and prompt templates that should respect Salesforce sharing and appear in Salesforce's audit trail.
- Watch: which models and regions your edition supports, and the Flex Credits or other usage charges.
Pattern 3: Your own integration service
A small service (for example on AWS, Azure or Vercel, or in MuleSoft) reads records through the CRM API, calls OpenAI, and writes results back.
- Good for: high volume, batch jobs, logic that spans several systems, or strict logging needs.
- Watch: it's software you own. Plan monitoring, secrets rotation and an owner.
Rules for all three
- Write AI output to its own field or note, labeled as AI-generated, not over a human-entered value.
- Keep a person in the loop for anything sent to a client.
- Send only the fields the task needs, and mask identifiers you don't need.
- Log the prompt version, model and timestamp with each result.
Official documentation
Frequently asked questions
Can a HubSpot workflow call the OpenAI API?
Yes, through a custom code action, which needs Data Hub (formerly Operations Hub) Professional or higher. Store the OpenAI key as a secret in the action and write the result to a HubSpot property.
Can Agentforce use OpenAI models?
Salesforce supports OpenAI models among the models available to Agentforce and its generative AI features, managed through the Einstein Trust Layer. Check which models your edition and region support.
Salesforce, HubSpot, Anthropic and OpenAI change their products often. Check the official documentation before you rely on a specific setting, limit or price.
