ServiceNow CSM 連携
ServiceNow Customer Service Management を Squid に接続して、ケースの検索、作成、管理を行う
ServiceNow CSM コネクタの機能
ServiceNow CSM コネクタを使用すると、Squid AI エージェントがユーザーに代わって Customer Service Management のケースを操作できます。
| 機能 | 説明 |
|---|---|
| ケースの検索 | 簡単な説明、説明、またはケース番号によるテキスト検索。必要に応じて状態でフィルタリング可能 |
| ケースの詳細の取得 | 発信者、担当者、コメント、作業メモを含むケースの詳細 |
| セマンティック検索 | インデックスされたケースに対する自然言語検索 |
| ケースの作成 | 簡単な説明、説明、優先度、カテゴリ、発信者を指定して新しいケースを作成 |
| ケースへの返信 | ケースに公開コメントまたは内部用の作業メモを追加 |
Squid は CSM ケースをナレッジベースに自動的に同期し、10 分ごとに更新します。初回同期では過去 1 年分のケース履歴が対象となります。この同期により、セマンティック検索が可能になります。
このコネクタは ServiceNow Customer Service Management のケース(sn_customerservice_case テーブル)を対象とします。ITSM インシデントは管理しません。
ServiceNow REST API キーの作成
コネクタは、Authentication Mode で選択した 2 つのモードのいずれかで認証します。API key(デフォルト。このセクションで説明)または OAuth 2.0(OAuth 認証を参照)です。
API key モードでは、キーはすべてのリクエストで x-sn-apikey ヘッダーとして送信されます。設定には ServiceNow で 4 つのレコードが必要で、4 つすべてが作成されるまでキーは機能しません。
前提条件
- ServiceNow Washington DC 以降。それ以前のリリースでは API key 認証を利用できません。リリースは
https://YOUR_INSTANCE.service-now.com/stats.doで確認してください。 - All > Admin Center > Application Manager で有効化された API Key and HMAC Authentication プラグイン(
com.glide.tokenbased_auth)。 sn_customerservice_caseテーブルを作成する Customer Service Management プラグイン(com.sn_customerservice)。
1. インテグレーションユーザーを作成する
All > User Administration > Users で専用ユーザーを作成し、sn_customerservice_agent ロールと、ケーステーブルに対して ACL が要求する追加のロールを付与します。API キーはこのユーザーのアクセス権を継承するため、コネクタが実際に行う操作であるケース、コメント、作業メモの読み取りに合わせてロールの範囲を限定してください。
2. インバウンド認証プロファイルを作成する
-
All > System Web Services > API Access Policies > Inbound Authentication Profile に移動します。
-
New をクリックし、Create API Key authentication profiles をクリックします。
-
プロファイルに名前を付けます。例:
Squid API Key Profile。 -
Auth Parameter で、
x-sn-apikeyの header レコードを選択します。 -
Submit をクリックします。
クエリパラメータのレコードではなく、ヘッダーのレコードを選択してください。コネクタはキーをヘッダーとしてのみ送信するため、クエリパラメータに紐付けられたプロファイルは一致しません。Auth Parameter フィールドが空の場合、プロファイルは機能せず、401 レスポンスが返されます。
3. REST API キーを作成する
-
All > System Web Services > API Access Policies > REST API Key に移動します。
-
New をクリックし、キーに名前を付け、User に手順 1 で作成したインテグレーションユーザーを設定します。
-
Submit をクリックし、レコードを再度開いてトークンを表示します。
-
トークンをコピーします。この値を Squid に貼り付けます。
4. Table API を対象とするすべてのポリシーにプロファイルを追加する
ServiceNow は REST API Access Policies を特異性に基づいて評価し、最も具体的に一致する 1 つのポリシーのみを適用します。ほとんどのインスタンスには Table API を対象とする初期設定済みのポリシーが含まれているため、通常、新しい広範なポリシーを作成しても効果はありません。初期設定済みのポリシーが優先され、新しいポリシーは評価されず、API キーも使用されません。
-
All > System Web Services > API Access Policies > REST API Access Policies に移動します。
-
Table API リクエストに一致する可能性のあるすべてのポリシーを特定します。REST API が Table API に設定されているポリシーと、Global にチェックが入っているポリシーが対象です。
-
それぞれのポリシーで Authentication Profiles 関連リストを開き、手順 2 で作成したプロファイルを追加します。
-
既存の認証プロファイルはそのまま残します。
ポリシーは、追加された認証方式のみを許可します。ポリシーから Basic Auth または OAuth を削除すると、API 全体でその方式が無効になります。
Squid アプリケーションへの ServiceNow CSM コネクタの追加
-
Squid Console の Connectors タブに移動します。
-
Available Connectors をクリックします。
-
ServiceNow - CSM コネクタを見つけ、Add Connector を選択します。
-
以下の設定情報を入力します。
Connector ID:コード内でコネクタを一意に識別する文字列。
Instance Domain:ServiceNow インスタンスのサブドメイン。たとえば、インスタンスが https://mycompany.service-now.com にある場合は、mycompany を入力します。
Authentication Mode:apiKey(デフォルト)または oauth。
REST API Token:上記で作成した API キーのトークン。API key モードでは必須です。トークンは Squid secret として安全に保存されます。
Client ID、Client Secret、Redirect URI:OAuth 2.0 アプリケーションの認証情報。OAuth モードでは必須です。シークレットは Squid secret として保存されます。
OAuth 認証
Authentication Mode を oauth に設定すると、コネクタは API キーの代わりにユーザーの OAuth トークンを使用して ServiceNow を呼び出します。ServiceNow の System OAuth > Application Registry で OAuth アプリケーションのレジストリエントリを作成し、リダイレクト URL をアプリケーションのコールバックに設定して、クライアント ID とシークレットをコネクタに設定します。
コネクタの executable を使用してユーザーの同意を取得します。これらの executable にはアプリの API キーが必要なため、バックエンドコードから呼び出してください。
// 1. Build the authorization URL to send the user to. The default scope is 'useraccount'.
const { url } = await this.squid.executeFunction('getServiceNowOAuthUrlExecutable', {
integrationId: 'SERVICENOW_CONNECTOR_ID',
});
// 2. After the user approves, ServiceNow redirects to your redirect URI with a code.
// Exchange and store it:
await this.squid.executeFunction('saveServiceNowAuthCodeExecutable', {
integrationId: 'SERVICENOW_CONNECTOR_ID',
authCode: codeFromRedirect,
});
コードを保存すると、コネクタがトークンを自動的に更新します。
アプリケーションでの ServiceNow CSM コネクタの使用
ノーコードの Studio
-
Squid Console の Studio タブに移動します。
-
Create AI Agent をクリックします。
-
agent ID と description を入力します。例:「csm-agent」と「This agent helps the user manage ServiceNow customer service cases」。
-
Add Abilities をクリックします。
-
ServiceNow - CSM の項目を展開し、先ほど作成したコネクタを選択します。
-
エージェントがこの接続をどのように使用するかを説明します。例:「Call this when a user wants to manage cases or customer service tasks in ServiceNow CSM.」
-
Test をクリックし、エージェントに「What are the open cases?」と尋ねてみます。
Squid SDK の使用
Squid SDK で AI エージェントを作成する場合は、ask() 関数の connectedIntegrations オプションにコネクタを追加して接続します。
- TypeScript
- Python
await this.squid
.ai()
.agent('AGENT_ID')
.ask('Summarize the most recent customer cases about billing', {
connectedIntegrations: [
{
integrationId: 'SERVICENOW_CONNECTOR_ID',
integrationType: 'servicenow_csm',
description: 'Call this connector to manage ServiceNow CSM cases',
},
],
});
await squid.ai().agent('AGENT_ID').ask(
'Summarize the most recent customer cases about billing',
options={
'connectedIntegrations': [
{
'integrationId': 'SERVICENOW_CONNECTOR_ID',
'integrationType': 'servicenow_csm',
'description': 'Call this connector to manage ServiceNow CSM cases',
}
]
},
)
npm パッケージの使用
バックエンドまたはクライアントコードからプログラムによってアクセスする場合(エージェントを使用しない場合)は、@squidcloud/servicenow_csm-client パッケージをインストールします。
npm install @squidcloud/servicenow_csm-client
import { SquidServiceNowCSMClient } from '@squidcloud/servicenow_csm-client';
const servicenow = new SquidServiceNowCSMClient(squid, 'SERVICENOW_CONNECTOR_ID');
// Search and inspect cases
const cases = await servicenow.searchCases('billing');
const details = await servicenow.getCase(cases[0].number);
// Create a case and reply to it
const created = await servicenow.createCase({ shortDescription: 'Billing discrepancy' });
await servicenow.replyToCase(created.number, 'We are investigating.', true);
ServiceNow は、優先度(1 = Critical から 5 = Planning)とケースの状態(1 = New、2 = In Progress、3 = On Hold、6 = Resolved、7 = Closed、8 = Canceled)に数値コードを使用します。