> For the complete documentation index, see [llms.txt](https://docs.maiagent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maiagent.ai/maiagent-user-guide/ja/hook/setup.md).

# Hook の追加と設定

標準テンプレートから Hook を作成し、パラメータ（禁止ワードリスト、判定モデル、ブロックメッセージなど）を調整し、AI アシスタントに関連付けます。

このページでは、標準テンプレートから Hook を作成し、パラメータを調整し、AI アシスタントに適用して運用を開始する方法を説明します。

## <mark style="color:blue;">一、Hook の新規作成</mark> <a href="#create-hook" id="create-hook"></a>

### 1. Hook 一覧に移動する <a href="#hook-list" id="hook-list"></a>

左側メニューから <mark style="color:blue;">AI 機能</mark> → <mark style="color:blue;">Hook</mark> に進みます。一覧には組織内のすべての Hook が表示され、**名前、タイプ、インターセプトポイント、アクション、有効ステータス、最終更新日時**が確認できます。

### 2. テンプレートを選択する <a href="#pick-template" id="pick-template"></a>

右上の <mark style="color:blue;">＋ Hook を追加</mark> をクリックします。ポップアップウィンドウで標準テンプレートを選択してください。各テンプレートカードには**インターセプトポイント**と**アクション**が表示されており、用途をすぐに判断できます。

{% hint style="info" %}
作成フローは 3 つのタブで構成されています：**テンプレート**（種類の選択）→ **基本情報**（名前、説明）→ **AI アシスタントに適用**（どのアシスタントに適用するか）。テンプレートを選択した後、順番に入力してください。
{% endhint %}

## <mark style="color:blue;">二、パラメータの調整</mark> <a href="#configure" id="configure"></a>

テンプレートによってパラメータが異なります。作成後、Hook の設定ページで調整できます。主なパラメータは以下の通りです：

| テンプレート          | 主なパラメータ                 | 説明                                             |
| --------------- | ----------------------- | ---------------------------------------------- |
| 個人情報マスキング       | マスキングする PII タイプ         | 検出するタイプを選択します（Email／電話番号／マイナンバー／クレジットカード）      |
| センシティブワードブロック   | 禁止ワードリスト、最短ワード長         | 1 行に 1 つの禁止ワードを入力。最短ワード長の設定で短すぎるワードによる誤検知を防ぎます |
| プロンプトインジェクション防護 | 判定モデル、追加ルール             | 攻撃かどうかを判定する LLM を選択。カスタムルールも追加できます             |
| 無効メッセージフィルタリング  | 挨拶ワードリスト、連続繰り返し上限、判定モデル | まずルールでフィルタリングし、次に LLM でメッセージが無効かどうかを判定します      |
| 返信信頼性チェック       | 書き換えモデル、チェック基準          | 返信が信頼できるかどうかを判定し書き換える LLM を選択します               |

### 判定モデル（LLM ベースのテンプレート） <a href="#judge-model" id="judge-model"></a>

「意味的な判定」が必要なテンプレート（プロンプトインジェクション防護、無効メッセージフィルタリング、返信信頼性チェックなど）には、**判定モデル**フィールドがあります。ドロップダウンには組織で現在利用可能なモデルが一覧表示されます。この判定はメッセージごとに実行されるため、**高速でコスト効率の良いモデルを選択することを推奨します**（Haiku、GPT-5 mini、Gemini Flash など）。空欄にするとプラットフォームのデフォルトモデルが使用されます。

{% hint style="info" %}
**ブロックメッセージはカスタマイズ可能です。**「ブロック」タイプのテンプレート（プロンプトインジェクション防護、センシティブワードブロック、無効メッセージフィルタリングなど）では、ブロック時にユーザーに表示するメッセージを設定できます。例：「メッセージに不適切な内容が含まれています。修正してからもう一度お試しください。」
{% endhint %}

## <mark style="color:blue;">三、AI アシスタントへの関連付け</mark> <a href="#link-assistant" id="link-assistant"></a>

Hook は **AI アシスタントに適用**して初めて有効になります。2 つの方法があります：

* **作成時に適用する**：Hook の新規作成時の「AI アシスタントに適用」タブで、適用するアシスタントを直接選択します。
* **アシスタントの設定から適用する**：AI アシスタントの設定ページに移動し、<mark style="color:blue;">Hook</mark> タブに切り替えて、適用する Hook を選択します。

{% hint style="success" %}
**1 つのアシスタントに複数の Hook を設定できます。** システムは順番に実行します。例えば、まず「無効メッセージフィルタリング」でスパムをブロックし、次に「個人情報マスキング」で個人情報をマスキングし、さらに「プロンプトインジェクション防護」で攻撃をブロックする——このように組み合わせて専用の防護フローを構築できます。
{% endhint %}

### Hook の有効化 <a href="#enable" id="enable"></a>

パラメータと関連付けたアシスタントを確認したら、Hook を <mark style="color:blue;">有効</mark> に設定してください。有効にすると、ユーザーがそのアシスタントと対話するたびに、Hook が対応するインターセプトポイントで自動的に動作します。

## <mark style="color:blue;">四、次のステップ</mark> <a href="#next" id="next"></a>

設定完了後、[Hook 実行ログ](/maiagent-user-guide/ja/hook/execution-logs.md)で各インターセプトや書き換えの記録を確認し、Hook が正しく動作していることを確認できます。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.maiagent.ai/maiagent-user-guide/ja/hook/setup.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
