Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/scooller/Leben-site/llms.txt

Use this file to discover all available pages before exploring further.

iLeben treats Salesforce as the single source of truth for commercial and operational entities. Projects (Proyectos), plants (Plantas), advisors (Asesores), branding assets, contact channels, and broker metrics all flow from Salesforce into the local MySQL database on a schedule. In the opposite direction, every public contact form submission is pushed to Salesforce as a Lead — with automatic retry logic so no lead is silently dropped. The integration is built on the omniphx/forrest library and uses the WebServer OAuth flow for persistent, user-authorized API access.

What Syncs From Salesforce

The following entities are owned by Salesforce and periodically pulled into iLeben’s local database:

Proyectos

Real estate projects with stage normalization (etapa), commercial fields, discount thresholds, and advisor assignments.

Plantas

Individual units (Product2) with pricing, surfaces, orientation, floor, and interior image URLs.

Asesores

Salesforce Users mapped to local advisors with avatar URL, WhatsApp, and activity status.

Branding & Images

Public Documents (cotizador logo / portada) resolved via SF_PUBLIC_SITE_URL and SF_ORG_ID.

Contact Channels

ContactChannel records synced from Salesforce — displayed as color-coded badges in the Filament panel.

Broker Metrics

Commercial metrics recalculated from local opportunity snapshots via salesforce:sync-broker-metrics.

What Syncs To Salesforce

Contact form submissions submitted via POST /api/v1/contact-submissions are enqueued as CreateSalesforceCaseJob and sent to Salesforce as Leads. The job includes automatic retry on invalid field errors, UTM enrichment, and full OAuth reconnect logic.
Whether the integration sends a Lead, a Case, or both is controlled by SF_LEAD_ENABLED and SF_CASE_ENABLED. See Leads & Contacts for details.

Architecture Overview

The core service class is App\Services\Salesforce\SalesforceService, which wraps all SOQL queries with Cache::remember using a configurable TTL (default 15 minutes). Mutations (Lead and Case creation) are handled through Forrest::sobjects() with a multi-attempt retry chain.
┌─────────────────────────────────────────────────────────────────┐
│                         Salesforce Org                          │
│   Opportunity  │  Product2  │  User  │  Document  │  Lead/Case  │
└───────┬────────┴──────┬─────┴───┬────┴─────┬──────┴──────┬──────┘
        │               │         │          │             │
        │  SOQL (forrest)          │   SObject POST         │
        ▼               ▼         ▼          ▼             │
┌────────────────────────────────────────────────────────┐ │
│              SalesforceService (Laravel)               │ │
│   query() → Cache::remember(soql_hash, TTL)            │ │
│   createLead() → sanitize → POST → retry on error      │ │
│   tryAutoReconnect() → restore backup → Forrest::refresh│ │
└──────────────────────┬─────────────────────────────────┘ │
                       │                                    │
        ┌──────────────┼──────────────────┐                │
        ▼              ▼                  ▼                 │
  SyncPlantsJob  SyncProjectsAction  SalesforceCaseMapper   │
        │              │                  │                 │
        ▼              ▼                  ▼                 │
┌────────────────────────────────────────────────────────┐ │
│               MySQL (local database)                   │ │
│   plants  │  proyectos  │  asesores  │  contact_channels│ │
│   contact_submissions  │  site_settings                │ │
└────────────────────────────────────────────────────────┘ │

                  CreateSalesforceCaseJob ──────────────────┘
                  (dispatched on form submit)

Key Environment Variables

Configure the Salesforce integration in your .env file using these variables:
VariablePurposeExample
SF_AUTH_METHODOAuth flow type — use WebServerWebServer
SF_CONSUMER_KEYConnected App consumer key3MVG9...
SF_CONSUMER_SECRETConnected App consumer secretABC123...
SF_CALLBACK_URIOAuth redirect URI registered in Salesforcehttps://app.example.com/salesforce/callback
SF_LOGIN_URLSalesforce login endpointhttps://login.salesforce.com
SF_API_VERSIONSalesforce API version57.0
SF_INSTANCE_URLYour Salesforce org instance URLhttps://your-domain.my.salesforce.com
SF_LEAD_ENABLEDEnable Lead creation from contact formstrue
SF_CASE_ENABLEDEnable Case creation from contact formstrue
Additional variables (SF_OAUTH_SCOPE, SF_OAUTH_PROMPT, SF_LEAD_OWNER_ID, etc.) are covered in the specific integration pages below.

OAuth Setup

Configure the WebServer OAuth flow, connected app scopes, and the auto-reconnect backup mechanism.

Sync Commands

Artisan commands, scheduler config, Production Sync job, and cPanel cron setup.

Leads & Contacts

How form submissions become Salesforce Leads, UTM mapping, CSV import, and activity log.

Build docs developers (and LLMs) love