A Salesforce-native integration with Google's Gemini AI File Search capabilities
Gemini Force enables Salesforce users to upload documents, have them automatically indexed in Google's Gemini File Search, and then ask natural language questions about their contentβall within the Salesforce UI.
- π€ Single & Batch Upload - Upload one or many files at once with drag-and-drop support
- π·οΈ Flexible Tagging - Apply optional metadata tags to documents for organized retrieval
- π Multi-Store Support - Configure multiple FileSearch Stores for different document categories
- π AI-Powered Search - Ask natural language questions about your documents
- π¬ Single-File Chat - Chat with individual documents in a conversational interface
- π Multi-File Chat - Query across multiple documents in a single conversation
- π Real-time Status - Track document processing with live polling updates
- βοΈ Admin Interface - Manage tag categories through a dedicated admin UI
- π Secure - API keys stored in Salesforce Custom Settings, never exposed to users
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Salesforce β
β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β Upload β β Tagging β β Processing β β Chat β β
β β (Single) ββ β (Optional) ββ β Status ββ β (Single) β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β
β βββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββ β
β β Batch Uploader β β Multi-File Chat β β
β β (Multiple Files) β β (Query Across Documents) β β
β βββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββ β
β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Shared LWC Libraries β β
β β gforceUtils β gforceStatusUtils β gforceFileService β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β β
β β β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Apex Services β β
β β FileService β SyncService β QueryService β MultiFileQueryServiceβ β
β β StoreService β HttpClient β ResponseParser β SettingsService β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
β HTTPS
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Google Cloud Platform β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Gemini File Search API (v1beta) β β
β β βββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββ β β
β β β FileSearchStore(s) β β generateContent API β β β
β β β (Multi-Store) β β (RAG with File Search Tool) β β β
β β βββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββ β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Salesforce CLI (
sforsfdx) - A Salesforce org (Developer Edition, Sandbox, or Scratch Org)
- DevHub enabled (for scratch orgs)
- A GCP project with billing enabled
gcloudCLI installed and authenticated- Gemini API enabled on your project
git clone https://github.com/bhanudas/gemini-force.git
cd gemini-force# Copy the config template
cp gcp/config/setup-config.env.template gcp/config/setup-config.env
# Edit with your GCP project ID
# nano gcp/config/setup-config.env
# Run the setup script
chmod +x gcp/scripts/setup-gemini.sh
./gcp/scripts/setup-gemini.shThe script will:
- Enable the Gemini API
- Create an API key
- Create a FileSearchStore for your documents
- Output the values you'll need for Salesforce configuration
# Authenticate with your org
sf org login web --alias my-org
# Deploy the source
sf project deploy start --source-dir force-app/main/default --target-org my-org
# Run tests to verify deployment
sf apex run test --test-level RunLocalTests --target-org my-org --wait 10After deployment, configure the Custom Settings in Salesforce:
- Go to Setup β Custom Settings β gforce Integration Settings β Manage
- Click New (for Org Default)
- Enter your values:
| Field | Description | Example |
|---|---|---|
| API Key | Your Gemini API key from GCP | AIzaSy... |
| FileSearch Store Name | Full store path from setup script | fileSearchStores/gforce-documents-xxxxx |
| LLM Model | Gemini model to use | gemini-2.5-flash |
| Max File Size MB | Maximum upload size | 12 |
| Max Retries | Retry count for failed uploads | 3 |
| Polling Interval Ms | Status check interval | 3000 |
| Timeout Seconds | API timeout | 120 |
For multi-store support, add records to the gforce FileSearch Store custom metadata:
- Go to Setup β Custom Metadata Types β gforce FileSearch Store β Manage Records
- A default store is included; add additional stores as needed:
| Field | Description | Example |
|---|---|---|
| Label | Display name | Financial Documents |
| Store Name | Full Gemini resource path | fileSearchStores/finance-docs-xxxxx |
| Is Default | Set one store as default | true |
| Is Active | Enable/disable store | true |
# For administrators
sf org assign permset --name gforce_Administrator --target-org my-org
# For standard users
sf org assign permset --name gforce_File_User --target-org my-orgNavigate to the Gemini Force app in the App Launcher. Available tabs:
| Tab | Description |
|---|---|
| Gemini Assistant | Single-file upload workflow with tagging and chat |
| Batch Upload | Upload and process multiple files at once |
| Multi-File Query | Query across multiple documents simultaneously |
| Gemini Files | List view of all uploaded files |
| Tag Admin | View configured tag categories |
| File Tags | Browse applied file tags |
| Chat Messages | View conversation history |
gemini-force/
βββ force-app/main/default/
β βββ applications/ # Lightning App definition
β βββ classes/ # Apex classes
β β βββ gforce_FileService.cls # File record management
β β βββ gforce_SyncService.cls # Gemini sync operations
β β βββ gforce_QueryService.cls # Single-file query handling
β β βββ gforce_MultiFileQueryService.cls # Multi-file query handling
β β βββ gforce_StoreService.cls # FileSearch Store management
β β βββ gforce_HttpClient.cls # API communications
β β βββ gforce_ResponseParser.cls # API response parsing
β β βββ gforce_SettingsService.cls # Configuration management
β β βββ gforce_FileSyncQueueable.cls # Async file processing
β β βββ gforce_SyncFinalizer.cls # Queueable finalizer
β β βββ gforce_SyncRetryHelper.cls # Retry logic helper
β β βββ gforce_TestDataFactory.cls # Test data utilities
β β βββ *Test.cls # Test classes
β βββ customMetadata/ # Tag definitions & FileSearch Store configs
β βββ flexipages/ # Lightning App Pages
β βββ layouts/ # Page Layouts
β βββ lwc/ # Lightning Web Components
β β βββ gforceFileDashboard/ # Main orchestration component
β β βββ gforceFileUploader/ # Single file upload UI
β β βββ gforceFileTagging/ # Optional metadata tagging UI
β β βββ gforceFileStatus/ # Processing status tracker
β β βββ gforceFileChat/ # Single-file chat interface
β β βββ gforceBatchUploader/ # Batch file upload UI
β β βββ gforceMultiFileChat/ # Multi-file query interface
β β βββ gforceTagAdmin/ # Tag administration UI
β β βββ gforceUtils/ # Shared logging & utilities
β β βββ gforceStatusUtils/ # Status styling helpers
β β βββ gforceFileService/ # Centralized Apex wrappers
β βββ objects/ # Custom Objects, Fields & Metadata Types
β βββ permissionsets/ # Permission Sets
β βββ remoteSiteSettings/ # Remote Site for Gemini API
β βββ tabs/ # Custom Tabs (7 total)
βββ gcp/
β βββ config/ # GCP configuration templates
β βββ scripts/ # Setup automation scripts
βββ config/ # Salesforce DX config
βββ docs/ # Architecture documentation
# Create scratch org from DevHub
sf org create scratch --definition-file config/project-scratch-def.json --alias gforce-dev --duration-days 30
# Push source
sf project deploy start --source-dir force-app/main/default --target-org gforce-dev
# Assign permission set
sf org assign permset --name gforce_Administrator --target-org gforce-dev
# Open the org
sf org open --target-org gforce-dev# Run all tests
sf apex run test --test-level RunLocalTests --target-org gforce-dev --wait 10
# Run specific test class
sf apex run test --class-names gforce_QueryServiceTest --target-org gforce-dev --wait 10# Lint LWC components
npm run lint:lwc
# Auto-fix issues
npm run lint:lwc:fix- API Keys: Stored in Salesforce Custom Settings (Hierarchy), protected by field-level security
- No hardcoded secrets: All sensitive values are configured post-deployment
- Remote Site Settings: Only the Gemini API endpoint is whitelisted
- Permission Sets: Granular access control for users and administrators
We welcome contributions! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Salesforce DX
- Powered by Google Gemini AI
- Inspired by the need for seamless document intelligence in Salesforce
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Made with β€οΈ for the Salesforce community