# Chat filters and automatic actions

> Match messages, hide noise, and automate carefully scoped responses.

The Chat Filter addon matches incoming text and can hide a message, run commands, or forward a copy to another view. A filter can be useful without running any commands at all.

## Create a simple filter

Open **Preferences → Addons → Chat Filter** and add a filter with a descriptive title. Start with a plain-text match, such as a repetitive status message you want to hide, then limit the scope to a test channel before enabling it elsewhere.

A regular expression gives more control when needed:

```text
^!help
```

This matches a message that begins with `!help`. Other examples include `^Apple$` for an exact message, `^([0-9]+)$` for digits only, and `apple\.com` for a literal dot in a domain name.

## Scope and sender rules

Use **Filter Scope** to choose the channels, queries and message types that the filter should consider. The advanced **Sender Match** option applies a regular expression to the sender's hostmask, while forwarding can copy matching messages to another view.

A title and notes containing a few matching and nonmatching examples make a complex filter much easier to maintain later.

## Automatic commands

Each line in **Filter Action** can contain a slash command, and the available action tokens provide context about a match. Treat incoming messages as untrusted input, particularly when passing their contents into a command or script.

Test actions on a channel you control, keep the scope narrow, and avoid a response that matches its own trigger or another bot's response. Automatic moderation requires the appropriate network privileges and deserves more care than a first tutorial example.

## Advanced reference

The [original Chat Filter guide](https://www.textualapp.com/docs/legacy/guides/introduction-to-the-chat-filter-addon) retains the illustrated controls, action-token details and embedded help sections linked from older Textual copies. Its automatic ban-and-kick example is preserved as history rather than recommended as a starting point.
