Welcome to the official launch of my substack! My goal is to discuss real-world, useful applications of AI, especially to the world of CRM (and Enterprise applications in general). But not just discuss, but also to demonstrate how to do so in a way that gives you working examples you can leverage for your own needs. Also, I’ll try to add a bit of lightness to some pretty dry material, so please read the footnotes1.
It’s wonderful to see a lot of people playing with ChatGPT and concocting various prompts to make it do things, but it misleadingly makes it look like all you need is a bit of prompt engineering wizardry and anything is possible. But apart from selling courses on Udemy, prompt engineering only gets you so far without a lot of grunt work.
Google “CRM GPT”, and about 2/3rds of the hits are about Salesforce and the rest scattered across various topics. Much of this is forward looking. Nobody has great case studies with solid ROI numbers, because this is new to everybody. Which means we’re all getting in on the ground floor of the next generation of AI. As Alan Kay said, "The best way to predict the future is to invent it." So let’s invent it.
Inventing the future starts with laying down a foundation to build it on. Thus, for our first project2, we’re going to develop a working integration between Salesforce and OpenAI. We’ll retrieve and then display (in the Salesforce UI) the various models OpenAI has available to us. What’s nice is that this is a free and simple integration, allowing us to iron out the integration kinks before we attempt more complicated, and not-free, uses. We will end up with a bunch of reusable components that we will build on in subsequent weeks, but alas, this week’s emails are not going to impress the family.
Did you get a copy of this email from a friend? Why not subscribe for yourself?
Since this is a direct integration from Salesforce to OpenAI, you might ask yourself, “self, why not use Salesforce’s Einstein GPT?” And if that’s the right solution for you, you should absolutely use it. Whatever you do with it will be immensely simpler than what we’re about to attempt to do over the coming weeks.
If, on the other hand, you want to see how all the moving pieces work and truly understand what’s going on, come along on this adventure with me! I find that when things are designed to work magically, you’re at a disadvantage when they don’t work: magicians who can fix things are always in terrible short supply. Much, much better to learn the magic ourselves.
Project Overview
This first project is just to get the mechanics of an integration with Open AI working. We are going to call an end-point that lists the models available. This is an endpoint that has no fees associated with it; so we can debug the heck out of it without accidentally running up some charges.
The project involves the following steps:
Setting up the Prerequisites (If you don’t have them already)
Security Discussion … Yeah, we need to talk
In Part 2 of this project, we will continue with:Building a Demo-caliber Integration Procedure
Displaying the list of OpenAI models in FlexCards.
In subsequent projects we’ll look at how to take this beyond a simple demo, both in terms of adopting integration best practices as well as doing something that is a lot more impressive!
Prerequisites
Before we start, you will need:
A Salesforce org, with OmniStudio, that you can play with, and
A developer account with OpenAI so you have an API key to use.
I’m also assuming you’re comfortable with these technologies, at least enough to follow step-by-step guidance.
If you don’t have one or both of them, here’s how to get them:
Getting a Salesforce Org
There are many different ways to get an OmniStudio enabled Salesforce org you can play with, depending upon your relationship with Salesforce (employee, partner, customer, or, um, trailheader?). Regardless, you can get an OmniStudio enabled org with a 180-day lifespan for free here:
https://trailhead.salesforce.com/promo/orgs/omnistudiotrails
(The fact that it says Vlocity all over it makes my heart skip a beat)
Getting an OpenAI API Key
If you don’t have an Open AI platform account (ChatGPT plus or Dall-E does not count), go here to create one:
https://platform.openai.com/signup
During the process, you’ll need to set a usage limit. I picked $10, under the assumption that I’ll never go over it when playing with it but if I do something’s gone terribly wrong. Hopefully, you won’t even have to go over the free credits they give you.
Make sure you pick an amount you are comfortable with. You never know who might take a liking to your project and demo the heck out of it.
You will get a key from Open AI that looks like:
(with lots of other characters that aren’t blurred)
Make sure you save your API key somewhere because you only get shown it once. If you forget it, you’ll have to generate a new key. That’s not a big inconvenience, unless you excel at losing it.
At the time of this writing, GPT-4 is under a limited beta; even though it won’t be necessary for this project you might as well go ahead and sign-up for it now:
https://openai.com/waitlist/gpt-4
(It only took a few days for me to clear the waitlist.) You know that somebody is going to ask what version of GPT is in the demo, and you will want to answer that you’re using the new hotness, not last month’s hotness. Not that they could tell, of course3.
Also, go ahead and get on the waitlist for plug-ins:
https://openai.com/waitlist/plugins
At the time of this writing, I haven’t cleared this list, but I’m fairly certain that plugins are going to play a huge role in integrating GPT back into source data like CRM4. Hopefully we all clear soon and can build some really interesting stuff.
Security Discussion
You have your Salesforce org with OmniStudio! You have an OpenAI API key! Now you can make calls from Salesforce to OpenAI using that key and unlock the wonders of AI!
Unfortunately, if someone manages to steal your key, they too can unlock the wonders of AI, all on your dime. And leaking OpenAI keys is a big, big problem, mostly because people don’t think about security (enough). (See here, here, and here for examples of different ways keys have leaked.)
The absolutely worst thing you can do is make an HTTP call from the browser to OpenAI. This will make it super easy (barely an inconvenience!) for an unknown malicious user to grab your key and run up your tab5.
Of course you will say, “mais non, I would never do that!” Not intentionally, perhaps, but it's seductively trivial to use e.g. OmniScript to make the call and, perhaps, not realize that this is being made directly from the browser6.
Quite a bit better is to make the call directly from the server so the API key never touches the browser. That's why we're going to use an Integration Procedure instead7 in this project. True, the co-worker who thinks your yogurt in the fridge is up for grabs could still find your key and use it without asking, but a bit of vigorous hand slapping should fix that8.
The absolute best way is to use a Named Credential which can hold and hide your key for you. There’s a bit of setup involved in that, and so we’re going to tackle that in another post after we get everything else working in this one. For now, we’re going with “Quite a bit better” and later we’ll aim for best.
At this point, you’re ready to build something tangible, and in Part 2 on Thursday, we’ll build an Integration Procedure and FlexCards to display the list of models to the user.
A prompt engineer walks into a bar and the bartender says “What’ll ya have?” The prompt engineer replies “I don’t know, I need a few shots before I can answer!” Ba dum tssh
OK, OK, OK, you’re thinking “Charles, I didn’t sign up for work!” I hear you, but even if you don’t actually implement this project with me, reading along will give you a lovely patina of been-there-done-that experience that comes from a real understanding of the effort and complexity involved. And you can always come back when you need it.
Please don’t be one of those people who says “I have GPT-5!”, or who tries to pretend that your wrapper around GPT is somehow turbocharging it. That’s not just merely lame, we’re talking a Java Beans level of lameness here.
Here’s how they describe what plug-ins can do:
Plugins can allow ChatGPT to do things like:
Retrieve real-time information; e.g., sports scores, stock prices, the latest news, etc.
Retrieve knowledge-base information; e.g., company docs, personal notes, etc.
Perform actions on behalf of the user; e.g., booking a flight, ordering food, etc.
A $10 tab, though, if you set a limit like I told you.
The general rule is only call publicly available, free services from the browser. OpenAI isn’t, so don’t.
We could write custom Apex instead, although that’s more effort.
I of course do not advocate violence. Feel free to fantasize about it, though. Especially with regards to the yogurt problem.
A little late but this looks great, and highly relevant. I am giving the config a go!