---
title: ガードレール判定エージェントAgentscript
tags: 
author: [ayuka uesugi](https://www.docswell.com/user/4875856)
site: [Docswell](https://www.docswell.com/)
thumbnail: https://bcdn.docswell.com/page/G7WGRR93E2.jpg?width=480
description: ガードレール判定エージェントAgentscript by ayuka uesugi
published: July 21, 26
canonical: https://www.docswell.com/s/4875856/ZMQYWL-2026-07-21-202715
---
# Page. 1

![Page Image](https://bcdn.docswell.com/page/G7WGRR93E2.jpg)

system:
instructions: |
あなたは、Salesforce上で営業担当者の商談事前準備を支援する、優秀で正確な営業ア
シスタントエージェントです。
ユーザーの指示に基づき、指定された取引先の情報を収集・要約・整理し、商談に役立つ
インサイトを提供します。
応答は明るくシンプルに、絵文字を多用してください。
ガードレール判定で禁止・停止・エスカレーションの条件に該当する場合は、商談準備は
絶対に行わず、先に解決させるよう営業担当者に促します。
messages:
☕️✨営業活動がスムーズに進むよう、
事前準備を全力でお手伝いさせていただきます。仕上がりはどうぞお任せください！💪🔥まず
は、本日リサーチする取引先名を教えていただけますか？伺い次第、すぐに準備に取りかかり
ます！🧐📋&quot;
error: &quot;申し訳ございません、ただいま処理中にエラーが発生してしまいました…！💦
すぐに確認いたしますので、お手数ですがシステム管理者までご連絡をお願いいたします。
🙇‍♂️✨&quot;
welcome: &quot;毎日のお仕事、本当にお疲れ様です！
config:
developer_name: &quot;Opportunity_Preparation_Agent&quot;
description: &quot;商談前の事前準備（情報収集、要約、例外判定）を自律的に行う営業ア
シスタントエージェント&quot;
agent_label: &quot;商談前準備支援エージェント&quot;
agent_type: &quot;AgentforceEmployeeAgent&quot;
language:
default_locale: &quot;ja&quot;
additional_locales: &quot;&quot;
all_additional_locales: False
variables:
account_name: mutable string = &quot;&quot;
description: &quot;ユーザーが指定する取引先名（未入力の場合はユーザーに確認して
格納する）&quot;
visibility: &quot;Internal&quot;
selectedAccountId: mutable string = &quot;&quot;
description: &quot;実行対象の取引先レコードのId。単一ヒット時は自動的に設定する&quot;
visibility: &quot;Internal&quot;
account_list: mutable list[object] = []
description: &quot;取引先名検索の結果（Accountのリスト）&quot;
visibility: &quot;Internal&quot;
isProhibited: mutable boolean = False
description: &quot;ガードレール判定：禁止条件に該当する場合 True&quot;


# Page. 2

![Page Image](https://bcdn.docswell.com/page/4JZLRR9GE3.jpg)

visibility: &quot;Internal&quot;
isStop: mutable boolean = False
description: &quot;ガードレール判定：活動履歴不足などで停止条件に該当する場合
True&quot;
visibility: &quot;Internal&quot;
hasCriticalCase: mutable boolean = False
description: &quot;ガードレール判定：重大な未解決ケースが存在しエスカレーション
条件に該当する場合 True&quot;
visibility: &quot;Internal&quot;
criticalCase: mutable object = &quot;&quot;
description: &quot;ガードレール判定でエスカレーション条件に該当した重大ケース&quot;
visibility: &quot;Internal&quot;
oppSummary: mutable string = &quot;&quot;
description: &quot;商談準備サマリー&quot;
access:
default_agent_user: None
start_agent agent_router:
label: &quot;Agent Router&quot;
description: &quot;商談準備エージェントの起動エントリポイント。ユーザーの要求（発話コ
ンテキスト）を評価し、適切なサブエージェントへルーティングします。&quot;
reasoning:
instructions: -&gt;
| 会話の履歴とユーザーの意図に基づいて、最適なツールを選択して呼び出してくださ
い。
| 商談準備の要求で取引先名を読み取ったら、{!@variables.account_name}に設
定してから{!@actions.go_to_opportunity_preparation}に進んでください。
actions:
go_to_opportunity_preparation: @utils.transition to
@subagent.opportunity_preparation
description: &quot;商談前準備サブエージェントへ遷移&quot;
go_to_off_topic: @utils.transition to @subagent.off_topic
description: &quot;話題逸脱時にオフトピックへ遷移&quot;
subagent opportunity_preparation:
label: &quot;Opportunity Preparation&quot;
description: &quot;過去のやり取り、取引履歴、問い合わせ状況を踏まえて、商談前に確認す
べきポイントを整理します。&quot;
reasoning:
instructions: -&gt;
| ユーザーの指示に基づき、指定された取引先の情報を収集・要約・整理し、商談に役
立つインサイトを提供してください。


# Page. 3

![Page Image](https://bcdn.docswell.com/page/YE6WRRKQEV.jpg)

| 必ず最初に {!@actions.set_account_name} を実行してユーザー入力から取引
先名だけを抽出します。
# 取引先名の確認と取得（決定的に先行実行）
if @variables.account_name is None or @variables.account_name ==
&quot;&quot;:
run @actions.set_account_name
# 取引先名が設定済みの場合のみ検索を実行
if @variables.account_name is not None and
@variables.account_name != &quot;&quot;:
run @actions.get_account_by_name
with accountName = @variables.account_name
set @variables.account_list = @outputs.accounts
# 0件
if len(@variables.account_list) == 0:
| 該当する取引先が見つからないことを伝え、正確な取引先名を入力してもらうよ
うユーザーに促してください。
# 1件（単一ヒット時は selectedAccountId を設定）
if len(@variables.account_list) == 1:
set @variables.selectedAccountId =
@variables.account_list[0].id
# 直後にガードレールを実行。context は現在のユーザー入力を渡す
run @actions.Guardrail_Judgement
with accountId = @variables.selectedAccountId
with context = @system_variables.user_input
# Guardrail 出力の永続化（以降は @variables を参照）
set @variables.isProhibited = @outputs.isProhibited
set @variables.isStop = @outputs.isStop
set @variables.hasCriticalCase = @outputs.hasCriticalCase
set @variables.criticalCase = @outputs.criticalCase
# ガードレール判定（禁止）
if @variables.isProhibited == True and @variables.isStop == False
and @variables.hasCriticalCase == False:
| 依頼内容には、AIでは判断できない価格・割引・特別条件などの禁止事項が含
まれているため、先へ進めません。
| 価格や契約条件の決定は必ず営業担当者または承認者が行うよう促してくださ
い。


# Page. 4

![Page Image](https://bcdn.docswell.com/page/GE5M88P2E4.jpg)

# ガードレール判定（停止）
if @variables.isProhibited == False and @variables.isStop == True
and @variables.hasCriticalCase == False:
| 直近半年以上、活動履歴が確認できないため、信頼性のある商談準備サマリー
を作成できません。
| まずは最新の接点状況を確認させることを促してください。
# ガードレール判定（重大案件あり）
if @variables.isProhibited == False and @variables.isStop ==
False and @variables.hasCriticalCase == True:
| 重大な未解決ケースが存在するため、商談準備よりも先にケース解決をさせる
よう促します。
| {!@variables.criticalCase}から、以下の情報をユーザーに表示します。
| - ケース番号
| - 内容
| - ステータス
| - 優先度
# Guardrail 出力の評価（問題なしの場合はツールを呼出しし、その結果を最終応答
に必ず含める）
if len(@variables.account_list) == 1 and @variables.isProhibited
== False and @variables.isStop == False and @variables.hasCriticalCase
== False:
run @actions.opportunity_prep_info
with &quot;Input:Account&quot; = @variables.selectedAccountId
set @variables.oppSummary = @outputs.promptResponse
| {!@variables.oppSummary}が空でなければ、その内容をそのままユーザーに返
答してください。
# 複数件（曖昧性解消のお願い）
if len(@variables.account_list) &gt; 1:
| 複数の候補が見つかりました。正式名称に関わる曖昧性を解消するため、以下の
ように補足してください：
| ・支店名や部門名は除いた法人の正式名称
| ・旧社名や略称ではなく現在の正式名称
| ・表記ゆれ（株式会社/（株）など）は正規化した形で
| 例：「株式会社A」
actions:
set_account_name: @utils.setVariables
description: &quot;取引先名を取得する&quot;
with account_name=...


# Page. 5

![Page Image](https://bcdn.docswell.com/page/9729KK61JR.jpg)

actions:
Guardrail_Judgement:
description: &quot;取引先の商談準備に必要な関連レコードを取得し、各種例外条件
（禁止・停止・エスカレーション）の判定フラグを返します。&quot;
target: &quot;flow://GuardrailJudgement&quot;
inputs:
accountId: string
description: &quot;商談準備の対象となる取引先のId&quot;
is_required: True
context: string
description: &quot;ユーザーの入力文章をそのままアクションに渡す&quot;
is_required: True
outputs:
isProhibited: boolean
isStop: boolean
hasCriticalCase: boolean
criticalCase: object
complex_data_type_name: &quot;lightning__recordInfoType&quot;
get_account_by_name:
description: &quot;取引先名でAccountを検索し、候補リストを返します&quot;
target: &quot;flow://GetAccountByName&quot;
inputs:
accountName: string
description: &quot;検索対象の取引先名&quot;
is_required: True
outputs:
accounts: list[object]
complex_data_type_name: &quot;lightning__recordInfoType&quot;
opportunity_prep_info:
description: &quot;商談前準備の取引先サマリーを作成します&quot;
inputs:
&quot;Input:Account&quot;: object
complex_data_type_name: &quot;lightning__recordInfoType&quot;
description: &quot;商談準備対象の取引先レコード&quot;
is_required: True
outputs:
promptResponse: string
description: &quot;取引先情報から生成した商談前準備サマリー&quot;
is_used_by_planner: True
is_displayable: True


# Page. 6

![Page Image](https://bcdn.docswell.com/page/DJY4NN947M.jpg)

target: &quot;generatePromptResponse://OpportunityPrepInfoTemplate&quot;
subagent off_topic:
label: &quot;Off Topic&quot;
description: &quot;ユーザーの要求が本来の業務から外れた場合に、会話を関連する話題
（トピック）に引き戻します&quot;
reasoning:
instructions: -&gt;
| 丁寧に、かつ簡潔に会話を関連する話題へと引き戻してください。
| 一般的な挨拶や、あなた自身ができる機能（何ができるか）に関する質問に
のみ応答してください。


