build-agent について
build-agentは、ServiceNowでカスタムAIエージェントを設計・設定するためのスキルです。Virtual Agentのトピック構築やNow Assistの拡張を対象に、知識ソース、会話フロー、アクション、安全策、テスト、公開を扱います。
主な機能
- 01エージェントの範囲と機能の定義
- 02知識ソースの設定
- 03インテントと会話フローの設計
- 04アクションと安全策の設定
- 05エージェントのテスト、公開、監視
活用シーン
- 01ITサポート用Virtual Agentの構築
- 02HR福利厚生アシスタントの作成
- 03エージェントの自動アクション設定
MCP 対応
SN-Query-TableやSN-Create-RecordなどのMCPツールを使い、ServiceNowのエージェント構成要素を設定・確認する方法を説明します。
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ happy-technologies-llc/ happy-platform-skills --skill build-agentインストール後、Claude Code で/build-agentを入力して読み込まれたか確認します。
詳細
カスタム AI エージェントの構築
概要
このスキルでは、ServiceNow でカスタム AI エージェントを構築するための包括的なガイドを提供します。
- エージェントの機能と責任範囲を定義する
- エージェントのグラウンディングに使用するナレッジソースを設定する(KB 記事、カタログアイテム、ドキュメント)
- エージェントがアクションを実行できるようにツールアクセスを設定する(レコードの作成、データのクエリ、フローのトリガー)
- 意図の認識とエンティティ抽出を用いた会話フローを設計する
- 安全性、正確性、コンプライアンスのためのガードレールを実装する
- 本番環境にデプロイする前にエージェントの動作をテストし、反復的に改善する
使用するタイミング: 新しいバーチャルエージェントのトピックを構築する場合、Now Assist スキルの機能を拡張する場合、ドメイン固有の AI アシスタントを作成する場合、自動タスク実行のためにエージェントのツールアクセスを設定する場合。
前提条件
- ロール:
admin、va_admin、またはnow_assist_admin - プラグイン:
com.glide.cs.chatbot(Virtual Agent)、com.snc.now_assist(Now Assist)を推奨 - アクセス権:
sys_cs_topic、sys_cs_intent、sys_cs_entity、sys_cb_topic、kb_knowledgeテーブルへの書き込みアクセス権 - 知識: 会話型 AI の概念(意図、エンティティ、スロット、フルフィルメント)の理解
- 関連スキル: 自動化対象の発見には
genai/agent-miner、Now Assist スキルにはgenai/skill-kit-custom
手順
ステップ 1:エージェントの範囲と機能を定義する
エージェントの目的、対象ユーザー、境界を文書化します。
=== AGENT DEFINITION ===
Name: [Agent Name]
Domain: [IT Support / HR / Facilities / Custom]
Target Users: [Employee / Customer / Technician]
CAPABILITIES (What the agent CAN do):
- [ ] Answer questions about [topic]
- [ ] Create [record type] on behalf of users
- [ ] Look up [information type]
- [ ] Trigger [workflow/process]
- [ ] Escalate to [team] when needed
BOUNDARIES (What the agent CANNOT do):
- [ ] Access [restricted data/system]
- [ ] Approve [request type]
- [ ] Modify [critical records]
- [ ] Share [sensitive information]
SUCCESS METRICS:
- Deflection Rate Target: [%]
- User Satisfaction Target: [score]
- Resolution Rate Target: [%]
- Average Handle Time Target: [minutes]
ステップ 2:ナレッジソースを設定する
エージェントがグラウンディングに使用するナレッジベースの記事とデータソースを設定します。
MCP の方法:
Tool: SN-Query-Table
Parameters:
table_name: kb_knowledge
query: kb_knowledge_base=[KB_SYS_ID]^workflow_state=published^active=true
fields: sys_id,number,short_description,kb_category,article_type
limit: 100
REST の方法:
GET /api/now/table/kb_knowledge
?sysparm_query=kb_knowledge_base=[KB_SYS_ID]^workflow_state=published^active=true
&sysparm_fields=sys_id,number,short_description,kb_category,article_type
&sysparm_limit=100
エージェントの各機能について、ナレッジの網羅状況を確認します。
| 機能 | KB 記事 | 特定された不足点 |
|---|---|---|
| パスワードのリセット | KB001、KB002 | なし |
| VPN の設定 | KB010 | macOS の手順が不足 |
| ソフトウェアのリクエスト | なし | カタログとのマッピング記事が必要 |
ステップ 3:エージェントのトピックを作成する
エージェントの会話範囲を定義する主要なトピックを構築します。
MCP の方法:
Tool: SN-Create-Record
Parameters:
table_name: sys_cs_topic
data:
name: "IT Support Assistant"
description: "Handles common IT support requests including password resets, VPN access, and software installations"
state: draft
category: IT
greeting_message: "Hi! I'm your IT Support Assistant. I can help with password resets, VPN access, software requests, and general IT questions. What do you need help with?"
no_match_message: "I'm not sure I understand. Could you rephrase your request, or would you like me to connect you with a live agent?"
max_retries: 3
REST の方法:
POST /api/now/table/sys_cs_topic
Body: {
"name": "IT Support Assistant",
"description": "Handles common IT support requests",
"state": "draft",
"category": "IT",
"greeting_message": "Hi! I'm your IT Support Assistant...",
"no_match_message": "I'm not sure I understand...",
"max_retries": "3"
}
ステップ 4:意図とトレーニング用発話を定義する
エージェントが認識して応答する意図を作成します。
MCP の方法:
Tool: SN-Create-Record
Parameters:
table_name: sys_cs_intent
data:
name: "Reset Password"
topic: [TOPIC_SYS_ID]
description: "User wants to reset their password for any system"
training_utterances: |
I need to reset my password
My password expired
I can't log in
Password not working
Forgot my password
Need a new password
Locked out of my account
Account locked
Can't access my account
Reset credentials
機能ごとに繰り返します。
| 意図 | 発話例 | エンティティスロット |
|---|---|---|
| パスワードのリセット | 「パスワードをリセットしたい」、「ロックアウトされた」 | system_name、username |
| VPN アクセス | 「VPN に接続したい」、「VPN が動作しない」 | vpn_type、device_type |
| ソフトウェアのインストール | 「ソフトウェアをインストールしたい」、「[アプリ] が必要」 | software_name、justification |
| 一般的な質問 | 「どのようにすれば…」、「…とは何ですか」 | topic_keyword |
ステップ 5:スロットフィリング用のエンティティを定義する
ユーザーメッセージから構造化データを抽出するエンティティを作成します。
MCP の方法:
Tool: SN-Create-Record
Parameters:
table_name: sys_cs_entity
data:
name: "system_name"
topic: [TOPIC_SYS_ID]
type: "list"
prompt: "Which system do you need the password reset for?"
required: true
values: |
Active Directory|AD|Windows login
Email|Outlook|Exchange
VPN|Cisco AnyConnect
SAP|ERP
Salesforce|CRM
REST の方法:
POST /api/now/table/sys_cs_entity
Body: {
"name": "system_name",
"topic": "[TOPIC_SYS_ID]",
"type": "list",
"prompt": "Which system do you need the password reset for?",
"required": "true"
}
ステップ 6:ツールアクセスとアクションを設定する
エージェントが ServiceNow で実行できるアクションを定義します。
MCP の方法:
Tool: SN-Create-Record
Parameters:
table_name: sys_cb_action
data:
topic: [TOPIC_SYS_ID]
name: "Create Incident for Password Reset"
action_type: "create_record"
table: "incident"
field_values: |
category=inquiry
subcategory=password
short_description=Password reset request: ${system_name}
assignment_group=IT Help Desk
caller_id=${sys_user}
urgency=3
impact=3
REST の方法:
POST /api/now/table/sys_cb_action
Body: {
"topic": "[TOPIC_SYS_ID]",
"name": "Create Incident for Password Reset",
"action_type": "create_record",
"table": "incident",
"field_values": "category=inquiry^subcategory=password^short_description=Password reset request"
}
一般的なアクションタイプ:
| アクションタイプ | 目的 | 設定 |
|---|---|---|
| create_record | 新しいレコードを作成する | table、field_values |
| update_record | 既存のレコードを更新する | table、sys_id、field_values |
| query_record | レコードを検索する | table、query、return_fields |
| run_flow | Flow Designer のフローをトリガーする | flow_sys_id、inputs |
| run_script | サーバーサイドスクリプトを実行する | script body |
| kb_search | ナレッジベースを検索する | query、kb_base |
| escalate | ライブエージェントに転送する | queue、message |
ステップ 7:ガードレールを実装する
安全性の境界とコンプライアンス管理を設定します。
入力ガードレール:
Tool: SN-Create-Record
Parameters:
table_name: sys_cs_topic_goal
data:
topic: [TOPIC_SYS_ID]
name: "Input Validation"
type: "guardrail"
configuration: |
BLOCKED_INTENTS:
- Requests for other users' personal data
- Attempts to bypass approval processes
- Requests for admin/root access
INPUT_SANITIZATION:
- Strip HTML/script tags from user input
- Validate employee ID format before lookup
- Limit free-text input to 500 characters
AUTHENTICATION:
- Require verified session for record creation
- Verify caller identity before sharing account details
- MFA challenge for sensitive operations
出力ガードレール:
RESPONSE RULES:
- Never expose sys_id values or internal table names to users
- Never share other employees' personal information
- Always confirm destructive actions before executing
- Include disclaimer for estimated timeframes
- Redirect compliance/legal questions to appropriate teams
- Log all agent actions for audit trail
ESCALATION TRIGGERS:
- User expresses frustration (sentiment < -0.5)
- 3 consecutive failed intent matches
- Request involves VIP or executive user
- Security-related request (account compromise)
- Agent confidence score below threshold (< 0.7)
ステップ 8:会話フローを設計する
各意図の会話フロー全体を計画します。
CONVERSATION FLOW: Password Reset
[User Message] -> Intent Recognition -> "Reset Password" (confidence > 0.8)
|
v
[Slot: system_name] -> "Which system?" -> User provides system
|
v
[Slot: username] -> "What is your username?" -> User provides username
|
v
[Validation] -> Verify user exists in system
|-- User found -> Proceed
|-- User not found -> "I couldn't find that username. Please verify and try again."
|
v
[Action] -> Trigger password reset flow
|-- Success -> "Your password has been reset. Check your email for the temporary password."
|-- Failure -> "I wasn't able to reset your password. Let me connect you with a live agent."
|
v
[Follow-up] -> "Is there anything else I can help you with?"
ステップ 9:エージェントをテストする
テストシナリオを使って、エージェントの動作を検証します。
MCP のアプローチ:
Tool: SN-Query-Table
Parameters:
table_name: sys_cs_topic
query: sys_id=[TOPIC_SYS_ID]
fields: sys_id,name,state,test_status,last_tested
テストマトリックス:
| テストケース | 入力 | 期待される動作 | 結果 |
|---|---|---|---|
| 正常系 | "Reset my AD password" | ユーザー名を確認して、リセットを実行する | |
| エンティティの不足 | "Reset my password" | どのシステムかを尋ねる | |
| 未知のインテント | "What's the weather?" | 一致しない場合の応答を返す | |
| ガードレールの作動 | "Reset John's password" | 拒否し、その理由を説明する | |
| エスカレーション | "This isn't working, get me a human" | ライブエージェントに引き継ぐ | |
| エッジケース | 空のメッセージ | 入力を促す |
ステップ 10:デプロイと監視
エージェントを公開して、監視を設定します。
MCP のアプローチ:
Tool: SN-Update-Record
Parameters:
table_name: sys_cs_topic
sys_id: [TOPIC_SYS_ID]
data:
state: published
デプロイ後の監視クエリ:
Tool: SN-Query-Table
Parameters:
table_name: sys_cs_conversation
query: topic=[TOPIC_SYS_ID]^sys_created_on>=javascript:gs.daysAgo(7)
fields: sys_id,state,live_agent,transfer_reason,user_satisfaction,sys_created_on
limit: 100
ツールの使用方法
| ツール | 目的 | 使用するタイミング |
|---|---|---|
| SN-Query-Table | 既存のトピック、インテント、ナレッジ記事を検索する | 検出と検証 |
| SN-Create-Record | トピック、インテント、エンティティ、アクションを作成する | エージェントのコンポーネントの構築 |
| SN-Update-Record | エージェントの設定を変更し、トピックを公開する | 設定とデプロイ |
| SN-Get-Table-Schema | トピックとインテントのテーブル構造を検出する | 初期設定 |
| SN-Get-Record | 特定のトピックまたはインテントのレコード詳細を取得する | 既存の設定の確認 |
ベストプラクティス
- 対象を絞って始め、段階的に拡大する -- 2~3 個の明確に定義されたインテントから開始してから追加します
- 確実に認識させるため、各インテントに少なくとも 10 個の学習用発話を使用する
- 実際のユーザーの言葉でテストする -- 学習データでは専門用語を避けます
- 適切なフォールバックを実装する -- ライブエージェントのサポートにつながる手段を必ず用意します
- デプロイ後の最初の 1 か月は、毎週監視して再学習する
- トピックをバージョン管理する -- 公開済みバージョンでユーザーに対応しながら、ドラフトバージョンを維持します
- 関心事を分離する -- ドメイン領域(IT、HR、施設)ごとにトピックを 1 つ作成します
- すべてのアクションを記録する -- コンプライアンスとデバッグのために監査証跡を維持します
- 信頼度のしきい値を設定する -- 信頼度の低いインテントの一致ではアクションを実行しないでください
- ユーザーからフィードバックを集める -- 会話後のアンケートを利用して、改善すべき領域を特定します
トラブルシューティング
| 問題 | 原因 | 解決方法 |
|---|---|---|
| エージェントがインテントを認識しない | 学習用発話が不十分、または質が低い | より多様な発話を追加し、誤字や略語も含めます |
| 誤ったインテントが一致する | インテント間で発話が重複している | 学習データを見直して重複を削除し、信頼度のしきい値を上げます |
| エンティティが抽出されない | エンティティの値がユーザー入力と一致しない | エンティティ値のリストに同義語やバリエーションを追加します |
| アクションが失敗しても何も表示されない | 権限がない、またはフィールドマッピングが無効 | エージェントのユーザーロールを確認し、テーブルスキーマに照らしてフィールド名を検証します |
| エージェントが同じ質問を繰り返す | ユーザーの応答から必須スロットを埋められていない | スキップロジックまたは代替のスロット入力プロンプトを追加します |
| エスカレーション率が高い | エージェントの対応範囲が狭すぎる、または回答が役に立たない | ナレッジソースを拡張し、エスカレーションされた会話を確認してパターンを特定します |
例
例 1:IT サポートボット
シナリオ: よくある IT サポートの依頼に対応するバーチャルエージェントを構築します。
AGENT: IT Support Assistant
INTENTS:
1. Password Reset -> Flow: Reset Password (AD, Email, VPN)
2. Software Request -> Action: Create RITM from catalog
3. VPN Troubleshooting -> KB Search: VPN articles
4. Hardware Issue -> Action: Create incident, escalate if P1
5. General IT Question -> KB Search: IT knowledge base
GUARDRAILS:
- Cannot reset passwords for other users
- Software requests require manager approval flow
- Hardware replacements require asset verification
例 2:HR 福利厚生ボット
シナリオ: 福利厚生の登録に関する質問に対応するエージェントを構築します。
AGENT: Benefits Assistant
INTENTS:
1. Benefits Overview -> KB: Benefits summary article
2. Enrollment Period -> KB: Open enrollment dates and process
3. Plan Comparison -> KB: Plan comparison matrix
4. Life Event Change -> Action: Create HR case for life event
5. Dependent Add/Remove -> Action: Create HR case with dependent info
GUARDRAILS:
- Cannot share other employees' benefits information
- Directs medical questions to benefits provider
- Logs all interactions for compliance
例 3:施設サービスボット
シナリオ: 職場のサービス依頼に対応するエージェントを構築します。
AGENT: Facilities Assistant
INTENTS:
1. Room Booking -> Action: Query room availability, create reservation
2. Maintenance Request -> Action: Create facilities incident
3. Badge Access -> Action: Create access request RITM
4. Parking -> KB: Parking policy and waitlist info
5. Catering -> Action: Create catering request with details
GUARDRAILS:
- Room bookings limited to 4 hours maximum
- Maintenance requests auto-prioritized by type
- Badge access requires security team approval
関連スキル
genai/agent-miner- 対話データから自動化の機会を見つけるgenai/flow-generation- エージェントが実行できるフローを構築するgenai/playbook-generation- エージェント支援ワークフロー用のプレイブックを作成するgenai/skill-kit-custom- カスタムの Now Assist スキルを構築するknowledge/article-generation- エージェントのナレッジソース用に KB 記事を生成する