コンテキスト変数アクセスガイド
コンテキスト変数により、エージェントは外部システムから渡されるチャネル固有の情報にアクセスできるようになります。 このガイドでは、Genesys Bot Connector を実例として、コンテキスト変数の設定方法と参照方法について説明します。
コンテキスト変数の有効化
エージェントでコンテキスト変数を有効にするには、エージェントの設定YAMLファイルで以下のように設定してください:
context_access_enabled: true
context_variables:
- channel
- other_variable_name
context_access_enabled: コンテキスト変数へのアクセスを有効にするには、これをtrueに設定する必要がありますcontext_variables: エージェントがアクセス可能な特定のコンテキスト変数キーの一覧
コンテキスト変数へのアクセス
コンテキスト変数には、中括弧の構文を使用してアクセスします。
{variable_name}例:instructions: You have access to everything under the {channel} context variables.
Genesys Bot Connector のコンテキスト構造
どのような引数が渡されるか
パラメータ(入力値とも呼ばれる)は、Genesys Bot Connectorのリクエスト内のフィールド "channel": {
"genesys_bot_connector": {
"bot_session_id": "<botSessionId>",
"conversation_id": "<genesysConversationId>",
"parameters": {
// Custom parameters from Genesys
}
}
}
parameters を通じて渡され、コンテキスト変数として利用可能になります。Genesysからの入力例:
"parameters": {
"user_name": "Jon Snow",
"priority": "high"
}
エージェントがデータにアクセスする方法
入力パラメータが与えられた user_name: "Jon Snow"場合、エージェントのガイドラインは以下のようになる(という名前の単純なツールが存在 get_hello_messageすると仮定する)。
オプション 1 どの変数を使用するかを明示的に指定してください。
guidelines:
- display_name: simple hello message
condition: If the user just wants a hello message
action: Use the get_hello_message tool to generate hello message, use {channel.genesys_bot_connector.parameters.user_name} for the name.オプション 2: エージェントに、サブキーの 「値」 を使用するように指示してください(「値」を使用するよう明記することが重要です)guidelines:
- display_name: simple hello message
condition: If the user just wants a hello message
action: Use the get_hello_message tool to generate hello message, use {user_name} value in the context for the name.
エージェント設定の例
...
name: customer_service_agent
description: Agent that handles customer service inquiries
instructions: You are a helpful customer service agent. Access user information from {channel} context variables.
context_access_enabled: true
context_variables:
- channel
guidelines:
- display_name: Personalized greeting
condition: When starting a new conversation
action: Greet the customer using {user_name} value from the context.
- display_name: Priority handling
condition: If {channel.genesys_bot_connector.parameters.priority} is "high"
action: Acknowledge the urgent nature and expedite the request. Say "I see this is a high priority matter for you."
...