# Salesforce Agentforce Integration

Connect your Salesforce Agentforce environment to Capsule Security for complete visibility into your AI agents, topics, actions, and conversation activity.

## Overview

This integration syncs your Agentforce agents and captures conversation data:

| Category | What Gets Captured |
|  --- | --- |
| **Agents** | Agentforce bots with configuration, status, and metadata |
| **Subagents** | Subagents with instructions |
| **Tools** | Tools the subagents can use like Apex actions, Flows, APIs, Prompt Templates, External Services |
| **Data Sources** | Retrievers and knowledge base components |
| **Channels** | Slack and other deployment channels |
| **Conversations** | User messages, agent responses, and tool invocations |


## Prerequisites

Before you begin, ensure you have:

- **Agentforce** enabled with at least one activated agent
- **Data Cloud** enabled (required for Einstein Audit and Feedback Data)
- **Salesforce Administrator** or equivalent permissions
- **Einstein** enabled in your org (required for conversation auditing)


## Step 1: Create a Connected App

Create a Connected App in Salesforce to enable secure OAuth authentication with Capsule.

### Steps

1. Click the **gear icon** in the top-right corner and select **Setup**
2. In the Quick Find box on the left, search for **External Client App Manager**
3. Click **New External Client App** in the top-right corner
4. **Basic Information**:
  - **External Client App Name**: `CapsuleSecurity`
  - **API Name**: `CapsuleSecurity` (auto-populated)
  - **Contact Email**: Enter your admin email address
5. **API**
  - Enable OAuth
  - Callback URL

```
https://portal.eu-west4.capsulesecurity.io/integrations/callback/AGENTFORCE
https://portal.us-east1.capsulesecurity.io/integrations/callback/AGENTFORCE
```
  - Add the following **Selected OAuth Scopes** (click Add for each):
    - Manage user data via APIs (api)
  - **Flow Enablement:**
    - Client Credential Flow
  - **Security** (Default Values):
    - Require Secret for Web Server Flow
    - Require secret for Refresh Token Flow
    - Require Proof Key for Code Exchange (PKCE) extension for Supported Authorization Flows
6. Click **Create** at the bottom of the page. Your Connected App settings should look like this:


![Connected App OAuth Settings](/assets/salesforce-connected-app-settings.388a1561f81de5902d22f1587ca1ce3b00cb36dc6eeb6477d23974d5745aea0c.7f7411d4.png)

1. Under **Policies** open **OAuth Policies** click **Enable Client Credentials Flow** and add the user we should use its scope


### Why these scopes?

| Scope | Purpose |
|  --- | --- |
| api | Access Salesforce data and metadata |


1. Go to settings and under **OAuth Settings** and click **Consumer Key and Secret**


## Step 2: Enable Einstein Audit and Feedback (Recommended)

Enable Einstein auditing to capture agent conversations in Capsule. Without this, conversation data may not be available.

### Steps

1. In Setup, search for **Einstein Audit, Analytics, and Monitoring Setup**
2. Turn on:
  - **Audit and Feedback**
  - **Agentforce Session Tracing**


### Why is this needed?

Einstein Audit and Feedback Data enables conversation logging for Agentforce agents. This allows Capsule to capture:

- User messages and agent responses
- Topic classifications
- Tool invocations and results
- Session metadata


## Step 3: Configure the Integration in Capsule

Connect your Salesforce org to Capsule using the credentials from Step 5.

### Steps

1. Log in to the **Capsule Security** portal
2. Click **Integrations** in the left sidebar
3. Find the **Salesforce Agentforce** card and click **Set up Integration**


1. Enter your credentials:
  - **Domain name**: From the URL
  - **Consumer Key**: Paste from Step 1
  - **Consumer Secret**: Paste from Step 1
2. Click **Connect**


### After setup

- Initial sync begins automatically
- First sync may take several minutes depending on data volume
- View synced agents in **Inventory → Agents**
- View conversations in **Observability → Filter Activity Type - Session**


## What Gets Captured

Capsule captures the following data from your Agentforce environment:

| Entity Type | Category | Description |
|  --- | --- | --- |
| **Agentforce Agents** | Model Agent | Bot configuration, status, languages, tone settings |
| **Apex Actions** | Tool | Custom Apex code invoked by agents |
| **Flow Actions** | Tool | Salesforce Flow automations triggered by agents |
| **API Actions** | Tool | REST API endpoints called by agents |
| **Prompt Templates** | Tool | Templates for generating agent responses |
| **Retrievers** | Data Source | Knowledge base and data retrieval components |
| **RAGs** | Data Source | Agent RAGs |
| **External Services** | Tool | External service integrations |
| **Predictive Models** | Tool | ML models used for predictions |
| **Slack Channels** | Access Channel | Slack deployment integrations |


## Verification

After setup, verify that data is syncing correctly.

### Check agents

1. In Capsule, navigate to **Inventory → Agents**
2. Look for your Agentforce agents in the list
3. Click on an agent to view it


### Check conversations

1. Navigate to **Observability**
2. Look for recent Agentforce conversations
3. Click on a session to view the full conversation transcript


## Troubleshooting

### No conversations appearing in Capsule

- Verify Einstein Audit and Feedback Data is enabled
- Check that your agent is activated and has handled conversations
- Initial sync may take several minutes


### OAuth authorization fails

- Verify the Callback URL matches exactly the URL is step 1
- Ensure all required OAuth scopes are selected
- Check that Client Credentials Flow is enabled


### Agent not showing

- Verify the agent is **Activated** in Agentforce
- Ensure your Salesforce user has permission to access the agent


## Support

For help with this integration:

- **Email**: support@capsule.security
- **Include**: Your Salesforce Org ID, integration status, and any error messages


For Salesforce Agentforce issues:

- **Salesforce Help**: [help.salesforce.com](https://help.salesforce.com)
- **Agentforce Documentation**: [developer.salesforce.com/docs/einstein/genai](https://developer.salesforce.com/docs/einstein/genai)