An intelligent case resolution system for Salesforce that leverages AI and Retrieval Augmented Generation (RAG) to provide solutions based on your knowledge articles.
This application connects your Salesforce instance with an AI-powered backend that:
- Receives case data from Salesforce
- Uses a RAG-based approach to find relevant information in your knowledge base
- Generates comprehensive solutions using AI (Gemini model)
- Returns formatted HTML solutions directly to your Salesforce interface
The system uses ChromaDB as a vector database and OpenAI embeddings to effectively retrieve contextually relevant information from your knowledge articles.
The current implementation demonstrates the system using:
- Knowledge articles scraped from Purdue University
- Vector embeddings stored in ChromaDB
- Flask server for API endpoints
- LWC component integration in Salesforce
Prerequisites
- Python 3.8+
- OpenAI API Key
- Google Gemini API Key
- MongoDB
- ngrok (for local development testing)
- Setup
git clone https://github.com/rahul07bagul/Salesforce-CaseSolver-AI.git
cd python_server
pip install -r requirements.txt
- Create .env file with below content and add your API keys
GEMINI_API_KEY=""
GEMINI_MODEL_NAME="gemini-2.0-flash"
GEMINI_EMBEDDING_MODEL_NAME="gemini-embedding-exp-03-07"
OPENAI_API_KEY=
OPENAI_EMBEDDING_MODEL_NAME="text-embedding-3-small"
MONGODB_URI="mongodb://localhost:27017/"
MONGODB_DB_NAME="SFDC_AI"
CURRENT_MODEL="Gemini"
- Process knowledge articles (one-time setup):
python run_pipeline.py
This will:
- Process the sample Purdue articles (from the provided JSON file)
- Store them in MongoDB
- Create vector embeddings in ChromaDB
- Start the Flask server:
python app.py
- For local development, expose your server using ngrok:
ngrok http 5000
- Add the ngrok URL to Salesforce Trusted Sites:
- Setup > Trusted URL > New
- Add the ngrok URL (or your production server URL)
- Create a Custom Label for your endpoint:
- Setup > Custom Labels > New
- Create a new label (e.g., "Python_App_URL")
- Set the value to your server URL + "api/v1/cases/get_resolution"
- Deploy the LWC component:
- Use the LWC component code provided in the repository
- Update the API endpoint reference to use your Custom Label
- Add the LWC component to the Case Record Page:
- Setup > Object Manager > Case
- Lightning Record Pages > Case Record Page
- Edit layout and add your component
- Open a Case in Salesforce
- Click the "Get Resolution" button in your LWC component
- The system will:
- Send case data to your Flask server
- Process the case using RAG and AI
- Return a formatted solution
- Display the solution in the Salesforce interface