> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# Salesforce

## 概要

ElevenLabs AIエージェントをSalesforce CRMに接続して、顧客データへのアクセス、リードの管理、商談の作成を行えます。このインテグレーションにより、エージェントは既存の顧客レコードの取得、新しいリードとコンタクトの作成、会話中のSalesforceオブジェクトのクエリを行えます。

## 機能

| 機能           | サポート状況                                      |
| ------------ | ------------------------------------------- |
| ゼロ保持モード（ZRM） | 非対応                                         |
| トリガー内の添付ファイル | 非対応 — 受信したケースコメントやメールの添付ファイルはエージェントに転送されません |
| ツール内の添付ファイル  | 非対応 — ツールはテキストのみを処理します                      |

## セットアップ

このインテグレーションでは、認証に**Salesforce OAuth 2.0 Client Credentials**を使用します。SalesforceでExternal Client Appを作成する必要があります。

#### External Client Appを作成する

1. 管理者としてSalesforce組織にログインします
2. **Setup** > **External Client App Manager**に移動します
3. **New External Client App**をクリックします
4. **External Client App Name**（例：`ElevenLabs Agents`）、**API Name**、**Contact Email**を入力します
5. \*\*API (Enable OAuth Settings)\*\*で以下を設定します：
   * **Enable OAuth**と**Enable Client Credentials Flow**をオンにします
   * **Callback URL**：`https://api.elevenlabs.io/oauth/callback`
   * **OAuth Start URL**：`https://api.elevenlabs.io/oauth/start`
   * **Selected OAuth Scopes**：次のスコープを追加します：
     * **Full access (full)**
     * **Perform requests on your behalf at any time (refresh_token, offline_access)**
     * **Manage user data via api**
6. **Create**をクリックします
7. アプリページで**Settings**タブを開き、**OAuth Settings**に移動して**Consumer Key and Secret**をクリックします
8. **Consumer Key**と**Consumer Secret**をコピーします。認証時に必要です

#### OAuth Client Credentialsフローを設定する

> **Warning**
>
> Client Credentials Flowは、ユーザー操作が不要なサーバー間インテグレーションに推奨されます。
> Salesforce管理者がこのフローを有効にしていることを確認してください。

1. External Client Appで**Edit**をクリックします
2. **Enable Client Credentials Flow**をオンにします。**Run As**フィールドが表示されます
3. **Run As**に管理者ユーザーまたは専用サービスアカウントを設定します。これにより、すべてのAPI呼び出しの権限が決まります
4. **Permitted Users**を**Admin approved users are pre-authorized**に設定します
5. **Save**をクリックします

**Run As**ユーザーにより、すべてのAPI呼び出しの権限が決まります。System Administratorプロファイルのユーザー、またはAPIアクセスとエージェントが必要とするオブジェクト（Contact、Lead、Accountなど）への権限を持つカスタムプロファイルのユーザーを選択してください。ユーザーレコードでは、**API Enabled**権限をオンにする必要があります。

#### Salesforceドメインを確認する

API呼び出しにはSalesforceドメインが必要です。

**方法1：現在のURLを確認する**

Salesforceにログイン中、ブラウザのアドレスバーを確認します：

* **Lightning Experience**：`https://acme.lightning.force.com/`
* **My Domain**：`https://acme.my.salesforce.com/`

**方法2：Setup > Company Information**

**Setup** > **Company Information**に移動し、**My Domain**のURLまたは組織情報を確認します。

**方法3：Setup > Domain Management**

**Setup** > **Domain Management** > **My Domain**に移動します。ページ上部にドメインが表示されます。

**一般的なドメイン形式：**

* `https://acme.my.salesforce.com`（My Domain）
* `https://acme.lightning.force.com`（Lightning）
* `https://acme.develop.my.salesforce.com`（Sandbox）

> **Note**
>
> 末尾のスラッシュを付けずに、完全なドメインを使用してください。

#### ElevenLabsで接続する

ElevenLabsのインテグレーション設定で、Salesforceの**インスタンスホスト名**（例：`acme.my.salesforce.com`）、**Client ID**（Consumer Key）、**Client Secret**（Consumer Secret）を入力します。

## デモ動画

> **Note**
>
> このデモでは、レガシーWebhookツールを使用しています。ネイティブのSalesforceインテグレーションを
> 使用している場合、ツールは自動的に設定されるため、Webhookを手動で設定する必要はありません。

## 仕組み

#### 概要

#### 最初の顧客問い合わせ

エージェントは顧客情報を収集し、ビジネス要件と現在の課題を把握するために関連する質問をします。

#### 顧客データの検索

エージェントは`salesforce_search_records`を使用して既存のレコードを確認し、連絡先、取引先、リードを検索します。`salesforce_get_record`で詳細情報を取得し、その情報をもとに会話をパーソナライズします。

#### リードの評価

顧客が新規の場合、エージェントは連絡先情報を収集し、ビジネスニーズを評価して、適切な営業プロセスまたはルーティングを判断します。

#### レコードの作成

エージェントは`salesforce_create_record`を使用して適切なレコード（リード、連絡先、商談）を作成し、顧客に作成を確認して次のステップを説明します。

#### 詳細なシステムプロンプト

```text
# Personality

You are a helpful sales assistant responsible for managing customer relationships and creating records in Salesforce using the available tools. Be friendly, professional, and consultative in your approach.

# Environment

You operate in a sales setting via voice or chat interface, where you engage with potential customers to gather information, check for existing CRM data, and create Salesforce records when necessary.

# Tone

Begin by asking about the customer's business needs and current challenges.

Then, ask relevant qualification questions to understand their requirements, one question at a time, and wait for their response before proceeding.

Once you have basic information about the customer, say you will check for any existing records in the system.

Use any existing information to personalize the conversation and avoid asking for data you already have.

When discussing opportunities, always reference them by name (e.g., "Q1 Enterprise Deal") rather than by ID.

# Goal

After checking existing records, qualify the customer by gathering:
- Company name and size
- Industry and business type
- Current challenges and pain points
- Budget and timeline information
- Decision-making authority

Once you have qualified the customer, gather the following contact details:
- Full name and job title
- Business email address (ensure it's formatted correctly)
- Phone number
- Company name and address

Read the email back to the customer to confirm accuracy.

Once all information is confirmed, explain that you will create a record in our system.

Create the appropriate record (Lead, Contact, or Opportunity) using the `salesforce_create_record` tool.

Thank the customer and explain the next steps in the sales process.

# Guardrails

- Always check for existing records before creating new ones.
- If the customer asks to proceed, do so with the existing information.
- Qualify leads appropriately based on their responses.
- Do not discuss topics outside of business solutions and sales.
- Always maintain professional communication.
- Protect customer privacy and handle data securely.

# Tools

- Call `salesforce_search_records` to look for existing contacts, accounts, or leads (always include Name fields and human-readable information in your SOQL queries).
- If found, call `salesforce_get_record` to get detailed information about the existing record.
- Use `salesforce_create_record` to generate Leads, Contacts, or Opportunities after qualification.
```

> **Tip**
>
> ツールの認可は、トークン更新を自動的に処理するWorkplace Auth Connectionsで管理できます。
> ツールは会話の品質を向上させるため、技術的なIDではなく、人が読める名前と説明を返します。

## ツール設定

利用可能なWebhookツールは`salesforce_search_records`、`salesforce_get_record`、`salesforce_create_record`の3つです。それぞれの認可はWorkplace Auth Connectionを使用して設定します。

### 認可 - Workplace OAuth2接続

#### Workplace Auth Connectionsに移動する

ElevenLabsダッシュボードで、**Agents** > **Workplace Auth Connections**に移動し、**Add Auth**をクリックします。

#### Salesforce接続を設定する

Salesforceインテグレーション用に以下の項目を入力します：

**接続名**：`Salesforce CRM`

**Client ID**

* External Client AppのConsumer Key
* 例：`3MVG9JJlvRU3L4pRiOu8pQt5xXB4xGZGm0yW...`

**Client Secret**

* External Client AppのConsumer Secret
* 例：`1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF...`

**Token URL**

* SalesforceドメインのOAuthトークンエンドポイント
* 形式：`https://{domain}.my.salesforce.com/services/oauth2/token`
* 例：`https://acme.my.salesforce.com/services/oauth2/token`

**Scopes（任意）**

* Salesforce APIアクセス用のOAuthスコープ
* 推奨：`full, api, refresh_token`
* External Client Appのデフォルトスコープを使用する場合は空欄のままにします

**Extra Parameters（JSON）**

* 設定固有の追加OAuthパラメータ
* Client Credentialsフローの例：

```json
{
  "grant_type": "client_credentials"
}
```

#### 認証接続を作成する

**Create auth connection**をクリックして設定を追加します。

#### ツール設定で使用する

接続に成功したら保存し、Webhookツール設定の**Authentication**セクションで参照します。

> **Tip**
>
> Workplace Auth Connectionsはトークン更新を自動的に処理するため、トークンを手動で
> 管理する必要はありません。

### Webhookツール設定

各ツールの**Authentication**セクションにWorkplace Auth Connection（OAuth2）を追加します。以下のタブで各ツールの設定を確認してください。

#### salesforce_search_records

**名前：** salesforce_search_records
**説明：** SOQLクエリを使用してSalesforce内の既存レコードを検索します。IDだけでなく、名前を含む人が読める情報を常に返します。
**メソッド：** GET
**URL：** `https://acme.my.salesforce.com/services/data/v58.0/query/?q={soql_query}`

**ヘッダー：**

* **Content-Type：** `application/json`

**クエリパラメータ：**

* **q：** SOQLクエリ文字列（例："SELECT Id, Name, Email FROM Contact WHERE Email = '[example@email.com](mailto:example@email.com)'"）

**ツールJSON：**

```json
{
  "type": "webhook",
  "name": "salesforce_search_records",
  "description": "Searches for existing records in Salesforce using SOQL queries. Always returns human-readable names and details, not just IDs.",
  "api_schema": {
    "url": "https://acme.my.salesforce.com/services/data/v58.0/query/",
    "method": "GET",
    "path_params_schema": [],
    "query_params_schema": [
      {
        "id": "q",
        "type": "string",
        "description": "SOQL query string to search for records. Always include Name fields and other human-readable information. Example: SELECT Id, Name, Email, Phone, Company FROM Contact WHERE Email = 'customer@example.com'. For Opportunities, include: SELECT Id, Name, StageName, Amount, CloseDate, Account.Name FROM Opportunity",
        "dynamic_variable": "",
        "constant_value": "",
        "required": true,
        "value_type": "llm_prompt"
      }
    ],
    "request_body_schema": null,
    "request_headers": [
      {
        "type": "value",
        "name": "Content-Type",
        "value": "application/json"
      }
    ]
  },
  "response_timeout_secs": 30,
  "dynamic_variables": {
    "dynamic_variable_placeholders": {}
  }
}
```

#### salesforce_get_record

**名前：** salesforce_get_record
**説明：** 特定のSalesforceレコードに関する詳細情報を取得します。
**メソッド：** GET
**URL：** `https://acme.my.salesforce.com/services/data/v58.0/sobjects/{object_type}/{record_id}`

**ヘッダー：**

* **Content-Type：** `application/json`

**パスパラメータ：**

* **object_type：** Salesforceオブジェクトタイプ（Contact、Lead、Accountなど）
* **record_id：** 一意のSalesforceレコードID

**ツールJSON：**

```json
{
  "type": "webhook",
  "name": "salesforce_get_record",
  "description": "Retrieves detailed information about a specific Salesforce record.",
  "api_schema": {
    "url": "https://acme.my.salesforce.com/services/data/v58.0/sobjects/{object_type}/{record_id}",
    "method": "GET",
    "path_params_schema": [
      {
        "id": "object_type",
        "type": "string",
        "description": "The Salesforce object type (Contact, Lead, Account, Opportunity, etc.)",
        "dynamic_variable": "",
        "constant_value": "",
        "required": true,
        "value_type": "llm_prompt"
      },
      {
        "id": "record_id",
        "type": "string",
        "description": "The unique Salesforce record ID obtained from search results",
        "dynamic_variable": "",
        "constant_value": "",
        "required": true,
        "value_type": "llm_prompt"
      }
    ],
    "query_params_schema": [],
    "request_body_schema": null,
    "request_headers": [
      {
        "type": "value",
        "name": "Content-Type",
        "value": "application/json"
      }
    ]
  },
  "response_timeout_secs": 30,
  "dynamic_variables": {
    "dynamic_variable_placeholders": {}
  }
}
```

#### salesforce_create_record

**名前：** salesforce_create_record
**説明：** Salesforceに新しいレコードを作成します。
**メソッド：** POST
**URL：** `https://acme.my.salesforce.com/services/data/v58.0/sobjects/{object_type}/`

**ヘッダー：**

* **Content-Type：** `application/json`

**パスパラメータ：**

* **object_type：** 作成するSalesforceオブジェクトタイプ（Lead、Contact、Accountなど）

**本文パラメータ：**

* レコードのフィールドと値を含む**動的JSONオブジェクト**

**ツールJSON：**

```json
{
  "type": "webhook",
  "name": "salesforce_create_record",
  "description": "Creates a new record in Salesforce (Lead, Contact, Account, Opportunity, etc.)",
  "api_schema": {
    "url": "https://acme.my.salesforce.com/services/data/v58.0/sobjects/{object_type}/",
    "method": "POST",
    "path_params_schema": [
      {
        "id": "object_type",
        "type": "string",
        "description": "The Salesforce object type to create (Lead, Contact, Account, Opportunity, etc.)",
        "dynamic_variable": "",
        "constant_value": "",
        "required": true,
        "value_type": "llm_prompt"
      }
    ],
    "query_params_schema": [],
    "request_body_schema": {
      "id": "record_data",
      "type": "object",
      "description": "Record data for the new Salesforce record",
      "required": true,
      "properties": [
        {
          "id": "FirstName",
          "type": "string",
          "description": "First name of the contact or lead",
          "dynamic_variable": "",
          "constant_value": "",
          "required": false,
          "value_type": "llm_prompt"
        },
        {
          "id": "LastName",
          "type": "string",
          "description": "Last name of the contact or lead",
          "dynamic_variable": "",
          "constant_value": "",
          "required": true,
          "value_type": "llm_prompt"
        },
        {
          "id": "Email",
          "type": "string",
          "description": "Email address. Must be properly formatted: user@domain.com",
          "dynamic_variable": "",
          "constant_value": "",
          "required": true,
          "value_type": "llm_prompt"
        },
        {
          "id": "Phone",
          "type": "string",
          "description": "Phone number of the contact or lead",
          "dynamic_variable": "",
          "constant_value": "",
          "required": false,
          "value_type": "llm_prompt"
        },
        {
          "id": "Company",
          "type": "string",
          "description": "Company name (required for Lead object)",
          "dynamic_variable": "",
          "constant_value": "",
          "required": false,
          "value_type": "llm_prompt"
        },
        {
          "id": "Title",
          "type": "string",
          "description": "Job title of the contact or lead",
          "dynamic_variable": "",
          "constant_value": "",
          "required": false,
          "value_type": "llm_prompt"
        },
        {
          "id": "Industry",
          "type": "string",
          "description": "Industry of the lead's company",
          "dynamic_variable": "",
          "constant_value": "",
          "required": false,
          "value_type": "llm_prompt"
        },
        {
          "id": "Description",
          "type": "string",
          "description": "Additional notes or description about the lead/contact",
          "dynamic_variable": "",
          "constant_value": "",
          "required": false,
          "value_type": "llm_prompt"
        }
      ]
    },
    "request_headers": [
      {
        "type": "value",
        "name": "Content-Type",
        "value": "application/json"
      }
    ]
  },
  "response_timeout_secs": 30,
  "dynamic_variables": {
    "dynamic_variable_placeholders": {}
  }
}
```

## 一般的なSalesforceオブジェクト

| オブジェクト          | 用途                 | 一般的なフィールド                                              |
| --------------- | ------------------ | ------------------------------------------------------ |
| **Lead**        | まだ評価されていない見込み顧客    | FirstName、LastName、Email、Phone、Company、Industry、Status |
| **Contact**     | 取引先に関連付けられた評価済みの個人 | FirstName、LastName、Email、Phone、AccountId、Title         |
| **Account**     | 組織または企業            | Name、Type、Industry、Phone、BillingAddress                |
| **Opportunity** | 進行中の商談             | Name、StageName、Amount、CloseDate、AccountId              |
| **Case**        | カスタマーサービスのリクエスト    | Subject、Description、Status、Priority、ContactId          |

## よく使われるSOQLクエリ

エージェントのシステムプロンプトをカスタマイズする際の出発点として、これらのSOQLクエリを使用してください。すべてのクエリは技術的なIDではなく、人が読み取れる情報を返します。

### メールアドレスで連絡先を検索

```sql
SELECT Id, Name, Email, Phone, Title, Account.Name, Account.Type FROM Contact WHERE Email = 'customer@example.com'
```

### メールアドレスまたは電話番号でリードを検索

```sql
SELECT Id, Name, Email, Phone, Company, Industry, Status, LeadSource, Title FROM Lead WHERE Email = 'customer@example.com' OR Phone = '+1234567890'
```

### 名前で取引先を検索

```sql
SELECT Id, Name, Type, Industry, Phone, BillingCity, BillingState, Website FROM Account WHERE Name LIKE '%Company Name%'
```

### 最近の商談を検索

```sql
SELECT Id, Name, StageName, Amount, CloseDate, Account.Name, Account.Type, Owner.Name, Description FROM Opportunity WHERE CreatedDate = THIS_MONTH
```

### 取引先で商談を検索

```sql
SELECT Id, Name, StageName, Amount, CloseDate, Probability, NextStep, Owner.Name FROM Opportunity WHERE Account.Name LIKE '%Company Name%'
```

## インテグレーションのテスト

External Client Appを設定してインテグレーションを接続したら、本番環境にデプロイする前にテストしてください。

1. **検索機能**：エージェントに既存の連絡先を検索するよう依頼します。
2. **レコード作成**：エージェントに新しいリードまたは連絡先を作成させます。
3. **データ取得**：エージェントが詳細な顧客情報を取得できることを確認します。

## ケースコメントトリガー：Email-to-Caseのメール返信

**Salesforce Case Comment**トリガー（Service Cloudのケースに対するエージェントの自動応答）を有効にしている場合、受信メールが1通以上あるケースへの返信は、単なる内部ケースコメントではなく、実際のスレッド形式のメールとして顧客に送信されます。これはケースの**Origin**選択リスト値ではなく、ケースに受信メールがあるかどうかに基づくため、組織で「Email」そのものではなく「Email - Returns」のようなカスタムOrigin値を使用していても正常に機能します。受信メールのないケースには、これまでどおり公開ケースコメントが投稿されます。顧客の元のメールでCCに含まれていたアドレスも、人間のエージェントが「全員に返信」する場合と同様に、返信時に自動でCCに追加されます。ただし、組織のEmail-to-Caseルーティングアドレスは意図的にCCから除外されます。これにより、返信がEmail-to-Caseによって再受信され、エージェント自身のメッセージで再トリガーされることを防ぎます。

メール返信の送信には、ケースコメントだけの場合に必要な設定に加えて、以下の設定が必要です。

* **Run As**ユーザーのプロファイルまたは権限セットで、インテグレーションに必要な**API Enabled**権限に加え、**Send Email**システム権限を有効にする必要があります（`Setup` > `Users` > `Profiles`の「System Permissions」）。
* 組織の**Email Deliverability**設定（`Setup` > `Email` > `Deliverability`）で外部メールを許可する必要があります。Sandboxではデフォルトで制限付き設定になっており、送信メールが通知なくブロックされます。
* Run Asユーザー自身のメールボックスではなくサポート用エイリアスから返信を送信する場合は、トリガーの**Org-Wide Email Address Id**フィールドに**Organization-Wide Email Address**のIdを設定します（`Setup` > `Organization-Wide Addresses` > アドレスをクリック > URLからIdをコピー）。空白のままにすると、Run Asユーザー自身のアドレスから送信されます。
* トリガーの\*\*Email-to-Case Routing Address(es)\*\*フィールドに、組織のEmail-to-Caseアドレスを設定します（複数ある場合はカンマ区切り、`Setup` > `Email-to-Case`）。これを設定しない場合、インテグレーションは顧客メールの`To`アドレスからルーティングアドレスを推測します。この方法では、ルーティングアドレスが主な受信者ではなくCCにのみ含まれていたケースを検出できません。その状況で返信にCCとして追加すると、エージェント自身のメッセージで再トリガーされます。

顧客の組織でこれらが設定されていない場合、メール送信に失敗すると公開ケースコメントの投稿にフォールバックするため、返信が通知なく失われることはありません。ただし、上記を設定するまで、顧客はメールで返信を受け取れません。

## セキュリティに関する考慮事項

* すべてのAPI呼び出しにHTTPSエンドポイントを使用してください。
* Salesforceで適切な項目レベルのセキュリティが設定されていることを確認してください。
* Run Asユーザーの権限によって、インテグレーションがアクセスできるデータが決まります。適切にスコープを設定してください。
* APIアクセスと利用状況を定期的に監査してください。

## 便利なリンク

* [Salesforce REST APIドキュメント](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/)
* [SOQLクエリ言語リファレンス](https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/)
* [External Client AppsとOAuth 2.0](https://help.salesforce.com/s/articleView?id=sf.connected_app_overview.htm)
* [Salesforceセキュリティのベストプラクティス](https://help.salesforce.com/s/articleView?id=sf.security_overview.htm)