Blog › Buyer guide
Buyer guide

How to connect ChatGPT or Claude to Salesforce

Large language models like ChatGPT and Claude can draft emails, summarize cases and suggest next steps directly inside Salesforce. Here are the three main ways to connect them, how to keep your data safe, and a simple technical example.

By Kliper Solutions · 9 min read · Updated October 2026
Time9-minute read
DifficultyIntermediate (technical)
EditionsEnterprise, Unlimited, Developer
You needAn AI provider account and a Named Credential

Why connect AI to Salesforce

  • Sales: draft follow-up emails, summarize calls, suggest the next best action.
  • Service: summarize long case histories, classify and route cases, suggest replies.
  • Operations: extract data from documents and emails into the right fields.

Three ways to connect

OptionBest forTrade-offs
1. Agentforce (Salesforce’s AI platform)Teams that want AI agents managed inside Salesforce with built-in guardrailsRequires the right Salesforce licences; check which models are supported for your org
2. Apex callouts to the OpenAI or Anthropic APICustom actions such as a “Summarize case” button or an automated flow stepNeeds development and maintenance; you manage prompts and limits
3. Middleware (MuleSoft, Zapier, Make, custom services)Simple automations across several systemsData passes through a third party; less control inside Salesforce

Example: an Apex callout

A common pattern: store the API endpoint and key in a Named Credential (never in code), then call it from an invocable Apex method that Flow or a button can use. Simplified example for Claude:

public with sharing class CaseSummarizer {
  @InvocableMethod(label='Summarize case with AI')
  public static List<String> summarize(List<String> caseTexts) {
    HttpRequest req = new HttpRequest();
    req.setEndpoint('callout:Anthropic_API/v1/messages'); // Named Credential
    req.setMethod('POST');
    req.setHeader('content-type', 'application/json');
    req.setHeader('anthropic-version', '2023-06-01');
    Map<String, Object> body = new Map<String, Object>{
      'model' => 'YOUR_CLAUDE_MODEL',
      'max_tokens' => 400,
      'messages' => new List<Object>{ new Map<String, Object>{
        'role' => 'user',
        'content' => 'Summarize this support case in 3 bullet points: ' + caseTexts[0]
      }}
    };
    req.setBody(JSON.serialize(body));
    HttpResponse res = new Http().send(req);
    // Parse res.getBody() and return the summary text
    return new List<String>{ res.getBody() };
  }
}

The API key is added by the Named Credential’s external credential as a custom header, so it never appears in code. The same pattern works for OpenAI’s API with its own endpoint and headers.

Security and data protection

  • Respect permissions: only send data the running user is allowed to see.
  • Minimize and mask: send only the fields the task needs; mask personal or sensitive data.
  • Use business API terms: check each provider’s data-handling terms for API use.
  • Keep a human in the loop for anything customer-facing or high-impact.
  • Log and monitor usage, costs and errors.

Where to start

  1. Pick one repetitive, high-volume task (for example case summaries).
  2. Build a small proof of concept on your own data.
  3. Measure time saved and quality, then scale.

Learn more about our Salesforce AI integration services.

Free template

AI use-case scorecard
Score your AI ideas by value and ease to pick the best first proof of concept.
Download CSV

FAQ

How much does AI usage cost?

You pay the AI provider for what you use. A focused use case like case summaries is usually inexpensive; we estimate costs during the proof of concept.

Which model should we start with?

Start with a fast, cost-effective model for summaries and drafts, and test a more capable one for complex reasoning.

Can AI update Salesforce records automatically?

Yes, but we recommend a human approval step for anything customer-facing or high-impact.

Does this work with Agentforce?

Yes. Many teams combine Agentforce with direct ChatGPT or Claude integrations for specific tasks.

Troubleshooting

If this happensDo this
Salesforce blocks the request to the AI serviceUse a Named Credential for the AI endpoint so Salesforce trusts it.
The AI service rejects your keyCheck the key stored in the External Credential and that users have access through a permission set.
Responses take too longKeep prompts short, lower the maximum response length, and run longer jobs asynchronously.
Output is inconsistentGive clearer instructions, an example and a fixed output format in the prompt.
Want a working AI proof of concept?
Start with a free proof of concept. Daily stand-ups, and you pay only after delivery.
Get your free POC