Salesforce

Overview

The Salesforce connector enables your AI Colleagues to integrate with your organization's Salesforce CRM platform, facilitating automated record management, data synchronization, and CRM workflows.

Salesforce is a cloud-based customer relationship management (CRM) platform that helps organizations manage sales, customer service, marketing, and more. The Salesforce connector allows Leena AI to automate CRM workflows, manage records across standard and custom objects, and interact with Salesforce data seamlessly.

API Details

Leena AI integrates with Salesforce via REST APIs.

Documentation link: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_rest.htm

Setup

The Salesforce connector supports two OAuth 2.0 authentication methods: OAuth 2.0 JWT Bearer Flow and OAuth 2.0 Client Credentials Flow.


Prerequisites

Before setting up the Salesforce connector, ensure you have:

  • Administrator access to your Salesforce organization
  • Access to Salesforce Setup with ability to create Connected Apps
  • Ability to manage OAuth settings and certificates in Salesforce
  • Access to your Leena AI workspace with connector management permissions

Get credentials

Option 1: OAuth 2.0 Client Credentials Flow

Here is how to configure a Connected App for OAuth 2.0 Client Credentials Flow in Salesforce:

  1. Log in to Salesforce as an administrator
  2. Navigate to Setup:
    1. Click on the gear icon in the upper right corner
    2. Select Setup
  3. Create Connected App:
    1. In the Quick Find box, search for "App Manager"
    2. Click on App Manager
    3. Click New Connected App
  4. Configure Basic Information:
    1. Connected App Name: Enter a descriptive name (e.g., "Leena AI Integration")
    2. API Name: Let Salesforce auto-populate based on name
    3. Contact Email: Enter your administrator email
  5. Configure API (Enable OAuth Settings):
    1. Check Enable OAuth Settings
    2. Callback URL: Enter a placeholder URL (e.g., https://localhost/) - not used for client credentials flow
    3. Selected OAuth Scopes: Choose "Manage user data via APIs (api)"
    4. Check Enable Client Credentials Flow
    5. Accept the security warning when prompted
  6. Save and Wait:
    1. Click Save
    2. Click Continue
    3. Wait 2-10 minutes for the connected app to activate
  7. Configure Run As User:
    1. From the App Manager, find your connected app and click Manage
    2. Click Edit Policies
    3. Under Client Credentials Flow, click the lookup icon for "Run As"
    4. Select an integration user with API-only permissions
    5. Click Save
  8. Get Consumer Credentials:
    1. From the App Manager, find your connected app and select View
    2. Click Manage Consumer Details
    3. Verify your identity if prompted
    4. Copy the Consumer Key and Consumer Secret

Option 2: OAuth 2.0 JWT Bearer Flow

Here is how to configure a Connected App for OAuth 2.0 JWT Bearer Flow in Salesforce:

  1. Generate Private Key and Certificate:
    1. Install OpenSSL if not already available
    2. Generate private key: openssl genrsa -out privatekey.pem 2048
    3. Generate certificate: openssl req -new -x509 -key privatekey.pem -out certificate.crt -days 365
    4. Keep the privatekey.pem file secure - you'll need it for Leena AI configuration
  2. Log in to Salesforce as an administrator
  3. Navigate to Setup:
    1. Click on the gear icon in the upper right corner
    2. Select Setup
  4. Create Connected App:
    1. In the Quick Find box, search for "App Manager"
    2. Click on App Manager
    3. Click New Connected App
  5. Configure Basic Information:
    1. Connected App Name: Enter a descriptive name (e.g., "Leena AI JWT Integration")
    2. API Name: Let Salesforce auto-populate based on name
    3. Contact Email: Enter your administrator email
  6. Configure API (Enable OAuth Settings):
    1. Check Enable OAuth Settings
    2. Callback URL: Enter sfdc://oauth/jwt/success
    3. Check Use digital signatures
    4. Upload your certificate file (certificate.crt)
    5. Selected OAuth Scopes: Choose "Manage user data via APIs (api)" and "Perform requests on your behalf at any time (refresh_token, offline_access)"
  7. Save and Wait:
    1. Click Save
    2. Click Continue
    3. Wait 2-10 minutes for the connected app to activate
  8. Pre-authorize Users:
    1. From the App Manager, find your connected app and click Manage
    2. Click Edit Policies
    3. Under OAuth Policies, set Permitted Users to "Admin approved users are pre-authorized"
    4. Click Save
    5. Under Profiles or Permission Sets, add the appropriate profiles/permission sets for users who will use this integration
  9. Get Consumer Key:
    1. From the App Manager, find your connected app and select View
    2. Click Manage Consumer Details
    3. Copy the Consumer Key

Add connection

Here is how to add a connection on Leena AI:

  1. Log in to your Leena AI workspace
  2. Navigate to Settings > Integrations
  3. Search for "Salesforce" and select it from the list to add its new connector
  4. Start configuring the connector:
    1. Auth Type: Select either "OAuth 2.0 Client Credentials" or "OAuth 2.0 JWT"
    2. Domain: Your Salesforce My Domain (e.g., "your-company" for your-company.my.salesforce.com)
    3. API Version: The Salesforce API version to use (Pre-filled with "v61.0")
  5. For OAuth 2.0 Client Credentials:
    1. Consumer Key: The consumer key from your connected app
    2. Consumer Secret: The consumer secret from your connected app
  6. For OAuth 2.0 JWT:
    1. Admin's Email: The email address of the Salesforce admin user
    2. Consumer Key: The consumer key from your connected app
    3. Private Key: Paste the contents of your privatekey.pem file
  7. Save the connector configuration

Actions

The following actions are supported for the Salesforce connector:

Create a record

Creates a new record in Salesforce for any standard or custom object. The Agent can leverage the skill (workflow), which has been designed to create new records in Salesforce, once the user raises a query to do so. The form fields are dynamically generated based on the selected Salesforce object's schema.


Input Parameters

Here are the input parameters required to set up this action:

Mandatory

NameDescription
Object NameThe Salesforce object type to create (e.g., Lead, Account, Contact, Opportunity, or custom objects)

Dynamic Fields

Once an object is selected, additional fields are dynamically generated based on the Salesforce object's schema. These fields include:

  • All createable fields for the selected object
  • Required fields are marked as mandatory
  • Picklist fields display available options from Salesforce
  • Date fields show date pickers
  • Boolean fields appear as switches
NameDescription
Impersonate User(JWT Auth only) Select a Salesforce user to impersonate for this operation
[Dynamic Fields]Fields are dynamically populated based on the selected object's schema from Salesforce

Here is a sample JSON input:

// Create a Lead

{
  "objectName": "Lead",
  "FirstName": "John",
  "LastName": "Doe",
  "Company": "Acme Corporation",
  "Email": "[email protected]",
  "Phone": "+1-555-123-4567",
  "LeadSource": "Web",
  "Status": "Open - Not Contacted"
}

// Create an Account

{
  "objectName": "Account",
  "Name": "Acme Corporation",
  "Type": "Customer",
  "Industry": "Technology",
  "Phone": "+1-555-987-6543",
  "Website": "https://www.acme.com",
  "BillingCity": "San Francisco",
  "BillingState": "CA",
  "BillingCountry": "USA"
}

// Create a Contact

{
  "objectName": "Contact",
  "FirstName": "Jane",
  "LastName": "Smith",
  "AccountId": "001XXXXXXXXXXXX",
  "Email": "[email protected]",
  "Phone": "+1-555-456-7890",
  "Title": "VP of Sales"
}

// Create an Opportunity

{
  "objectName": "Opportunity",
  "Name": "Acme Corp - Enterprise License",
  "AccountId": "001XXXXXXXXXXXX",
  "Amount": 50000,
  "StageName": "Prospecting",
  "CloseDate": "2025-12-31",
  "Type": "New Business"
}

Response

Upon successful creation, the action returns the created record details including:

  • Record ID
  • Success status
  • Any errors if the creation failed

Get all records

Retrieves a list of records from a Salesforce object using SOQL queries. This action can be leveraged by Leena AI Orchestrator/Agent to list records with optional filtering and pagination. Here are some common use cases:

  • Lead Management: Get all open leads assigned to a user
  • Account Overview: Retrieve accounts by industry or region
  • Opportunity Pipeline: List opportunities by stage or close date
  • Custom Object Queries: Query any standard or custom object with filters

Input Parameters

Here are the input parameters required to set up this action:

Mandatory

NameDescription
Object NameThe Salesforce object type to query (e.g., Lead, Account, Contact)

Optional

NameDescription
Filter SOQLSOQL filter clause starting with WHERE (e.g., "WHERE Status = 'Open'")
Next Records URLURL for pagination to fetch the next page of results
Impersonate User(JWT Auth only) Select a Salesforce user to impersonate for this operation

Here is a sample JSON input:

// Get all Leads

{
  "objectName": "Lead"
}

// Get Leads with Filter

{
  "objectName": "Lead",
  "filterSOQL": "WHERE Status = 'Open - Not Contacted' AND CreatedDate = THIS_MONTH"
}

// Get Accounts by Industry

{
  "objectName": "Account",
  "filterSOQL": "WHERE Industry = 'Technology' AND AnnualRevenue > 1000000"
}

// Get Opportunities in Pipeline

{
  "objectName": "Opportunity",
  "filterSOQL": "WHERE StageName != 'Closed Won' AND StageName != 'Closed Lost' ORDER BY CloseDate ASC"
}

// Paginated Query (using nextRecordsUrl from previous response)

{
  "objectName": "Contact",
  "nextRecordsUrl": "/services/data/v61.0/query/01gD0000002HU6KIAW-2000"
}

Response

The action returns a list of records, each containing:

  • Record ID
  • All fields for the selected object
  • Total record count
  • Done flag indicating if all records have been retrieved
  • Next Records URL for pagination (if more records exist)

Get a record by its ID

Retrieves a single record from Salesforce using its unique Record ID. The Agent can leverage the skill (workflow) to fetch specific record details when the Record ID is known. Here are some common use cases:

  • Record Lookup: Get full details of a specific lead, account, or contact
  • Data Verification: Verify record information before updates
  • Related Record Fetch: Retrieve details of linked records
  • Audit Trail: Get record details for compliance purposes

Input Parameters

Here are the input parameters required to set up this action:

Mandatory

NameDescription
Object NameThe Salesforce object type (e.g., Lead, Account, Contact)
Record IDThe unique 18-character Salesforce Record ID

Optional

NameDescription
Impersonate User(JWT Auth only) Select a Salesforce user to impersonate for this operation

Here is a sample JSON input:

// Get a Lead by ID

{
  "objectName": "Lead",
  "recordId": "00Q5f00000XXXXXXXX"
}

// Get an Account by ID

{
  "objectName": "Account",
  "recordId": "001XXXXXXXXXXXX"
}

// Get a Contact by ID

{
  "objectName": "Contact",
  "recordId": "003XXXXXXXXXXXX"
}

// Get an Opportunity by ID

{
  "objectName": "Opportunity",
  "recordId": "006XXXXXXXXXXXX"
}

Response

The action returns the complete record including:

  • Record ID
  • All standard and custom fields for the object
  • System fields (CreatedDate, LastModifiedDate, etc.)
  • Related record references

Update a record by its ID

Updates an existing record in Salesforce using its Record ID. The Agent can leverage the skill (workflow), which has been designed to modify existing records in Salesforce, once the user provides the record details to be updated. The form fields are dynamically generated based on the selected Salesforce object's updateable fields. Here are some common use cases:

  • Lead Qualification: Update lead status and qualification details
  • Account Maintenance: Modify account information and contacts
  • Opportunity Updates: Change stage, amount, or close date
  • Data Correction: Fix incorrect field values

Input Parameters

Here are the input parameters required to set up this action:

Mandatory

NameDescription
Object NameThe Salesforce object type (e.g., Lead, Account, Contact)
Record IDThe unique Record ID of the record to update

Dynamic Fields

Once an object is selected, additional updateable fields are dynamically generated based on the Salesforce object's schema.

NameDescription
Impersonate User(JWT Auth only) Select a Salesforce user to impersonate for this operation
[Dynamic Fields]Updateable fields are dynamically populated based on the selected object's schema from Salesforce

Here is a sample JSON input:

// Update Lead Status

{
  "objectName": "Lead",
  "recordId": "00Q5f00000XXXXXXXX",
  "Status": "Working - Contacted",
  "Rating": "Hot"
}

// Update Account Details

{
  "objectName": "Account",
  "recordId": "001XXXXXXXXXXXX",
  "Phone": "+1-555-999-8888",
  "Website": "https://www.newwebsite.com",
  "Industry": "Financial Services"
}

// Update Contact Information

{
  "objectName": "Contact",
  "recordId": "003XXXXXXXXXXXX",
  "Title": "Chief Technology Officer",
  "Email": "[email protected]",
  "Phone": "+1-555-123-4567"
}

// Update Opportunity Stage

{
  "objectName": "Opportunity",
  "recordId": "006XXXXXXXXXXXX",
  "StageName": "Proposal/Price Quote",
  "Amount": 75000,
  "CloseDate": "2025-11-30",
  "NextStep": "Schedule demo with technical team"
}

Response

Upon successful update, the action returns:

  • HTTP status code (204 for success)
  • Confirmation of successful update
  • Any errors if the update failed

Delete a record by its ID

Deletes an existing record from Salesforce using its Record ID. The Agent can leverage the skill (workflow), which has been designed to remove records from Salesforce, once the user specifies the record to be deleted. Here are some common use cases:

  • Data Cleanup: Remove duplicate or invalid records
  • Lead Management: Delete unqualified leads
  • Record Removal: Remove obsolete accounts or contacts
  • Compliance: Delete records per data retention policies

Input Parameters

Here are the input parameters required to set up this action:

Mandatory

NameDescription
Object NameThe Salesforce object type (e.g., Lead, Account, Contact)
Record IDThe unique Record ID of the record to delete

Optional

NameDescription
Impersonate User(JWT Auth only) Select a Salesforce user to impersonate for this operation

Here is a sample JSON input:

// Delete a Lead

{
  "objectName": "Lead",
  "recordId": "00Q5f00000XXXXXXXX"
}

// Delete an Account

{
  "objectName": "Account",
  "recordId": "001XXXXXXXXXXXX"
}

// Delete a Contact

{
  "objectName": "Contact",
  "recordId": "003XXXXXXXXXXXX"
}

// Delete a Custom Object Record

{
  "objectName": "Custom_Object__c",
  "recordId": "a00XXXXXXXXXXXX"
}

Response

Upon successful deletion, the action returns:

  • HTTP status code (204 for success)
  • Confirmation of successful deletion
  • Any errors if the deletion failed