# 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

Пример работы триггера с регулярным выражением по поиску и реакции на сообщения пользователей, полностью написанным на английском языке, с учетом пробелов, любых цифр и определенных символов «.,!?». Без учета emoji (встроенный модификатор)

Description

Готовые шаблоны регулярных выражение ищите в главе "Регулярные выражения" (opens new window)