How to Integrate Salesforce with OpenAI's ChatGPT
Salesforce

How to Integrate Salesforce with OpenAI's ChatGPT

Intellectual Clouds Team
June 10, 2026

A comprehensive guide on connecting Salesforce to OpenAI to generate emails, summarize cases, and build custom AI agents.

How to Integrate Salesforce with OpenAI's ChatGPT

Direct Answer: To integrate Salesforce with OpenAI's ChatGPT, you can either write custom Apex code to make direct HTTP callouts to the OpenAI API, use low-code middleware platforms like Zapier or Make.com, or utilize Salesforce's native Einstein Copilot Studio which allows you to bring your own LLM (BYOLLM) and integrate external models securely.

By Intellectual Clouds Team | Last Updated: June 10, 2026

Why Connect Salesforce to OpenAI?

While Salesforce stores your data beautifully, it has historically lacked the ability to generate human-like reasoning based on that data. By connecting OpenAI's API, you can transform Salesforce from a static database into a proactive AI Workflow Engine.

3 Methods for Integration

| Method | Pros | Cons | Best For | | :--- | :--- | :--- | :--- | | Apex Callouts | Highest control, no subscription costs | Requires developer skills | Enterprise custom apps | | Middleware (Make.com)| Fast setup, low code | Extra monthly software cost | Rapid prototyping | | Einstein Copilot | Native UI, highly secure | Requires specific Salesforce licensing | Strict compliance environments |

Step-by-Step Process: Custom Apex Method

If you want to build a custom solution, here is the technical approach:

  1. Obtain API Keys: Create an account on the OpenAI developer platform and generate a secure API Key.
  2. Configure Remote Site Settings: In Salesforce, go to Remote Site Settings and add https://api.openai.com so Salesforce permits outbound traffic to that URL.
  3. Write the Apex Class: Create an Apex class that formats a JSON payload (containing your prompt) and makes an HTTP POST request to the v1/chat/completions endpoint.
  4. Parse the Response: Deserialize the JSON response from OpenAI and extract the generated text.
  5. Create a Flow or LWC: Build a Screen Flow or Lightning Web Component with a button that triggers the Apex class, displaying the AI's response to the user.

Real Example

For a high-volume customer support center, we built a Generative AI Solution within Salesforce. When a support agent opens a Case containing 30 back-and-forth emails, they click a "Summarize" button. An Apex callout sends the email chain to OpenAI, which returns a 3-bullet-point summary and drafts a suggested response, cutting case handling time by 50%.

Frequently Asked Questions

1. Will my Salesforce data be used to train ChatGPT?

If you use OpenAI's paid API (not the free web interface), OpenAI explicitly states they do not use your API data to train their foundational models. However, you should still avoid sending PII (Personally Identifiable Information) unless necessary.

2. Can I use Anthropic's Claude instead of ChatGPT?

Yes. The integration architecture is identical; you simply change the endpoint URL to Anthropic's API and adjust the JSON payload format.

3. How much does this integration cost?

You pay OpenAI based on "tokens" (essentially word count). For tasks like summarizing cases, it usually costs a fraction of a cent per request.

4. What is Prompt Engineering in Salesforce?

Prompt engineering involves dynamically combining Salesforce merge fields (like {!Lead.Name} and {!Lead.Industry}) into the text prompt you send to the AI to ensure highly contextual outputs.

5. Can you build this for us?

Yes. Our Custom AI Solutions team has pre-built frameworks for safely integrating LLMs directly into Salesforce orgs.

Share this article: