# 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.

# Types of conditions

There are 200 possible conditions for creating triggers.

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.

# Conditions according to messages

Conditions for triggering a trigger that are related to the content of the user's message.

# A complete match of the message

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.

# The 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.

# Conditions for message parameters

Conditions for triggering a trigger that are related to the parameters of the user's message, and not to its content.

# Type of message

Trigger call via the parameter type (or format) of the message being sent: photo, audio, sticker, etc. There are 14 types of messages available in total:

  • Audio
  • Document
  • Sticker
  • Photo
  • Photo file
  • Video
  • Video file
  • Animation
  • Contact
  • Location
  • Voice
  • The game
  • Video note
  • Survey

# Message length

Calling the trigger via the message length parameter. This can be either the length of the user's message itself, or the length of the message of the person being answered. There are 4 types of parameter available for the length of messages:

  • The message length is less than or equal to
  • The length of the message is greater than or equal to
  • The length of the message of the person who was answered is less than or equal to
  • The length of the message of the person who was answered is greater than or equal to

# Conditions according to user parameters

Conditions for triggering a trigger that are related to conditions according to user parameters.

# Length of the username

Calling the trigger via the username length parameter. There are 2 types of parameter available according to the length of the username:

  • The length of the username is less than
  • The length of the username is longer than

# Length of first and last name

Calling the trigger via the first and last name length parameter. There are 2 types of parameter available in total according to the length of the first and last name:

  • The length of the first and last name is less than
  • The length of the first and last name is more than

# Conditions by username or username

The trigger will only work on the specific name and username specified in the condition values.

# Conditions by user rank

Conditions for triggering a trigger that are related to the rank system.

Rank is the current status of the participant in the chat. Ranks are given for performing certain actions that are set by the chat administrator. There are 3 types of parameter available according to the value of the participant's rank:

  • The user's rank corresponds to
  • The user's rank is lower
  • The user's rank is higher

# Other conditions

# Regular expression

The most powerful and most difficult condition. It provides endless functionality for your bot. With this tool, you can create any conditions for a message, user name and login! It can replace a whole chain of conditions in triggers and even most text filters.

Performs a search based on a regular expression of the Java language. The tester and a short guide to regular expressions are available by clicking on the "Help" button in the upper panel - "Testing regular expressions". There is also a short article on regular expressions in the instructions (opens new window)

# Type of response

Any – the condition will work for any message; All replays – the condition will only work on replays (answers); Replays to the bot – the condition will only work on bot responses; Replays to the user – the condition will only work on user responses, except for administrators; Replays to the admin – the condition will only work on the responses of administrators;

Warning

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

Replays to @ChatKeeperBot – the condition will work on replies to messages from @ChatKeeperBot; Do not replay – the condition will work on messages that were not sent by replying (reply); User's first message – the condition will be triggered at the first message of the new participant.

# Modifiers for condition handling

They allow you to filter out anything unnecessary in user messages, without specifying it in the conditions.

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 "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.

# Trigger with a regular expression

A trigger with a regular expression is the easiest to set up and does not require manually adding a long chain of conditions.

Only one category is selected as a condition: "Other - Regular expressions".

Description

The first step is to indicate the search area for the bot using the "Select condition type" field. The bot will check the selected area for a match with the condition in the regular expression.

The bot can handle:

  • user's message
  • the message that was answered
  • user name
  • the name of the responding user
  • user's login
  • the username of the responding user

As an example, we will specify the search area "User Message".

Description

In the "Condition Values" field, you insert a ready-made regular expression template. All ready-made templates are presented here below.

For example, let's take a template with which the bot will respond to messages written entirely in English:

^[A-Za-z\d\s.,!?]+$ – search for a text consisting entirely of Latin letters, taking into account spaces, any numbers and certain characters ".,!?"

Description

For a trigger with a regular expression, it is also acceptable to use modifiers. With the help of modifiers, the bot will not take into account additional conditions that clog up the search. For example, you can enable "Ignore emoji". Then the bot will ignore any emoji anywhere in the user's message and process the text as if they are not in it.

The "Invert condition" setting is always disabled by default. This means that the bot will react if a match is found with a condition in its search area. If you enable "Invert condition", the trigger will work the other way around and the bot will respond to anything that does not meet the specified condition.

For our example, where the bot should respond to messages in English, the setting remains disabled.

Description

As a reaction of the bot, you can specify any appropriate type of action. Let's take the action "Send a message to the chat" for our case, where in the text field we ask the user whose message the bot reacted to to contact the support chat for foreign users.

Description

An example of how triggers work with a regular expression for searching and responding to user messages, completely written in English, taking into account spaces, any numbers and certain characters ".,!?". Excluding emoji (built-in modifier)

Description

# Search for a phone number

Triggers with regular expressions to search for different phone numbers can be useful for a group in several cases:

  • protect the group from spam and fraud
  • specify the mandatory conditions for publication. For example: a job advertisement indicating the phone number for communication.

((8|+7)[- ]?)?((?\d{3})?[- ]?)?[\d- ]{7,10} – search in the text of a city or mobile phone number, which may contain brackets " ()", dashes "-", spaces, area code "8" or "+7" and consist of 7 to 10 digits, excluding the area code.

This regular expression is universal and suitable for searching all popular formats for writing mobile and landline numbers. It is equally suitable for combating spam and for checking group ads with mandatory indication of contacts.

Description

(8|+7)\d{10} – search for a mobile phone number in the text, which may contain the area code "8" or "+7". The number can consist of only 10 digits, excluding the area code.

This regular expression is strict. It is suitable for searching for only 2 formats of a mobile phone number. It is not suitable for anti-spam, but it can be used if you have strict requirements for publications in the group.

Description

(8|+7)(-|()?\d{3}(-|))?\d{3}-?\d{2}-?\d{2} – search for a mobile phone number in the text, which may contain brackets " ()", dashes "-", area code "8" or "+7". The number can consist of only 10 digits, excluding the area code.

Description

# Search for bank card numbers

Triggers with regular expressions for searching for different bank card numbers belong to the same categories: spam prevention and checking group ads.

Warning

To prevent spam, we recommend adding 2 separate regular expression conditions to one trigger so that they work through the conjunction "OR". Check the phone number in the first one, and the bank card in the second one.

(2|3|4|5|6)\d{3}(\ |-)?\d{4}(\ |-)?\d{4}(\ |-)?\d{4} – search in the text for bank card numbers with the types of payment systems Visa, MasterCard, Maestro, American Express, MIR. The card number can contain spaces, dashes "-" and consist of 16 digits.

The regular expression is universal, suitable for searching all popular formats for writing bank card numbers and takes into account most payment systems.

Description

(2|3|4|5|6)\d{15} – search in the text for bank card numbers with the types of payment systems Visa, MasterCard, Maestro, American Express, MIR. The card number can consist of 16 digits.

A strict regular expression and with a limited type of number spelling check. Spaces and dashes are not taken into account. It reacts only to the combined spelling of the card number.

Description

2\d{3}(\ |-)?\d{4}(\ |-)?\d{4}(\ |-)?\d{4} – search in the text for bank card numbers of the MIR payment system. The card number can contain spaces, dashes "-" and consist of 16 digits.

A regular expression for searching for cards of only 1 type of payment system. It can be used for Russian-language chats.

Description

3\d{3}(\ |-)?\d{4}(\ |-)?\d{4}(\ |-)?\d{4} – search in the text for the numbers of bank cards of the American Express payment system. The card number can contain spaces, dashes "-" and consist of 16 digits.

Description

4\d{3}(\ |-)?\d{4}(\ |-)?\d{4}(\ |-)?\d{4} – search in the text for the numbers of bank cards of the VISA payment system. The card number can contain spaces, dashes "-" and consist of 16 digits.

Description

(5|6)\d{3}(\ |-)?\d{4}(\ |-)?\d{4}(\ |-)?\d{4} – search in the text for the numbers of bank cards of the MasterCard or Maestro payment system. The card number can contain spaces, dashes "-" and consist of 16 digits.

Description

# Search for a language mark

Triggers with regular expressions to search for different language characters help filter users' text by language. It can be used to process user messages if you have multiple chats for an audience from different countries. You can create regular expressions that will search for individual characters and words in a particular language in a message. Or search for messages that are entirely not in the language of your chat.

[A-Za-z] – search for at least one Latin character in the text in the range A-Z (uppercase) or a-z (lowercase).

The regular expression will look for the presence of any one uppercase or lowercase Latin character in the text. It can be absolutely any letter from the alphabet anywhere in the text.

Description

[A-Za-z]+– search in the text for at least one English word consisting of Latin characters in the range A-Z (uppercase) and a-z (lowercase). A word can consist of uppercase and lowercase letters, or only uppercase or lowercase letters.

A trigger with such a regular expression will allow the content of 1 Latin character in the text, but respond to a word consisting entirely of them. This is a mild regular expression that forgives typos in the text (hello), but reacts to English words.

Description

[^A-Za-z] – search for at least one character in the text, except Latin characters in the range A-Z (uppercase) or a-z (lowercase).

A trigger with such a regular expression prohibits the use of characters in any language other than English in the text. The text must consist entirely of Latin letters so that the trigger does not work.

Description

[А-Яа-я] – search for at least one Cyrillic character in the text in the range A-Z (uppercase) or a-z (lowercase).

The regular expression will look for the presence of any one uppercase or lowercase Cyrillic character in the text. It can be absolutely any letter from the alphabet anywhere in the text.

Description

[^А-Яа-я] – search in the text for at least one character other than Cyrillic in the range A-Z (uppercase) or a-z (lowercase).

A trigger with such a regular expression prohibits the use of symbols in any language other than Russian in the text. The text must consist entirely of Cyrillic letters so that the trigger does not work.

Description