Salesforce
Salesforce org を Squid に接続し、CRM record を管理して Salesforce data を検索します
Salesforce Connector の Functionality
Salesforce connector を使用すると、Squid AI agent は Salesforce org 内の record を操作できます。connector は Opportunity、Case、Account、Incident object をサポートします。
| Capability | 説明 |
|---|---|
| 取得、作成、更新、削除 | Opportunity、Case、Account、Incident の完全な record CRUD |
| Object の記述 | field、type、picklist value、record type などの object metadata を取得 |
| Semantic search | sync 済み Opportunity および Case record を自然言語で検索 |
| Knowledge article search | Salesforce Knowledge article を自然言語で検索 |
record sync を有効にすると、Squid は Opportunity と Case record(および optional で Salesforce Knowledge article)を knowledge base に index 化し、10 分ごとに refresh します。これにより、agent は direct record lookup に加え、「この billing issue に類似する open case を検索して」のような question に回答できます。
Salesforce Connected App の作成
connector は OAuth 2.0 Client Credentials Flow を使用して authenticate するため、user login は必要ありません。
-
Salesforce Setup で、OAuth を有効にした Connected App(または External Client App)を作成します。
-
OAuth setting で、Manage user data via APIs (
api) scope を追加します。 -
app の Client Credentials Flow を有効にします。
-
Client Credentials Flow 用の run-as user(execution user)を assign します。この user の permission により connector が access できる対象が決まるため、user の profile または permission set に、使用する予定の object(Opportunity、Case、Account、Incident、および article sync を有効にする場合は Salesforce Knowledge)への access が付与されていることを確認してください。
-
app の Consumer Key と Consumer Secret を copy します。
詳細については、Client Credentials Flow 用の Connected App の構成に関する Salesforce documentationを参照してください。
Squid Application に Salesforce Connector を追加する
-
Squid Console の Connectors tab に移動します。
-
Available Connectors をクリックします。
-
Salesforce connector を見つけ、Add Connector を選択します。
-
次の configuration detail を指定します。
Connector ID: code 内で connector を一意に識別する string。
Domain: protocol を含み、trailing slash を含まない Salesforce instance の domain。例: https://mycompany.my.salesforce.com。
Consumer Key: Connected App の Consumer Key。
Consumer Secret: Connected App の Consumer Secret。Squid secret として安全に保存されます。
Sync Opportunities: semantic search 用に Opportunity record の indexing を有効にします。
Sync Cases: semantic search 用に Case record の indexing を有効にします。
Sync Knowledge Articles: documentation と FAQ に対する semantic search 用に、Salesforce Knowledge article の knowledge base への indexing を有効にします。
Sync History Days: sync する record history の日数。default は 30 です。
semantic search は、sync を有効にした record type のみを対象とします。sync option を有効にした後、initial sync が完了するまでしばらく待機してください。Knowledge article sync は、published English(en_US)article を index 化します。
Application で Salesforce Connector を使用する
No-code Studio
-
Squid Console の Studio tab に移動します。
-
Create AI Agent をクリックします。
-
"sales-agent"や"This agent helps the user manage Salesforce records"などの agent ID と description を指定します。 -
Add Abilities をクリックします。
-
Salesforce entry を expand し、先ほど作成した Salesforce connector を選択します。
-
「user が Salesforce opportunity、case、account、incident を lookup または管理したい場合にこれを call する」など、agent がこの connection を使用する方法の description を指定します。
-
Test をクリックし、agent に「What are my open cases?」と尋ねてみます。
Squid SDK を使用する
Squid SDK を使用して AI agent を作成する場合は、ask() function の connectedIntegrations option に Salesforce connector を追加して接続します。
- TypeScript
- Python
await this.squid
.ai()
.agent('AGENT_ID')
.ask('Summarize the open cases for the Acme account', {
connectedIntegrations: [
{
integrationId: 'SALESFORCE_CONNECTOR_ID',
integrationType: 'salesforce',
description: 'Call this connector to look up and manage Salesforce records',
},
],
});
await squid.ai().agent('AGENT_ID').ask(
'Summarize the open cases for the Acme account',
options={
'connectedIntegrations': [
{
'integrationId': 'SALESFORCE_CONNECTOR_ID',
'integrationType': 'salesforce',
'description': 'Call this connector to look up and manage Salesforce records',
}
]
},
)
npm Package を使用する
backend または client code から programmatic(non-agent)access を行うには、@squidcloud/salesforce-client package を install します。
npm install @squidcloud/salesforce-client
import { SquidSalesforceClient } from '@squidcloud/salesforce-client';
const salesforce = new SquidSalesforceClient(squid, 'SALESFORCE_CONNECTOR_ID');
// Look up a record
const opportunity = await salesforce.getOpportunity('OPPORTUNITY_ID', 'Id, Name, StageName, Amount');
// Create a record
await salesforce.createCase({ Subject: 'Billing issue', Origin: 'Web' });
// Semantic search over synced records
const results = await salesforce.searchKnowledgeBase('customers asking about refunds', 'Case', 10);