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

# Salesforce Integration

> Connect your Verbex AI Assistant with Salesforce CRM

<Note>
  **What you'll learn**

  * How to set up Salesforce API credentials
  * How to create a Salesforce Connected App
  * How to integrate Salesforce with Verbex Platform
  * How to test and verify the integration
</Note>

This guide will show you how to integrate Salesforce Lead Generation with your Verbex AI Assistant.

## Prerequisites

* A Salesforce account with administrative access
* Access to your Verbex AI Assistant
* Basic understanding of API integration

Let's walk through setting up a Salesforce lead generation integration.

## Step 1: Create Salesforce Connected App

1. Log into Salesforce
2. Navigate to Setup:
   * Click the settings gear icon
   <Frame>
     <img height="212" width="423" src="https://mintcdn.com/hishabsingaporepteltd/Wx-6A5SGbH-ne_kM/images/salesforce_example/sf_1.png?fit=max&auto=format&n=Wx-6A5SGbH-ne_kM&q=85&s=ece36ad7ccc23ac7162c2d8b82411761" data-path="images/salesforce_example/sf_1.png" />
   </Frame>
   * Select "Open Advanced Setup"
   <Frame>
     <img height="212" width="423" src="https://mintcdn.com/hishabsingaporepteltd/Wx-6A5SGbH-ne_kM/images/salesforce_example/sf_2.png?fit=max&auto=format&n=Wx-6A5SGbH-ne_kM&q=85&s=d7529050ccb9705169ddea349cfb94c3" data-path="images/salesforce_example/sf_2.png" />
   </Frame>
3. Create Connected App:
   * Go to "App -> App Manager"
   <Frame>
     <img height="212" width="423" src="https://mintcdn.com/hishabsingaporepteltd/hKDJJlbuwj-_7GRI/images/salesforce_example/sf_4.png?fit=max&auto=format&n=hKDJJlbuwj-_7GRI&q=85&s=14a2f38ee598192e8633a17b23ff304c" data-path="images/salesforce_example/sf_4.png" />
   </Frame>
   * Click "New Connected App"
   <Frame>
     <img height="212" width="423" src="https://mintcdn.com/hishabsingaporepteltd/hKDJJlbuwj-_7GRI/images/salesforce_example/sf_5.png?fit=max&auto=format&n=hKDJJlbuwj-_7GRI&q=85&s=f87c5b6680aa769a970d8fa5625667a2" data-path="images/salesforce_example/sf_5.png" />
   </Frame>
   * Select "Create a Connected App"
   <Frame>
     <img height="212" width="423" src="https://mintcdn.com/hishabsingaporepteltd/hKDJJlbuwj-_7GRI/images/salesforce_example/sf_6.png?fit=max&auto=format&n=hKDJJlbuwj-_7GRI&q=85&s=634b5133d2f3a1d1eea160ccc46051a0" data-path="images/salesforce_example/sf_6.png" />
   </Frame>

## Step 2: Configure OAuth Settings

1. Fill in Basic Information
   <Frame>
     <img height="212" width="423" src="https://mintcdn.com/hishabsingaporepteltd/hKDJJlbuwj-_7GRI/images/salesforce_example/sf_7.png?fit=max&auto=format&n=hKDJJlbuwj-_7GRI&q=85&s=a7235c18145c22665f8e7304c8b3f6ad" data-path="images/salesforce_example/sf_7.png" />
   </Frame>

2. Configure OAuth settings
   <Frame>
     <img height="212" width="423" src="https://mintcdn.com/hishabsingaporepteltd/hKDJJlbuwj-_7GRI/images/salesforce_example/sf_8.png?fit=max&auto=format&n=hKDJJlbuwj-_7GRI&q=85&s=651cd0b030068fd9dceb19211f386918" data-path="images/salesforce_example/sf_8.png" />
   </Frame>

3. Save and continue

   <Frame>
     <img height="212" width="423" src="https://mintcdn.com/hishabsingaporepteltd/hKDJJlbuwj-_7GRI/images/salesforce_example/sf_9.png?fit=max&auto=format&n=hKDJJlbuwj-_7GRI&q=85&s=f790245b8704ce81f7656cfee8ec642b" data-path="images/salesforce_example/sf_9.png" />
   </Frame>

   <Frame>
     <img height="212" width="423" src="https://mintcdn.com/hishabsingaporepteltd/Wx-6A5SGbH-ne_kM/images/salesforce_example/sf_10.png?fit=max&auto=format&n=Wx-6A5SGbH-ne_kM&q=85&s=dbbbf75e4a5ed5d67b0b8a4b88b0e69e" data-path="images/salesforce_example/sf_10.png" />
   </Frame>

4. Click "Manage Consumer Details"
   <Frame>
     <img height="212" width="423" src="https://mintcdn.com/hishabsingaporepteltd/Wx-6A5SGbH-ne_kM/images/salesforce_example/sf_11.png?fit=max&auto=format&n=Wx-6A5SGbH-ne_kM&q=85&s=1c1fbb46de20234bbf9b846495f0561d" data-path="images/salesforce_example/sf_11.png" />
   </Frame>

5. Complete verification process
   <Frame>
     <img height="212" width="423" src="https://mintcdn.com/hishabsingaporepteltd/Wx-6A5SGbH-ne_kM/images/salesforce_example/sf_12.png?fit=max&auto=format&n=Wx-6A5SGbH-ne_kM&q=85&s=96d4d84fa6389275fc3b43e14ae94b8e" data-path="images/salesforce_example/sf_12.png" />
   </Frame>

6. Save the following credentials:
   * Consumer Key (Client ID)
   * Consumer Secret
   * Username
   * Security Token

<Warning>
  Store these credentials securely - you'll need them for the integration.
</Warning>

## Step 3: Update Policies

* Go to your app and click "Edit Policies"

<Frame>
  <img height="212" width="423" src="https://mintcdn.com/hishabsingaporepteltd/Wx-6A5SGbH-ne_kM/images/salesforce_example/sf_15.png?fit=max&auto=format&n=Wx-6A5SGbH-ne_kM&q=85&s=3205d3fb84bec49049f8b91a25bf0799" data-path="images/salesforce_example/sf_15.png" />
</Frame>

* Update the following marked policies:

<Frame>
  <img height="212" width="423" src="https://mintcdn.com/hishabsingaporepteltd/Wx-6A5SGbH-ne_kM/images/salesforce_example/sf_16.png?fit=max&auto=format&n=Wx-6A5SGbH-ne_kM&q=85&s=19d518db14a07ccc3e7e70f37e6fc3c3" data-path="images/salesforce_example/sf_16.png" />
</Frame>

## Step 4: Generate Access Token

* Use this curl command template to get your access token:

```bash theme={null}
curl -X POST "https://login.salesforce.com/services/oauth2/token" \
-d "grant_type=password" \
-d "client_id=CONSUMER_KEY" \
-d "client_secret=CONSUMER_SECRET" \
-d "username=YOUR_SALESFORCE_USER_NAME" \
-d "password=YOUR_SALSEFORCE_PASSWORD_AND_SECRET_KEY"
```

<Note>
  The password should be your Salesforce password immediately followed by your security token (no spaces).
</Note>

* The response will include:

```json theme={null}
{
  "access_token": "YOUR_ACCESS_TOKEN",
  "instance_url": "https://your-instance.salesforce.com",
  "id": "",
  "token_type": "Bearer",
  "issued_at": "",
  "signature": ""
}
```

* Test your access token using and data sending CURL or Postman.

```bash theme={null}
curl -X POST "<INSTANCE_URL>/services/data/v59.0/sobjects/Lead/" \
     -H 'Authorization: Bearer ACCESS_KEY' \
     -H "Content-Type: application/json" \
     -d '{
         "LastName": "Sarker",
         "Company": "Hishab Technologies Limited",
         "Email": "sagor.sarker@example.com"
     }'
```

## Step 5: Create Custom Tool in Verbex

1. Go to "Add Tool -> Custom Tool"
2. Configure the tool:
   * **Name**: create\_lead
   * **Description**: Create new leads in Salesforce
   * **Endpoint URL**: \[Your Instance URL]/services/data/v59.0/sobjects/Lead/
   * **Method**: POST

<Frame>
  <img height="212" width="423" src="https://mintcdn.com/hishabsingaporepteltd/Wx-6A5SGbH-ne_kM/images/salesforce_example/sf_26.png?fit=max&auto=format&n=Wx-6A5SGbH-ne_kM&q=85&s=5e441ae45cebaabc06aa35fd74df6cb9" data-path="images/salesforce_example/sf_26.png" />
</Frame>

<Frame>
  <img height="212" width="423" src="https://mintcdn.com/hishabsingaporepteltd/hKDJJlbuwj-_7GRI/images/salesforce_example/sf_27.png?fit=max&auto=format&n=hKDJJlbuwj-_7GRI&q=85&s=e106af3599b06ddf1083826ca72bb0d7" data-path="images/salesforce_example/sf_27.png" />
</Frame>

3. Add Header Parameters:
   * Authorization: Bearer \[Your Access Token]
   * Content-Type: application/json

<Frame>
  <img height="212" width="423" src="https://mintcdn.com/hishabsingaporepteltd/hKDJJlbuwj-_7GRI/images/salesforce_example/sf_28.png?fit=max&auto=format&n=hKDJJlbuwj-_7GRI&q=85&s=7675512f91e5f4fa6b079ae3379f0083" data-path="images/salesforce_example/sf_28.png" />
</Frame>

4. Configure Body Parameters:

```json theme={null}
{
  "LastName": "string",
  "Company": "string",
  "Email": "string"
}
```

<Frame>
  <img height="212" width="423" src="https://mintcdn.com/hishabsingaporepteltd/hKDJJlbuwj-_7GRI/images/salesforce_example/sf_29.png?fit=max&auto=format&n=hKDJJlbuwj-_7GRI&q=85&s=e3a4a375c95783f14bbbbd6d36b52bdb" data-path="images/salesforce_example/sf_29.png" />
</Frame>

<Warning>
  Access tokens expire after 24 hours. In production, implement proper OAuth token management.
</Warning>

Everything is now set up. You can now test the tool in your AI Assistant. Like this you can connect any CRM tool to your AI Assistant.

# Best Practices

1. **Naming Convention**
   * Use clear, descriptive names
   * Follow a consistent pattern
   * Include the system name

2. **Error Handling**
   * Implement proper error catching
   * Provide clear error messages
   * Log issues for debugging

3. **Security**
   * Regularly rotate credentials
   * Use environment variables
   * Implement rate limiting

4. **Testing**
   * Test with sample data first
   * Verify error scenarios
   * Monitor integration health

# Monitoring and Maintenance

1. **Regular Checks**
   * Monitor API usage
   * Check for failed requests
   * Verify data accuracy

2. **Updates**
   * Keep API versions current
   * Update authentication tokens
   * Maintain documentation

For more details, refer to the [Salesforce API Documentation](https://developer.salesforce.com/docs).
