Use cases of filtering

Filtering of forwarded messages allows you to automatically filter out messages from forwarding according to certain criteria, such as text, author, media and fwd header.

You can configure filters in one of two modes:

  • Block all messages with the specified content.
  • Allow only messages with the specified content. 

Filters will be useful in the following scenarios:

  • Parsing of chats, groups and channels to search for potential customers (leads) on the subject of your business. You can set up monitoring of a huge number of thematic chats and all requests and requests from users in your direction will be sent to you in real time automatically. You will only have to respond to the hot lead on his message with your offer.
  • Blocking advertising posts from sources if you have a news aggregator.
  • Collecting information only on a specific topic.
  • Copying messages from groups of only certain users.

Creating a simple text filter

Before creating a filter, make sure that you already have the forwarding configured.

To create a filter, follow these steps:

en_filter_add
  1. Go to the Filters page.
  2. Click Add.
 
filter simple text
  1. Select a Message as the Where to apply the filter. This option will apply a filter to the text of messages and buttons.
  2. Enter the Contents of the filter. The filter will be triggered if the specified content is located in the location selected in the previous step.
  3. As a filter action, select Block with content. This means that messages in which the specified content will be found will not be forwarded.
  4. If necessary, enter a Description - it does not affect anything and is needed solely for the convenience of the user.
  5. Click OK.
 
filter select forward
  1. In the list of your forwards that appears, select the forward in which the filter will be applied.
  2. Click OK.
 
filter menu

After successful creation, the filter will be displayed in the list. Now messages that fall under the filter will not be forwarded (in this case, all messages that contain the word ad). If necessary, by clicking on the gear, you can:

  • Edit the filter settings.
  • Select other forwards for the filter.
  • Duplicate the filter for later modification.
  • Remove the filter.
 

Multiple filter with regular expression

Regular expressions are text templates that allow you to search for certain lines in the text according to specified conditions (numbers, links, words and other patterns), which opens up incredible possibilities for configuring filters. 

The most common way to use regular expressions in filters is to list multiple words in one filter (instead of creating a separate filter for each word).

filter regexp

To enable support for regular expression syntax, you must put the appropriate check mark under the content field, after which the content entered in the field will be perceived by the service as a regular expression.

In this example, the filter will block all messages that contain at least one of the words: black, white or red.

Media filtering (photos, videos, etc.)

filter media

In order to filter messages with media, it is necessary to select Media in the Where field. In this case, the specified content will be searched in the name, type and extension of the media attached to the message.

The following types can be used:

  • photo
  • document
  • poll
  • geo
  • video
  • voice
  • audio

In this example, the filter will block all messages with photos and videos, skipping all others.

 

Filtering by the author of the message

filter author

Filtering messages by author can be extremely useful when forwarding chats and groups where messages can be sent by different people.

In order to filter messages by author, you must select Author in the Where field. In this case, the specified content will be searched in the name, ID, or username of the author of the messages.

In this example, the filter will block all messages from a user with ID 12312433  or with the name main_admin.

 

Filtering by FWD header

fwd заголовок пересланного сообщения

Forwarded messages always have an FWD header indicating the source of the message. The service allows you to filter similar messages sent from somewhere by this header.

filter fwd header

In order to filter messages by FWD Header, you must select FWD Header in the Where field . In this case, the specified content will be searched specifically in the message header.

In this example, the filter will block all messages forwarded to the source and not forward them further.

 

Forwarding only with the specified content

filter allow media

Sometimes it is necessary to forward messages with only certain content, or from a certain author, or only with a certain type of media, and block all others.

For such a task, it is necessary to select as the action Allow with content.

In this example, only messages with photos will be forwarded, and all others will be skipped.

IMPORTANT

If multiple filters with the Allow action are applied to one forward that they will be applied to the message sequentially. In other words, for a message to be forwarded, it must contain every content from every filter with the Allow action.

If it is necessary to forward a message when it contains at least one of the allowed words, then this must be done within the same filter using a regular expression, as shown above: (word1|word2|word3)