A regular expression to exclude reactions to certain words

A regular expression for an exception can be applied if in response to almost everything that the user sends, a certain screen or text should come and there are exception words to which the bot should not respond or should respond differently.

In order for the bot to respond to all words except certain ones, you can use such a regular expression:

^(?!var|cost$).+

where var and cost are the words the bot is not supposed to respond to.

For example, the bot has Main menu and you need Template to work on any input from the user, except for the commands of Main menu.

Let’s also make an exception for /start command that starts the bot.

In this case, we use only inline buttons from Button component in the bot, since Template will also respond to text buttons clicks (Buttons with hints), as well as to the text from the user.

Let's add our regular expression to Template event with Regular Expression data type to exclude the response of the event to a menu item and /start.

^(?!/start|/menu$).+

We recommend to add /start in any case, even if there is no such command in the main menu. It gives the user an opportunity to restart the bot.