Skip to content

Salesforce based connector to Gemini features and functionality

License

Notifications You must be signed in to change notification settings

bhanudas/gemini-force

Repository files navigation

Gemini Force πŸš€

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.

License Salesforce API Gemini API

✨ Features

  • πŸ“€ 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

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                              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)   β”‚  β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“‹ Prerequisites

Salesforce

  • Salesforce CLI (sf or sfdx)
  • A Salesforce org (Developer Edition, Sandbox, or Scratch Org)
  • DevHub enabled (for scratch orgs)

Google Cloud Platform

  • A GCP project with billing enabled
  • gcloud CLI installed and authenticated
  • Gemini API enabled on your project

πŸš€ Quick Start

1. Clone the Repository

git clone https://github.com/bhanudas/gemini-force.git
cd gemini-force

2. Set Up Google Cloud

# 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.sh

The 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

3. Deploy to Salesforce

# 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 10

4. Configure Integration Settings

After deployment, configure the Custom Settings in Salesforce:

  1. Go to Setup β†’ Custom Settings β†’ gforce Integration Settings β†’ Manage
  2. Click New (for Org Default)
  3. 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

4b. Configure FileSearch Stores (Optional - Multi-Store)

For multi-store support, add records to the gforce FileSearch Store custom metadata:

  1. Go to Setup β†’ Custom Metadata Types β†’ gforce FileSearch Store β†’ Manage Records
  2. 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

5. Assign Permission Sets

# 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-org

6. Access the App

Navigate 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

πŸ“ Project Structure

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

πŸ”§ Development

Creating a Scratch Org

# 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

Running Tests

# 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

Linting

# Lint LWC components
npm run lint:lwc

# Auto-fix issues
npm run lint:lwc:fix

πŸ” Security Notes

  • 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

🀝 Contributing

We welcome contributions! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support


Made with ❀️ for the Salesforce community

About

Salesforce based connector to Gemini features and functionality

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published