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

# Salesforce Integration

> Link RecordEngine documents to Salesforce Opportunities, Accounts, and Contacts — and push extracted data back to Salesforce automatically.

The Salesforce integration creates a bidirectional pipeline between RecordEngine and your Salesforce org. Documents processed in RecordEngine are linked to Salesforce records, extracted data flows back to update Opportunities and Accounts, and your sales team gets a direct link from any Salesforce record to the full document in RecordEngine.

***

## What the Integration Does

<CardGroup cols={2}>
  <Card title="Link documents to Salesforce records" icon="link">
    Pass a Salesforce Opportunity, Account, or Contact ID at upload time. The document is permanently associated with that CRM record and the reference travels through the entire processing pipeline.
  </Card>

  <Card title="Push extracted data to Salesforce" icon="arrow-right">
    When a document is exported, an automation scenario reads the extracted fields and updates the corresponding Salesforce record — deal amounts, close dates, contact details, and any custom fields.
  </Card>

  <Card title="Post AI summaries as Chatter notes" icon="comment">
    The AI summary from each processed document is posted to Salesforce as a Chatter post or Activity Note on the associated record — giving your team instant context without opening RecordEngine.
  </Card>

  <Card title="Deep-link back to the document" icon="arrow-up-right-from-square">
    The direct URL to each document in RecordEngine is stored on the Salesforce record. Your team jumps from an Opportunity straight to the full document, extracted fields, and approval status in one click.
  </Card>
</CardGroup>

***

## How It Works — The Two Scenarios

The Salesforce integration uses two automation scenarios that work together:

**Scenario A — Salesforce → RecordEngine**
A trigger in Salesforce (stage change, new attachment, scheduled) causes a document to be uploaded to RecordEngine with the Salesforce record ID attached.

**Scenario B — RecordEngine → Salesforce**
When RecordEngine exports a document, the outbound webhook fires and an automation updates the corresponding Salesforce record with the extracted data.

***

## Step 1 — Connect Salesforce in Your Automation Platform

Connect your Salesforce org using the native Salesforce connector in your automation platform. You'll need:

* Salesforce account with API access (Professional edition or above)
* Admin or API-enabled user profile
* OAuth connection authorised through your automation platform

***

## Step 2 — Build Scenario A (Salesforce → RecordEngine)

This scenario uploads documents to RecordEngine automatically when triggered by a Salesforce event.

**Trigger:** Salesforce — Watch Records (e.g. Opportunity Stage changed to "Proposal Sent")

**Action 1:** Salesforce — Get Related Files
Retrieve any attachments linked to the triggering Opportunity.

**Action 2:** Salesforce — Download Attachment
Download the file content for each attachment.

**Action 3:** HTTP — POST to RecordEngine Upload API

```
POST https://YOUR-INSTANCE/api/documents/upload
Authorization: Bearer YOUR_TOKEN
Content-Type: multipart/form-data

file: [downloaded file]
contact_id: [your default contact or mapped from Salesforce Account]
folder_id: [target folder ID]
profile_id: [extraction profile ID]
external_refs: {
  "salesforce": {
    "record_id": "{{opportunity.id}}",
    "record_type": "Opportunity",
    "record_url": "https://yourorg.salesforce.com/{{opportunity.id}}"
  }
}
```

**Action 4:** Salesforce — Update Opportunity
Store the returned RecordEngine `document_id` on the Opportunity (in a custom field) so you can look it up later.

<img src="https://mintlify.s3.us-west-1.amazonaws.com/recordengineai/images/integrations/automation-scenario-salesforce-a.png" alt="Scenario A — Salesforce trigger to RecordEngine upload" className="rounded-lg" />

***

## Step 3 — Build Scenario B (RecordEngine → Salesforce)

This scenario receives the RecordEngine outbound webhook and updates Salesforce when a document is approved and exported.

**Trigger:** Webhooks — Custom Webhook
Copy the generated URL and paste it into **RecordEngine Settings → Document Webhook URL**.

**Action 1:** Parse the incoming webhook payload

**Action 2:** Salesforce — Update Record

* Object: use `external_refs.salesforce.record_type` from the payload (e.g. `Opportunity`)
* Record ID: use `external_refs.salesforce.record_id`
* Map extracted fields to Salesforce fields (see field mapping table below)

**Action 3 (optional):** Salesforce — Create Note or Chatter Post

* Set the body to `ai_summary` from the payload
* Associate it with the record using the same record ID

**Action 4 (optional):** Salesforce — Update Custom URL Field

* Map `doc_url` from the payload to a custom URL field on the Opportunity (e.g. `RecordEngine_Document_URL__c`)

<img src="https://mintlify.s3.us-west-1.amazonaws.com/recordengineai/images/integrations/automation-scenario-salesforce-b.png" alt="Scenario B — RecordEngine webhook to Salesforce update" className="rounded-lg" />

***

## Salesforce Field Mapping Reference

| RecordEngine field | Salesforce field    | Object      | Notes                                 |
| ------------------ | ------------------- | ----------- | ------------------------------------- |
| `total_amount`     | `Amount`            | Opportunity | Standard field                        |
| `invoice_date`     | `CloseDate`         | Opportunity | If invoice date = contract date       |
| `vendor`           | `Name`              | Account     | For vendor account lookup             |
| `invoice_number`   | Custom field        | Opportunity | Create `Invoice_Number__c`            |
| `currency`         | `CurrencyIsoCode`   | Opportunity | Multi-currency orgs only              |
| `ai_summary`       | Note / Chatter body | Any         | Posted as an Activity                 |
| `doc_url`          | Custom URL field    | Any         | Create `RecordEngine_Document_URL__c` |
| `confidence_score` | Custom number field | Any         | Create `RE_Confidence_Score__c`       |

<Info>
  Salesforce custom field API names end with `__c`. To create a custom URL field on Opportunity: Setup → Object Manager → Opportunity → Fields & Relationships → New → URL field type.
</Info>

***

## Setting Up the Custom Fields in Salesforce

Create these two custom fields on your most-used object (typically Opportunity) to get full value from the integration:

**RecordEngine Document URL** — stores the deep-link back to the document:

1. Setup → Object Manager → Opportunity → Fields & Relationships → New
2. Data Type: **URL**
3. Field Label: `RecordEngine Document`
4. Field Name: `RecordEngine_Document` (API name becomes `RecordEngine_Document__c`)
5. Add to the Opportunity page layout

**RecordEngine Confidence Score** — stores the AI confidence for reporting:

1. Repeat above with Data Type: **Number**, decimal places: 0
2. Field Label: `RE Confidence Score`
3. Field Name: `RE_Confidence_Score` (API name: `RE_Confidence_Score__c`)

***

## Testing the Integration

<Steps>
  <Step title="Test Scenario B first">
    Use [webhook.site](https://webhook.site) temporarily as your webhook URL. Export a document in RecordEngine and inspect the exact payload — confirm all field names and the `external_refs` structure.
  </Step>

  <Step title="Switch to your automation platform">
    Replace the webhook.site URL with your automation platform's incoming webhook URL. Re-export the same document and confirm the scenario executes without errors.
  </Step>

  <Step title="Verify the Salesforce update">
    Open the Salesforce Opportunity that was referenced in `external_refs`. Confirm the extracted fields updated correctly and the document URL is saved.
  </Step>

  <Step title="Test Scenario A">
    Trigger the Salesforce event (e.g. move an Opportunity to the watched stage). Confirm a document upload appears in RecordEngine within 30 seconds.
  </Step>
</Steps>

***

## Troubleshooting

| Issue                                 | Fix                                                                                                                                        |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| Salesforce record not updating        | Check `external_refs.salesforce.record_id` in the payload — it must be a valid 15 or 18-character Salesforce ID                            |
| `INVALID_FIELD` error from Salesforce | The field API name in your mapping is wrong — confirm it ends with `__c` for custom fields and matches exactly what's in Salesforce Setup  |
| `INSUFFICIENT_ACCESS` error           | The connected Salesforce user doesn't have edit access to the record or field — check the user's profile and field-level security settings |
| Note not appearing on record          | Confirm the Note's `ParentId` is set to the Opportunity/Account ID, not left blank                                                         |
| Webhook not firing                    | Confirm the Document Webhook URL is saved in RecordEngine Settings and the document reached **Export** status (not just Approved)          |

For more help see [Integration Troubleshooting](/troubleshooting/integration-issues).
