Configure Regular Expressions

From English wiki app24.online
Jump to navigation Jump to search

Regular expressions are templates of questions and messages for which the chatbot can send replies. You can find regular expressions on the chatbot control panel:

Panel botApp24

To create a regular expression, you must have a good knowledge of a special formalized query language. The idea of the language is that some characters of a message (question) are replaced by such special characters as ^ $ * + ? { [ ] \ | ( ). They make questions more universal.

Imagine that customers sent the following questions:

  • Hello! Tell me how do I collect my goods?
  • Could you tell me how to collect the goods?
  • I don't know how to collect the goods. Please, tell me about that.

These questions are different, but they have something in common:

  • All of them have a sequence of words “how”, “collect”, and “goods”.
  • Chatbot must send the same answer to these questions.

If you want to teach the chatbot to answer these questions, do the following:

  1. On the BotApp24 control panel, click Add.png.
  2. On the Add Item window, fill in the fields:
    Example regular expression
    • In the first field, specify the reply that the chatbot must send.
    • In the second field, specify a regular expression. For example, you can use the following regular expression for these messages:
      /.*How.*collect.*goods.*/miu
      In the example below, you can find a detailed description of this regular expression.
    • In the State drop-down list, select Switched on.
  3. Save your changes.
  4. Refresh the browser page.
  5. Make sure that the regular expression has the Switched on value in the State column.
  6. Configure the Open Channel and test the chatbot

IMPORTANT. If your regular expression contains an error, you won’t receive an automatically generated reply from the chatbot.

To modify the regular expression, click Change.png. In the dialog box that opens, make necessary changes or delete the regular expression.

Change panel.png

Example. Create Regular Expression

Regular expression /.*How.*collect.*goods.*/miu can be applied to generate an answer for the following three questions:

  • Hello! Tell me how do I collect my goods?
  • Could you tell me how to collect the goods?
  • I don't know how to collect the goods. Please, tell me about that.

All regular expressions start with / and end with /miu.

A period (.) may replace any character, except for a line break. An asterisk (*) declares that a character can repeat 0 or more times until the word specified in the regular expression is met. On the picture below, you can read how it actually works:

Shema.png
Sentence “Hello! Tell me how do I collect my goods?” has phrase “Hello! Tell me” before word “how”. This part of the phrase consists of letters, an exclamation point, and spaces. The period character replaces any of these characters. If there was only a period, then only one character could be before word “how”, for example, a space character or not character at all. An asterisk declares that any number of character can be before word “how”. This principle explains why a period and an asterisk is between other words.

You can find the list of special characters in topic "Special Characters for Regular Expressions". We recommend that you check regular your expressions in the special services, such as ”Regular Expressions”. Keep in mind that if your regular expression contains an error, you won’t receive an automatically generated reply from the chatbot.