Skip to main content

Basic pattern elements


* — any characters in any quantity.

How to use

state: catchAll
q!: *
a: I don’t understand you.
state: start
q!: *
a: Let’s get started!
go!: /SecondStep


word — a word: checks if the response contains the specified sequence of characters.

If a client enters additional characters (words), the response will not match the pattern.

How to use

q!: hello
a: Hello! What’s up?

If a client sends or says to a bot Hello bot, the response will not match the hello pattern.

* stem *

*stem* — a stem: checks if the word contains the specified character sequence.

Asterisks can be placed:

  • In the beginning, to denote a variable prefix: the *put pattern will match input, output, put.
  • In the end, to denote a variable suffix: the put* pattern will match putting, putter, put.
  • Both in the beginning and in the end, to denote variable prefixes and suffixes: the *put* pattern will match outputting, put.

How to use

q: * *info* * // will match "info", "information, "metainfo"
a: More information is available at

(word1|word2|or a phrase)

(word1|word2|or a phrase) — alternatives: checks whether the request contains any of the given alternatives.

The options are separated by either | or /. They may recursively contain any other embedded pattern elements.

How to use

q: (hello | good* (morning/day/evening) | greet* )
a: Hiya!

[an optional word|or another phrase]

[an optional word|or another phrase] — options: elements within square brackets need not be present within the request.

If they are, the weight of the pattern is increased.

You can also use alternatives with options.

How to use

state: How many players
q: * {(how [many|much]) (gamer*|player*|people) [can] [play]} *
q: * [game] for one * [or] [many] *
q: * {([game]|in the game) [is] [there] (multiplayer [mode]|for several player*)} *
a: This is a single-player adventure.

{word1 word2 (1|2)}

{word1 word2 (1|2)} — permutations: checks whether the request contains the specified elements in any order.

Permutation elements are separated by spaces.

Any element may recursively contain other pattern elements to an arbitrary level of embedding.

How to use

state: How much gameplay
q: * {(how [much|many]) gameplay} *
q: * {[how] (big|great) [is] [the] [game]} *
a: The script for this game took about 2 thousand pages!

Usage notes

Permutations should contain 5 to 6 elements at most. Using more permutation elements slows down the bot considerably.
If you want to account for word order variation using permutations, you can split the pattern into several smaller patterns and use grouping for phrases where the word order is fixed.

For instance, a pattern like * {information * about * taxes and insurance} * can be rewritten using several patterns:

* information * about * {taxes and insurance} *
* (taxes and insurance/insurance and taxes) * information *