Integrating Salesforce and Operational Systems into ChatGPT: A Practical Guide

February 2, 2024
Using ChatGPT with Salesforce
Experience automated API building for yourself!
Start for free today.
No credit card required

Imagine you have an advisor available around the clock, skilled in providing insights about your company’s sales, products, and customers. This advisor could analyze customer feedback on demand and recommend product enhancements. It could also inform a salesperson on everything they need to know before visiting a customer, all live based on the latest issues or feedback given that day. The advent of advanced model technologies like ChatGPT makes this possible. However, one crucial step remains: integrating your operational systems that hold all this knowledge with these systems.

In the past, we discussed some fundamental principles for successfully integrating real-time data from operational systems - the "beating heart" of your company! - with LLMs. One critical insight we underlined was the importance of operational data. As we stated then:

Operational data is where novel insights are to be found; that's where we should expect to discover the new insights that never made it to a quarterly report document or presentation. You need to tap into operational systems in real-time to find those.

This article turns those thoughts into a practice implementation with a step-by-step guide. If it's your first time reading about integrating operational data with LLMs, consider reading our high-level guide first.

Building our first LLM-based sales advisor

Our goal is to build a 'sales advisor.' This advisor should be aware of our products, who our customers are, what feedback they have given us, and revenue information per customer. We could add more, but this is a good start.

For the sake of this guide, let's make a few assumptions. First, let' assume that some of our critical operational data is stored inside Salesforce. This includes information on customer relationships, sales data and other data on business operations. Second, let's assume that some othe key knowledge is stored externally in systems other than Salesforce. For this scenario, let's take product revenue information is stored in a separate system, as is sometimes the case.

Now, let's talk about the ideal user interface for our end users. Our goal is to present our C-level executives with a chat interface where they can ask various questions. We will use ChatGPT for this example, although the same key concepts will work in other systems. In fact, we have discussed alternatives like SquirroGPT, an alternative to ChatGPT with a focus on enterprise data with enterprise security features and anti-hallucation protection.

In the case of ChatGPT, we will be using GPTs, a feature that allows for creating custom versions of ChatGPT tailored to a specific context. In this scenario, we will create a custom GPT that links to your company's operational data (that's the extra knowledge) and is configured to act only as a sales advisor. This GPT requires real-time access to your latest data to ensure responses are valid and backed up by the latest available data. And we need to guarantee this integration is secure. This guide will demonstrate how to accomplish this, utilizing the RAW platform as the conduit between your operational data and ChatGPT.

And once we are done, this is the sort of interaction you can expect to do with the system:

You can see the system analyzing user feedback, revenue per customer, and customer feedback and provide actionable recommendations!

How Does This Work?

You may have read about LLMs being trained using static documents or, more commonly nowadays, about retrieval augmented generation (RAG) techniques.

However, there's a better way to link operational data. Unlike documents, operational data needs additional "context." A simple value such as "sales: 4000" is meaningless without context: sales of what product or wha period? That's why, at the most basic level, linking operational data with an LLM is best done by creating a data product. This data product is essentially one or more REST APIs that read data from one or more operational systems. The REST API provides the additional context - in the form of metadata - so that the LLM can interpret the data correctly. This means the LLM knows "who to ask" - i.e., which API to use - when trying to find the answer to a question. Because the REST API serves data from the source directly, the LLM is consuming the latest information in real-time. Platforms like RAW make this process very simple to develop and operate.

Data is nothing without context, and numbers are meaningless without an understanding of what they represent and where they come from. That’s why it is important to organize this data and serve them as APIs, because APIs bring along associated metadata, which provides the necessary context. APIs, which are a way to “turn data into a product” with full specification, become a key part of the integration with AI systems. Without them, context is lost, and without context, AI systems cannot provide assistance, or worse, will give you inadequate guidance or bad responses due to hallucinations and misinterpretation.
You can think of an LLM asking questions to an API as an employee contacting various departments to find the requested information. The employee needs to be aware of which departments exist and whom to contact in each of them to find the info. That's the role of an API metadata catalog. Once it knows whom to ask, it can then ask the question - that's making the API call.

Technical Step-By-Step Implementation Guide

Let’s now get started in the technical implementation. We need the following steps to implement our scenario:

  1. First, we need a RAW account (it’s free, so you can try it out!)
  2. Then, we need to build APIs in RAW over your Salesforce data and other operational systems. This involves writing the code – which is easy as RAW provides templates off-the-shelf and you can use high-level languages to do so.
  3. Then, we must configure a new GPT in ChatGPT, and link it with RAW.
  4. And finally, we can ask some questions and see its analytical capabilities!
Step 1: Creating a RAW Account

RAW is a data management platform that specializes in facilitating the flow of information to advanced AI systems, streamlining the process of feeding data into Large Language Models (LLMs). The platform allows you to build and host data services that aggregate, join, and transform data from anywhere in real-time, and serve it as an API product ready to consume by systems like ChatGPT.

APIs built in RAW have high performance and low latency, and allow you to define the “context,” which is a key piece for AI integration. You can visit to learn more and create an account (for free) to try it out (no credit card required).

Step 2: Build the APIs in RAW

Now let’s use RAW to bridge the data from Salesforce and other systems into ChatGPT. For this, we will be using the SQL support in RAW, Salesforce plugin and more. Some of these features may be in “closed beta” at the time of reading, so ping us and we will enable them in your account, for free and no questions asked!

In this scenario, we need 4 pieces of data:

  • Information on company products, available in Salesforce;
  • Contact information, which is also in Salesforce;
  • Customer feedback, which in our scenario is also available in Salesforce as a “custom object” – a type of custom extension that can be built directly into Salesforce – to store individual feedback given to the company on products;
  • Revenue information, which, for this scenario, is kept in a separate relational database.

Given this scenario, we will be building 5 APIs in RAW. We build one API for each of the pieces of data described above. These APIs simply read directly – with caching! – the data from the source system. We then build a 5th API that joins all this data together. For the technically oriented, we include the API definitions in case you want to try it in your own RAW account. For others, feel free to jump to scroll down to see the next steps.


The following examples assume you have added your Salesforce credentials to your RAW account under the name ‘salesforce01’. Credentials are entities that must be created in RAW to give it access to the original data source. This Salesforce instance would also need to have a custom object called “customer feedback”, since the queries below assume its existence. Finally, the examples also assume the presence of a separate relational database (e.g., MySQL in this example) with revenue information, also registered as a RAW credential under the name ‘revenuedb01’.

Company Products API Definition

Title: Retrieve CRM/Salesforce Products

Description: Retrieve CRM/Salesforce Products. Optionally specify name, code and description. If any of these values are specified, then retrieve products with name, code or description that contain these values respectively.

SQL Source Code

select name, product_code, created_date, description 
from salesforce02.salesforce_product
where name like coalesce(concat('%', cast(:name as varchar), '%'), '')
    and description like coalesce(concat('%', cast(:email as varchar), '%'), '')
    and product_code like coalesce(:code, '%');

Contact Information API Definition

Title: Retrieve CRM/Salesforce Contacts

Description: Retrieve CRM/Salesforce Contacts. Optionally specify name and email. If any of these values are specified, then retrieve contacts with name or email that contain these values respectively.

SQL Source Code

select contact_id__c as contact_id, product_id__c as product_id, 
        feedback_type__c as feedback_type, description__c as feedback, 
        date_received__c as date_received
from salesforce02.salesforce_customer_feedback__c
where feedback_type__c like coalesce(:name, '%')
        and contact_id__c like coalesce(:contactid, '%')
        and product_id__c like coalesce(:productid, '%')
        and description__c like coalesce(concat('%', cast(:description as varchar), '%'), '');

Customer Feedback API Definition

Title: Retrieve CRM/Salesforce Customer Feedback

Description: Retrieve CRM/Salesforce customer feedback. Optionally specify feedback type (‘Compliment’, ‘Complaint’, ‘Suggestion’), contact_id, product_id and description. If any of these values are specified, then retrieve contacts with feedback type, contact_id, product_id, description containing these values.

SQL Source Code

select contact_id__c as contact_id, product_id__c as product_id, 
        feedback_type__c as feedback_type, description__c as feedback, 
        date_received__c as date_received
from salesforce02.salesforce_customer_feedback__c
where feedback_type__c like coalesce(:name, '%')
        and contact_id__c like coalesce(:contactid, '%')
        and product_id__c like coalesce(:productid, '%')
        and description__c like coalesce(concat('%', cast(:description as varchar), '%'), '');

Revenue API Definition

Title: Retrieve Revenue

Description: Retrieve revenue for a given product of a given customer/contact of CRM/Salesforce, if any. If no product is specified, retrieve revenue for all products of the given customer/contact of CRM/Salesforce. If no customer/contact is specified, retrieve revenue for all customers of the given product.

SQL Source Code

select contact_id, product_code, revenue_date, cast(amount as decimal(10,2)) as amount
from revenuedb01.revenue
where contact_id like coalesce(:contactid, '%')
    and product_code like coalesce(:productcode, '%');

Combined Data API Definition

Title: Get customer – feedback – revenue combined information

Description: Get customer – feedback – revenue combined information.

SQL Source Code

SELECT as contact_id, salesforce_contact.Name as contact_name, 
    salesforce_customer_feedback__c.feedback_type__c as feedback_type, 
    salesforce_customer_feedback__c.description__c as feedback, 
    SUM(revenue.amount) as total_revenue 
    salesforce02.salesforce_customer_feedback__c ON = salesforce_customer_feedback__c.contact_id__c
    salesforce02.salesforce_product ON
    revenuedb01.revenue ON = revenue.contact_id and revenue.product_code=salesforce_product.product_code
GROUP BY, salesforce_contact.Name, salesforce_customer_feedback__c.feedback_type__c, salesforce_customer_feedback__c.description__c;
Step 3: Configuring an Advisor in ChatGPT

Assuming you have created all the API definitions in RAW and deployed them (see here for a Getting Started Guide if it is your first time learning about RAW), it’s time to configure them in ChatGPT by creating your own custom GPT. You can find a detailed guide on how to create a GPT but essentially, you need to export the API definitions from RAW and add them to the GPT definition, as well as provide some configuration information.

Here are the GPT configuration settings that were used for the example, which you would need to add to your GPT in ChatGPT.

Name: Sales Advisor

Description: Advisor to get insights on customer contacts, products sold, revenue, and doing analysis.InstructionsYou are an advisor that contacts internal APIs that retrieve information regarding Contacts, Products, Customer (Contact) Feedback and Revenue. Always consult the internal API. To perform your own deductions/correlations, prefer to use information from APIs that combine information.

Conversation Starters

  • List CRM contacts
  • Show products in Salesforce
  • What is the total revenue for our Steel Fermenter?
  • Can you correlate revenue with customer feedback?

Schema: Link to the OpenAPI schema from the RAW catalog, e.g Policy: <Link to your own privacy policy>

There are many ways to improve and experiment with this GPT definition, particularly on the “Instructions”. Nonetheless, this is a simple setup to get started.

Once you add that information to the ChatGPT GPT creation interface, you are all set. You have your first GPT, ready to answer questions in real-time based on the latest available data! Note that in the GPT configuration, you can use secure communication methods to guarantee your data is never available publicly. This is supported both by RAW and by GPT.

Step 4: Let’s ask some questions!

For this demo, we have configured a Salesforce instance with product, contact, and customer feedback information. We also configured a separate database system that stores revenue data. We then created 5 APIs in RAW to expose this data, and we configured a ChatGPT “Custom GPT” to read it. So it’s time to show the results.

Let’s start simple. Let’s just ask which products we are selling:

You can see the system contacting RAW APIs to obtain the latest product information. This indicates the integration is successful.

Having a chat navigation to a system like Salesforce is great, but let’s see if we can do more, with a question that requires integration of all the data we have. Let’s ask the GPT to help us understand our products, what users think of them, and what we can do to improve!

… and here we have; a fairly comprehensive description with useful analysis. This is leveraging the best of advanced AI systems with real-time data!

This last example also shows a key ability of this type of API-based integration. We asked a question that requires retrieving data from many sources - customer info, products, revenue, customer feedback. The LLM chose to use an API we created that provides this exact information, all "pre-integrated" (the "Combined Data API" we defined above). That is a key design principle for a sucessful integration: it's best to provide "integrated data products" to the LLM system, rather than letting it "guess" and contact many systems independently and compose information. By creating well-defined data APIs and data products, we are setting ourselves up for success. Providing good quality APIs means we will be getting good quality answers!

Ready to Learn More?

For businesses looking to dive deeper into the specifics of this integration or to see it in action, we’re here to help. Reach out for a detailed discussion or a demo, and we’ll show you how to make LLMs an invaluable part of your data analysis toolkit.

Start for free today.
No credit card required.