# (7) Set Rules

### Things you should know

Rules are a set of certain conditions to tell the bot what to respond. To put it simply, rules are the connections between **“what bot understands”** (e.g., NLU) and **”what bot responds”** (e.g., message). Setting rules means to set up which message the bot will respond with, once the bot understands certain contents.

### Steps

1. Click on **`My Bot`** > **`Dialogue`**
2. Select the **message** that you want to add rules on.
3. On the top, select **`Rules`** , then add a rule by clicking **`+ Rule`**
4. On **`Type`** , choose the type of rule (Types are illustrated as follow.)

![](https://4036424674-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlAIFssOEGqft8svll9%2F-LpSHT0MRzHmkGdj05nH%2F-LpSH_sqCyWXYiI5qaj-%2Fimage.png?alt=media\&token=b9537309-e7a1-417b-822c-c066f1d7eadd)

### Types of Rules

1. NLU (Intent and Entity)
2. Keyword matching (one or more keywords)
3. Regular expression

Method 1 and 2 are more commonly used. Below is an in-depth description on the differences.

#### 1. Using NLU as a rule

‌Set a rule with intents and/ or entity as a rule.&#x20;

For example: Intent **“Take away”**, **“Price”**, Entity **“Drinks”**

![](https://4036424674-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlAIFssOEGqft8svll9%2F-LpSHT0MRzHmkGdj05nH%2F-LpSHdDlA4ci21iZ7bFm%2Fimage.png?alt=media\&token=8566b604-a6fb-463b-a21b-fe70a41870d4)

![](https://4036424674-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlAIFssOEGqft8svll9%2F-LpSHT0MRzHmkGdj05nH%2F-LpSHgA795SCPvcPTUgD%2Fimage.png?alt=media\&token=d24b1959-7b2b-464a-adb2-0e609b1de264)

#### 2. Using keyword matching as a rule

For instance, you can set keywords such as “take away” or “order” as a rule. When any of these keywords appears in the sentence, it tells the bot to respond with this message.

![](https://4036424674-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlAIFssOEGqft8svll9%2F-LpSHT0MRzHmkGdj05nH%2F-LpSHiu77Kggful1jVUh%2Fimage.png?alt=media\&token=0f23de44-ed55-457e-99d9-39d937067c6c)

#### ‌3. Using regular expressions as a rule

Regular expression is a sequence of characters that define a search pattern. \
For instance, you want to set up a rule that can match the words including “order” and “take away”, you can use regular expression as the rule.&#x20;

**I want to order drinks.**\
**I want to take away .**

The above sentences, you can use a single regular expression to match both of them.

**^I (want|would like to) (order|take away)(drinks)?.$**

For more detailed tutorial, check out [Regular Expression](https://app.gitbook.com/@docs-en-yoctol-ai/s/yoctol/~/edit/drafts/-LnQJsTXatUDJ-slOjKr/v/master/term-translations/regular-expression)

![](https://4036424674-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlAIFssOEGqft8svll9%2F-LpSHT0MRzHmkGdj05nH%2F-LpSHlyBs_M9YNnuQUhN%2Fimage.png?alt=media\&token=e4add760-a994-4972-936c-10af66afbd16)

{% hint style="danger" %}
Note: A particular rule can be only used in one message. A message can contain several rules.
{% endhint %}

##
