> ## Documentation Index
> Fetch the complete documentation index at: https://docs.thena.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Salesforce

> Synchronize accounts and contacts between Salesforce and Thena for seamless customer data management.

<img src="https://mintcdn.com/thena-840ce5ec/fnPhXvYfm-TNmZho/images/docs/Salesforce-CRM.webp?fit=max&auto=format&n=fnPhXvYfm-TNmZho&q=85&s=2f085bd719bc00aa29c567cabca02325" alt="Salesforce CRM in Thena" className="rounded-lg" width="7680" height="4800" data-path="images/docs/Salesforce-CRM.webp" />

## Overview

The Salesforce integration enables synchronization of accounts and contacts from Salesforce CRM to Thena. This integration helps you maintain consistent customer data across both platforms, streamline your customer relationship management, and enhance your team's ability to provide personalized service.

* **Account synchronization**: Automatically sync accounts from Salesforce to Thena with custom field selection
* **Contact synchronization**: Automatically sync contacts from Salesforce to Thena with predefined fields
* **Advanced filtering**: Control which accounts and contacts are synchronized with multiple filter operators
* **Manual sync triggers**: Trigger immediate synchronization for accounts or contacts
* **Activity monitoring**: Track all synchronization activities with detailed audit logs and sync status
* **Flexible sync frequency**: Configure sync intervals from 4 to 24 hours
* **Data preservation**: Deletions in Salesforce are not automatically handled to prevent data loss in Thena

## Key features

<CardGroup cols={2}>
  <Card title="Account synchronization" icon="building">
    * Sync account fields
    * Choose from available Salesforce fields
    * Apply complex filtering rules
    * Manual sync triggers available
  </Card>

  <Card title="Contact synchronization" icon="address-book">
    * Sync contacts with predefined standard fields
    * Link contacts to associated accounts
    * Track sync status and history
  </Card>

  <Card title="Advanced filtering" icon="filter">
    * Multiple filter operators (equals, contains, greater than, etc.)
    * Filter by any selected field
    * Include/exclude specific records
  </Card>

  <Card title="Activity monitoring" icon="list-check">
    * Real-time sync status tracking
    * Detailed audit logs
    * Monitor sync operations progress
    * View sync history and errors
  </Card>

  <Card title="Flexible scheduling" icon="clock">
    * Configure sync frequency (4, 8, 12, or 24 hours)
    * Manual sync triggers for immediate updates
    * Track last sync timestamps
  </Card>

  <Card title="Field mapping" icon="arrows-left-right">
    * Predefined field mappings
    * Account fields mapping
    * Contact fields mapping
    * Automatic field creation in Thena
  </Card>
</CardGroup>

## Setup

<Info>
  You need admin permissions in Salesforce to install the Salesforce integration.
</Info>

<Tip>
  Install the Salesforce integration at the organization level since this feature will be accessible to all teams, as Accounts is an organization-level feature.
</Tip>

<Steps>
  <Step title="Begin installation">
    1. Navigate to the [Apps studio](https://dashboard.thena.ai/organization/settings/apps-studio) in your Thena dashboard
    2. Find the Salesforce integration in the available apps
    3. Click the "Install" button to begin the installation process
  </Step>

  <Step title="Review and configure">
    1. Review the permissions and scopes required by the integration
    2. Select "No team" to install Salesforce at the organization level
  </Step>

  <Step title="Complete authorization">
    1. After configuration, click "Complete Salesforce authorization"
    2. You'll be redirected to Salesforce to authorize the connection
    3. Sign in with your Salesforce account and grant the requested permissions
    4. You'll be redirected back to Thena once authorization is complete
  </Step>

  <Step title="Verify connection">
    1. Navigate to the Salesforce configuration page
    2. Verify that account and contact sync is enabled
    3. Configure custom fields for accounts (contacts use predefined fields)
    4. Set up sync frequency for both accounts and contacts
    5. Optionally set up filters to sync selective data
    6. Click "Save changes" to apply your configuration
  </Step>
</Steps>

## How to configure synchronization

<AccordionGroup>
  <Accordion title="Account field selection">
    For accounts, you can select which custom fields to synchronize (default fields are always included):

    1. Navigate to the Salesforce configuration page in App Studio
    2. Open the "Accounts" section
    3. Find the "Custom fields" section
    4. Type at least 2 characters in the search box to find available fields
    5. Select the custom fields you want to synchronize
    6. Default fields (Name, Website, OwnerId, Description, Id, Type, Industry) are always included
    7. Click "Save changes" to apply your configuration

    <Tip>
      Default account fields are always synchronized and cannot be deselected. These include Name (maps to Thena account name), Website (maps to primaryDomain), OwnerId (maps to accountOwnerId), and others with specific mappings to Thena properties.
    </Tip>

    <Info>
      Account sync allows custom field selection beyond default fields and supports advanced filtering with multiple operators. Custom fields must be searched and selected, and filters can only be applied to selected custom fields.
    </Info>
  </Accordion>

  <Accordion title="Contact field configuration">
    Contact synchronization uses predefined standard fields:

    1. Navigate to the Salesforce configuration page in App Studio
    2. Open the "Contacts" section
    3. View the predefined fields that will be synchronized:
       * **FirstName**: Maps to Thena contact firstName
       * **LastName**: Maps to Thena contact lastName
       * **Email**: Maps to Thena contact email (required)
       * **Phone**: Maps to Thena contact phoneNumber
       * **Title**: Contact title/position
       * **Department**: Contact department
       * **AccountId**: Links contact to associated Salesforce account

    <Tip>
      Contact fields are predefined and cannot be customized. This ensures consistent data mapping between Salesforce and Thena.
    </Tip>

    <Info>
      Contact sync uses predefined standard fields only with no custom field selection available. This ensures consistent data mapping between systems and links contacts to their associated Salesforce accounts.
    </Info>
  </Accordion>

  <Accordion title="Setting up filters">
    You can set up advanced filters to control which account records are synchronized:

    1. Navigate to the Salesforce configuration page
    2. Open the "Accounts" section
    3. Find the "Filters" section (available only for accounts with selected custom fields)
    4. Click "Add filter" to create a new filter
    5. Select the field to filter on (from your selected fields)
    6. Choose from multiple available operators
    7. Enter the filter value(s)
    8. Add additional filters as needed
    9. Click "Save changes" to apply your filters

    Available filter operators include:

    * **Equals / Not equals**: Exact value matching
    * **Contains / Does not contain**: Partial text matching
    * **Greater than / Less than**: Numeric/date comparisons
    * **Greater than or equal / Less than or equal**: Inclusive comparisons
    * **Is empty / Is not empty**: Check for null/empty values
    * **Is true / Is false**: Boolean value checks
    * **Starts with / Ends with**: Text pattern matching
    * **Is one of / Is not one of**: Multiple value matching (comma-separated)
    * **Has property / Does not have property**: Property existence checks

    <Tip>
      Multiple filters are combined with AND logic. Use filters to exclude test data, inactive records, or records that don't meet your criteria.
    </Tip>
  </Accordion>

  <Accordion title="Sync frequency configuration">
    Configure how often data is synchronized:

    1. Navigate to the Salesforce configuration page
    2. Open either the "Accounts" or "Contacts" section
    3. Find the "Sync frequency" dropdown
    4. Choose from available options:
       * **Every 4 hours**: More frequent updates
       * **Every 8 hours**: Balanced frequency
       * **Every 12 hours**: Less frequent updates
       * **Every 24 hours (Daily)**: Once per day

    <Tip>
      You can also trigger manual synchronization using the refresh button next to each sync section for immediate updates.
    </Tip>

    <Info>
      There is no specific limit imposed by Thena on the number of Salesforce records you can synchronize. However, the integration respects Salesforce's API rate limits and governor limits. For large data sets, synchronization may take longer due to these rate limits, but the system implements rate limiting and retry mechanisms to handle this gracefully.
    </Info>
  </Accordion>

  <Accordion title="Activity monitoring">
    Monitor synchronization activities and troubleshoot issues:

    1. Navigate to the Salesforce configuration page
    2. Open the "Sync status" section
    3. Switch between two tabs:
       * **Sync Status**: View active, completed, and failed sync operations
       * **Audit Logs**: Search and view detailed activity logs

    **Sync Status features:**

    * Real-time status of sync operations
    * Progress tracking for active syncs
    * Completion times and error information
    * Auto-refresh during active operations

    **Audit Logs features:**

    * Searchable log entries with detailed information
    * Filter by entity type (accounts, contacts, webhooks)
    * View specific actions (created, updated, fetched)
    * Error details for troubleshooting
    * Pagination for large log sets

    <Tip>
      Use the search functionality in audit logs to quickly find specific records or error messages. Logs are automatically refreshed and provide comprehensive tracking of all integration activities.
    </Tip>

    <Info>
      If data is missing after synchronization, check that custom fields are selected for accounts, verify records contain required predefined fields for contacts, ensure filters aren't excluding expected records, and check audit logs for specific errors. Some complex field types may not be supported by the integration.
    </Info>
  </Accordion>
</AccordionGroup>

## Permission scopes

The Salesforce app requires specific permissions to function properly and processes events to keep data synchronized between systems.

<AccordionGroup>
  <Accordion title="Required platform scopes">
    <CardGroup cols={1}>
      <Card title="accounts:read">
        Read account information:

        * Access account data for synchronization
        * Query account records from Thena
        * Retrieve account properties and metadata
      </Card>

      <Card title="accounts:write">
        Create and update accounts:

        * Sync account data with Salesforce
        * Create new accounts in Thena from Salesforce
        * Update existing account information
      </Card>

      <Card title="contacts:read">
        Read contact information:

        * Access contact data for synchronization
        * Query contact records from Thena
        * Retrieve contact properties and metadata
      </Card>

      <Card title="contacts:write">
        Create and update contacts:

        * Sync contact data with Salesforce
        * Create new contacts in Thena from Salesforce
        * Update existing contact information
      </Card>

      <Card title="custom-fields:read">
        Read custom field definitions:

        * Access custom field configurations for sync mapping
        * Retrieve field metadata and types
        * Support field search functionality
      </Card>

      <Card title="custom-fields:write">
        Create custom fields for sync tracking:

        * Create sf\_account\_id and sf\_contact\_id fields for sync tracking
        * Automatically create custom fields in Thena when needed
        * Maintain field mapping relationships
      </Card>
    </CardGroup>
  </Accordion>

  <Accordion title="Events from Thena">
    <CardGroup cols={1}>
      <Card title="account.created">
        Sync new accounts from Thena to Salesforce:

        * Creates a contact in Salesforce when a new account is added in Thena
        * Only active in bidirectional sync mode
        * Synchronizes standard and custom field values
      </Card>

      <Card title="account.updated">
        Sync account updates from Thena to Salesforce:

        * Updates the account in Salesforce when account details are modified in Thena
        * Only active in bidirectional sync mode
        * Maintains data consistency between platforms
      </Card>

      <Card title="contact.created">
        Sync new contacts from Thena to Salesforce:

        * Creates a contact in Salesforce when a new contact is added in Thena
        * Only active in bidirectional sync mode
        * Synchronizes predefined contact fields
      </Card>

      <Card title="contact.updated">
        Sync contact updates from Thena to Salesforce:

        * Updates the contact in Salesforce when contact details are modified in Thena
        * Only active in bidirectional sync mode
        * Links contacts to associated accounts
      </Card>
    </CardGroup>
  </Accordion>

  <Accordion title="Events to Thena">
    <CardGroup cols={1}>
      <Card title="salesforce.account.synced">
        Notifies Thena about account synchronization:

        * Provides account\_id, sync\_status, and salesforce\_id
        * Confirms successful account creation or updates
        * Tracks sync operation status
      </Card>

      <Card title="salesforce.contact.synced">
        Notifies Thena about contact synchronization:

        * Provides contact\_id, sync\_status, and salesforce\_id
        * Confirms successful contact creation or updates
        * Tracks sync operation status
      </Card>
    </CardGroup>
  </Accordion>
</AccordionGroup>
