Campfire Solutions home
← All resources

AI in Salesforce

How to connect ChatGPT to Salesforce Flow

Updated September 24, 2026

Everyone is working out what AI can actually do inside their daily workflows. Drafting emails is the obvious one. But once ChatGPT is connected to Salesforce Flow, it can sit inside any process you automate, reading your data and writing results back to records.

This guide covers how to set up the connection. To see what you can do with it, read Leveraging AI for process automation, with three real use cases and demos.

How the connection works

Flow can call an outside API directly with an HTTP Callout action, with no Apex required. The pieces:

  1. An OpenAI API key. Create one in your OpenAI account, and set a monthly spending limit there so a runaway flow can't run up a bill.
  2. An External Credential in Setup that stores the key securely. Use the Custom authentication protocol, add a principal with an ApiKey parameter, and add a custom header that sends it:
Authorization: {!'Bearer ' & $Credential.OpenAI.ApiKey}
  1. A Named Credential pointing to https://api.openai.com that uses the External Credential. The key never appears in your flow.
  2. A permission set that grants access to the External Credential principal, assigned to the users (or the automated process user) that run the flow.
  3. An HTTP Callout action in Flow Builder that uses the Named Credential and posts to the chat completions endpoint. You give Flow a sample request and response, and it generates typed variables you can use in the rest of the flow.

A sample request, here asking the model to classify a job title:

POST /v1/chat/completions

{
  "model": "<your chosen model>",
  "temperature": 0.2,
  "max_tokens": 300,
  "messages": [
    { "role": "system", "content": "Classify job titles. Reply with JSON only." },
    { "role": "user",   "content": "Title: VP, Global Revenue Operations" }
  ]
}

And the part of the response your flow reads:

{
  "choices": [
    { "message": { "role": "assistant",
                   "content": "{\"function\": \"Operations\", \"level\": \"VP\"}" } }
  ],
  "usage": { "prompt_tokens": 31, "completion_tokens": 14 }
}

The answer is in choices[0].message.content. Asking for JSON, as above, makes it easy to split the answer into separate fields on the record.

Build it to last

Where to start

Pick one repetitive task where people currently read something and make a judgment: classifying, summarizing, cleaning up data, or drafting a first response. Those are where AI in your workflow pays off fastest. For ideas, see three use cases we have built.

We can connect ChatGPT to your Salesforce and build your first use case quickly, with logging and configurable prompts from day one. Book a free strategy session to talk it through.

Free · No obligation

Let's map your process.

Tell us how your business runs today and where you want to take it. You'll leave with a clear path to a Salesforce you can actually run - whether or not we work together.

Book your free strategy session