> 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/maiagent-user-guide-en/hook/setup.md).

# Create and Configure Hooks

This page explains how to create a Hook from a standard template, adjust its parameters, and attach it to an AI assistant to start operating.

## <mark style="color:blue;">1. Create a Hook</mark> <a href="#create-hook" id="create-hook"></a>

### 1. Go to the Hook List <a href="#hook-list" id="hook-list"></a>

Navigate to <mark style="color:blue;">AI Features</mark> → <mark style="color:blue;">Hook</mark> from the left menu. The list displays all Hooks in your organization, including **name, type, interception point, action, enabled status, and last updated time**.

### 2. Choose a Template <a href="#pick-template" id="pick-template"></a>

Click <mark style="color:blue;">+ New Hook</mark> in the upper right corner. In the popup window, select a standard template. Each template card indicates its **interception point** and **action**, making it easy to quickly identify its purpose.

{% hint style="info" %}
The creation flow has three tabs: **Template** (which type) → **Basic Info** (name, description) → **Apply to AI Assistant** (which assistants to attach). Fill them in sequentially after selecting a template.
{% endhint %}

## <mark style="color:blue;">2. Adjust Parameters</mark> <a href="#configure" id="configure"></a>

Different templates have different parameters. After creation, go to the Hook settings page to make adjustments. Common parameters include:

| Template                    | Main Parameters                                              | Description                                                                                               |
| --------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------- |
| PII Masking                 | PII types to mask                                            | Select which types to detect (Email / Phone / ID Number / Credit Card)                                    |
| Sensitive Keyword Blocking  | Keyword blocklist, minimum word length                       | One prohibited word per line; minimum word length filters out overly short words to avoid false positives |
| Prompt Injection Protection | Judgment model, additional rules                             | Select an LLM to determine whether it's an attack; add custom rules                                       |
| Invalid Message Filtering   | Greeting word list, consecutive repeat limit, judgment model | Rules filter first, then an LLM determines whether the message is invalid                                 |
| Response Reliability Review | Rewrite model, review criteria                               | Select an LLM to judge whether the response is reliable and rewrite it                                    |

### Judgment Model (LLM-based Templates) <a href="#judge-model" id="judge-model"></a>

Templates that require "semantic judgment" — such as Prompt Injection Protection, Invalid Message Filtering, and Response Reliability Review — have a **judgment model** field. The dropdown lists the models currently available to your organization. Since this judgment runs on every message, **it's recommended to choose a fast, cost-effective model** (such as Haiku, GPT-5 mini, Gemini Flash, or similar). Leave it empty to use the platform default model.

{% hint style="info" %}
**Block messages are customizable.** "Block" type templates (such as Prompt Injection Protection, Sensitive Keyword Blocking, Invalid Message Filtering) allow you to set the message shown to users when blocked, for example: "Your message contains inappropriate language. Please revise and try again."
{% endhint %}

## <mark style="color:blue;">3. Link to AI Assistant</mark> <a href="#link-assistant" id="link-assistant"></a>

A Hook must be **attached to an AI assistant** to take effect. There are two ways:

* **Attach during creation**: In the "Apply to AI Assistant" tab when creating a Hook, directly select the assistants to apply it to.
* **Attach from assistant settings**: Go to an AI assistant's settings page, switch to the <mark style="color:blue;">Hook</mark> tab, and select the Hooks to apply.

{% hint style="success" %}
**One assistant can have multiple Hooks.** The system executes them in order — for example, first "Invalid Message Filtering" blocks spam, then "PII Masking" masks personal data, then "Prompt Injection Protection" blocks attacks — combining them into a custom protection pipeline.
{% endhint %}

### Enable Hook <a href="#enable" id="enable"></a>

After confirming parameters and linked assistants, set the Hook to <mark style="color:blue;">Enabled</mark>. Once enabled, whenever users chat with that assistant, the Hook will automatically operate at the corresponding interception points.

## <mark style="color:blue;">4. Next Steps</mark> <a href="#next" id="next"></a>

After setup is complete, you can check [Hook Execution Logs](/maiagent-user-guide/maiagent-user-guide-en/hook/execution-logs.md) to view logs for each interception or modification and confirm that the Hook is working correctly.


---

# 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/maiagent-user-guide-en/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.
