Build a conversational AI that understands your Salesforce CRM data using Retrieval-Augmented Generation (RAG)
This article has been refreshed with the latest LangChain patterns, ChromaDB improvements, and OpenAI embedding model recommendations. Originally published December 2023.
This is blog post 2 in my AI series. In this tutorial, I'll share source code and a video walkthrough for using LangChain with OpenAI embeddings and ChromaDB vector database to create a conversational interface for Salesforce Lead data.
The concept behind this is called RAG - Retrieval-Augmented Generation. Instead of relying solely on the LLM's training data, we provide it with relevant context from our own database, enabling accurate answers about your specific Salesforce records.
The RAG architecture for this demo follows these key steps:
| Component | Purpose | 2026 Recommendation |
|---|---|---|
| LangChain | Orchestration framework for LLM applications | Use LangGraph for agentic workflows |
| ChromaDB | Open-source vector database | Rust-core rewrite offers 4x performance |
| OpenAI Embeddings | Convert text to vector representations | text-embedding-3-large for production |
| GPT Model | Generate natural language responses | GPT-4 or GPT-4-turbo for accuracy |
Here's a summary of what the demo code accomplishes:
# Key imports
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.vectorstores import Chroma
from langchain.chains import ConversationalRetrievalChain
from langchain.chat_models import ChatOpenAI
# Create embeddings and store in ChromaDB
embeddings = OpenAIEmbeddings()
vectorstore = Chroma.from_documents(
documents=salesforce_docs,
embedding=embeddings,
persist_directory="./chroma_db"
)
# Create conversational chain
llm = ChatOpenAI(model_name="gpt-4")
qa_chain = ConversationalRetrievalChain.from_llm(
llm=llm,
retriever=vectorstore.as_retriever(),
return_source_documents=True
)
# Query your Salesforce data
response = qa_chain({
"question": "Which leads are from the technology industry?",
"chat_history": []
})
Watch the complete video walkthrough demonstrating the RAG implementation with Salesforce data:
The full Python implementation is available on GitHub. This includes Salesforce authentication, data extraction, embedding generation, and the conversational interface:
The RAG landscape has evolved significantly since this article was first published. Here are the key updates for building production RAG systems in 2026:
| Model | Dimensions | Best For |
|---|---|---|
| text-embedding-3-large | 3072 (adjustable) | Production RAG, multilingual support |
| text-embedding-3-small | 1536 | Cost-sensitive applications, prototypes |
Salesforce now offers native RAG capabilities through Agentforce and Data Cloud. The Agentforce Data Library (ADL) automatically configures:
Continue your Salesforce and AI learning journey with these related guides:
Reference guide for abbreviations and technical terms used in this article.
Hello Sir, I am getting error. can we call on google meet?