# Triggers

Triggers provide the most powerful functionality in a bot. You can customize any reaction to any user message.

Good morning to the admins (or any specific users) in the morning if they come into a conversation? - No problem.

When users send gifs, politely ask them to delete them within a minute, and if they don't do it, delete the gif and issue a warning, and if they do, write "thanks for understanding"? - You are welcome.

Send to chat "Master, you were called!" with a link to your profile when you are mentioned in a group? - Yes, and this is possible.

The main function of a trigger is a certain CONDITION, and when it is executed, a certain ACTION occurs, which you specify yourself.

# Trigger rates

This table explains the differences in trigger rates. There is no limit on condition groups/action groups - you can create 6 action groups, each of which will have one action, or 1 action group with six actions for the "Starter" tariff.

If you go beyond the trigger limits or the tariff expires - (a red inscription will appear, notifying that the number of triggers or actions in them has been exceeded) triggers will work, with limitations. For example, if you created 4 actions without a tariff, three will work. Also the number of triggers - if there are more than possible, the rest simply will not work.

Go to the section "Chat triggers", click on "+ Add new"

Next, a window will appear with the conditions for creating a trigger:

We give a name to the trigger.

Prompt

Try to name your trigger so that it is easy to find and edit among others.

# Type of trigger execution

"Perform all action" - this means that for a certain condition, all the actions indicated and specified by you will be performed. (In the event that you specify several actions)

“Perform a random group of actions” - in this case, for a certain condition, a group of several selected actions will be selected in a random order.

"Conditions" are certain messages, words, smilies, after which certain actions are applied.

"Actions" are certain reactions to the specified conditions, the action can be restriction of any actions of the chat participant, warning, exclusion from the chat or deletion of this message.

# Trigger testing

The triggers are worked out in turn. In the picture below, the number of the trigger queues is highlighted in red.

In order for the triggers to work in a row in order, you must enable the toggle switch "Continue executing the trigger chain at the end of the current trigger" in the advanced settings available from the "Advanced" tariff

If the toggle switch is turned off, only one trigger will be triggered, the one with the smaller number.

# Trigger conditions

We create conditions using "+", a separate window "Group of conditions" opens and a separate button "+" below. By clicking on a separate button, another group of conditions with separate functions is created.

Prompt

In the tool "Actions" the functionality is the same.

# Condition types:

A total of 18 conditions, 4 initiators, 8 types of messages and 6 filters for conditions for the message text.

# Complete match

The trigger will fire when the message fully matches the value you specified in the condition. That is, if you specify "Hello" in the condition, the condition will be fulfilled only with the message "Hello". If there is “Hello. You know ... ", or" Hello. ", Or" Hello) "the condition will NOT be met. * An exception is if you enable the "Ignore characters" filter below, then the bot will skip the last two options.

# The message starts with

The trigger will fire if the user's message starts with the lines (words/expressions) that you specified in the condition values.

# Message ends with

The trigger will fire if the user's message ends with the lines (words/expressions) you specified in the condition values, otherwise the trigger will not fire.

# The message contains

The trigger will fire if the message contains at least one of the strings (words/expressions) specified in the values of the conditions.

# Regular expression

The most powerful condition, the most difficult. However, if you master regular expressions, you will get endless functionality for your bot. With this tool, you can create any conditions for the user's text! With proper configuration, it can replace the six trigger conditions and to some extent most text filters.

Performs a search based on a Java regular expression. The tester and a quick reference on regular expressions are available by clicking the "Help" button in the top panel. There is also a small article dedicated to regular expressions in instructions.

# Message length less than or equal to

The trigger will fire if the message length is less than or equal to the number of characters you specified. You can enable/disable counting spaces.

# Message length is greater than or equal to

The trigger will fire if the message length is greater than or equal to the number of characters you specified. You can enable/disable counting spaces.

# Message type

There are 13 types of messages available, select the ones on which the trigger will work. For example, if you put a photo, then every time the participants send a photo, the condition will be met.

# Regular expression on minority in messages

Regular expression triggered by login (@username), written in chat in user messages. Specify values like this: (username), must be in lower case. You can read about working with regular expressions in the instructions. The tester and a quick reference on regular expressions are available by clicking the "Help" button in the top panel.

# Regular expression on text minor in messages

In the official Telegram client, when you write the "@" symbol in the chat, a list of recent participants appears:

If the user has a username, then by clicking on the user you will get his @username. If there is no username, then by clicking you will receive its clickable nickname. For example, the user's nickname is Tania Pupkina. After clicking, you will have the word Tania with a link to her profile. This condition is triggered for such words. Specify this word in values (eg Tania), formatted as a regular expression, eg "(Tania)". You can read about working with regular expressions in the instructions. The tester and a quick reference on regular expressions are available by clicking the "Help" button in the top panel.

# Regular expression on phone numbers

It works on the phone number (formatted as a regular expression) to which the Telegram account was registered. The telephone number should be indicated in the international format without a plus. It can only be used when the user has sent their contacts to the bot.

# Client language

Condition based on the selected language of the Telegram client (set language in the Telegram app). Specify values by type: ru, en, ua. Due to the peculiarities of Telegram, if the Russian language is set in the application, it triggers the values en and ru, so be careful with this. You can find the values that can be specified as the client's language here.

# Regular expression on username

The ability to trigger a condition for a specific user by his username. Usually works in combination with other conditions in the same activity group. Values are specified as follows: ^(username1)$, ^(username2)$ OR ^(username1|username2)$, must be in lower case. You can read about working with regular expressions in the instructions. A tester and a quick reference on regular expressions are available by clicking the "Help" button in the top panel.

# Minimum login length

You can specify the minimum number of characters that will be contained in the username (@username of the user). If the login contains less than the characters you specified, the action will work. The minimum possible length of a Telegram login is 5, the maximum possible is 32.

# Maximum login length

You can specify the maximum number of characters that will be contained in the username. If the login contains more characters that you specified, then the action will work. The minimum possible length of a Telegram login is 5, the maximum possible is 32.

# Regular expression on username

The ability to make a condition for a specific user by his nickname. Usually works in combination with other conditions in the same activity group. Values are specified as follows: ^(this user's nickname)$ OR ^(firstname1 lastname1|firstname2 lastname2)$, must be in lower case. You can read about working with regular expressions in the instructions. The tester and a quick reference on regular expressions are available by clicking the "Help" button in the top panel.

# Minimum name length

You can specify the minimum number of characters that will be contained in the username. If the username contains fewer characters than specified, the trigger will fire.

# Maximum name length

You can specify the maximum number of characters that will be contained in the username. If the username contains more characters than you specified, then the trigger will fire.

# User rank matches

Specify the desired number of ranks and a trigger will go off on a participant with the corresponding ranks.

# User rank below

Set the minimum number of ranks, for a participant with an indicator of ranks less than the specified ones, the trigger will go off.

# User rank higher

Set the maximum number of ranks, for a participant with an indicator of ranks greater than the specified ones, the trigger will go off.

Rank is the current status of the member in the chat. Ranks are given for performing certain actions that are set by the chat administrator.

# Next Tool "Condition Filter"

Let's take a closer look:

  1. Ignore spaces at the beginning and end of the line - regardless of whether or not there are spaces at the beginning or at the end of the line in the user's message, the trigger will work.
  2. Do not take into account spaces and line breaks - regardless of how and where there are spaces and line breaks in the user's message, the trigger will work.
  3. Ignore all spaces - the condition will be fulfilled regardless of how and where the spaces are in the user's message.
  4. Ignore symbols - the condition will be triggered even if symbols that you did not specify in the condition are used. Specify in the values "hello" - the trigger will work on "hel()lo"
  5. Ignore numbers - the trigger will work even if numbers that you did not specify in the condition are used. In the meanings "time" - will work on "tim54e"
  6. Ignore case - the trigger will work regardless of case (upper and lower case letters will be perceived the same). Example: "Hello" in values will work on "hello", "HELLO", "hElLo", and so on.

# Trigger "Initiator Tool"

Trigger initiator - the group member on whom the trigger will fire.

  • Anyone - the condition will work for all members of the group
  • Administrators - the condition will work for all administrators, including the creator
  • Users - the condition will work for all users, except for administrators
  • Creator - the condition will work only for the creator

Warning

Administrators are group members who can change bot settings, not chat administrators.

# Tool "Message Type"

Any - the condition will be triggered for any message;

All replicas - the condition will work only on replicas (responses);

Replays to the bot - the condition will only work on replies from bots;

Replies to the user - the condition will work only on responses from users, except for administrators;

Replays to the admin - the condition will work only on answers from administrators;

Warning

Administrators are group members who can change bot settings, not chat administrators.

Replies to @ ChatKeeperBot - the condition will trigger on replies to messages from @ChatKeeperBot;

Do not replay - the condition will work on messages that were not sent by replay (response);

User's first message - the condition will be triggered at the first message of a new participant.

# Tool "Invert"

Inverting reverses all conditions. If the condition should have been triggered for the word "Hello" - the condition will work for all messages that do not contain this word. If “Replies to @ChatKeeperBot” is set, the condition will be triggered for all messages that are not replies (replies) to @ChatKeeperBot. When inverting, only condition filters, initiator “Anyone” and message type “Any” do not change.

# Trigger actions

  • Send a message - If the condition is met, a message will be sent, the text of which you entered in the text input field, after selecting an action;

  • Send by private message - The bot will send text to private messages to the user. The list of recipients of such a message is located after selecting the action - there you can specify @username (with or without a sign, in any case) or user ID. For the message to be sent, the user must click on the start button in private messages with the bot. *Do not forget that a bot cannot write first;

  • Remove user from chat with the option to return - The user will be removed from the chat, but they will be able to return when using the /kick command;

  • Remove user from chat for a while - The user will be removed from the chat for a specified period of time, after this time, the user has the opportunity to return to the chat;

  • User will not be able to write - The user will not be able to write during the time period you specified, after this period, the user will be able to write using the /mute command;

  • Allow user to return to chat - The user can return to the chat if he was previously excluded, to return to the chat use the /unban command;

  • Allow user to write - The user will be able to write messages, if he was previously blocked, use the /unmute command;

  • Delete message - The message that triggered the trigger will be deleted;

  • Increase or decrease the user's reputation - The action makes it possible to change the participant's reputation in a positive or negative direction. After choosing an action, there will be a form "Quantity" in which you will specify the addition or subtraction of reputation;

  • Change user score - The action makes it possible to change the number of points of the participant. After choosing an action, there will be a form "Quantity" in which you will specify the addition or subtraction of points;

  • Add or remove warning from user - The ability to add a certain number of warnings to a user works like the /warn command;

  • Add or remove warning in trigger - In this trigger, you can add or subtract the number of warnings. *After the number of warnings set by the administrator, the user enters the block;

  • Send form result to chat - (action is available on tariffs Advance and Ultimate) After the participant has filled out the form, the result of the form will be sent to the chat and will be available for viewing by all users. After choosing an action, you can write the contents of the form in the text input field;

  • Send the result of the form by a personal message - (the action is available on tariffs Advance and Ultimate) After the participant has filled out the form, the result of the form will be sent to private messages to the specified users. The list of recipients of the result is specified after selecting an action in the form "List of users who will receive the result of the form". The username is specified without the @ sign in small case, for example "username" or user ID. For the message to be sent, the user needs to click the start button in private messages with the bot. Thus, the result of the form will be available only to certain users. The shape can be set in the Open Advanced Settings tool under the trigger name shape.