# How to use rules in an enrichment

### Adding rules to an enrichment

Rules are an essential component within Enrichment Insights. They define what scope the enrichment insight should apply to.

To add a new rule, click 'Add new rule' on the 'Edit enrichment insight' page.

<figure><img src="/files/LBZcmFxihRs4O15ihYym" alt="The page in which you create a new enrichment insight, and add rules to it"><figcaption><p>Enrichment insight creation page.</p></figcaption></figure>

You can choose between different scopes for the rule. Select the one that fits your specific needs and use case. In this example we will set up a rule that is applied to all [products](/fundamental-concepts/data-management.md) with the 'Dangerous goods' [product structure](/fundamental-concepts/channels-and-distribution.md).

<figure><img src="/files/LW7788xsfxC2RkaZY0t3" alt="The rule scope selector"><figcaption><p>Enrichment insight rule scope selector.</p></figcaption></figure>

Define the scope, then select fields that you want to enrich on the entity. We select the 'Dangerous goods' boolean attribute that we have created on the 'Dangerous goods'-product structure.

<figure><img src="/files/cueZF5sJKFIDmLmWcniY" alt="The field selector"><figcaption><p>Field selector.</p></figcaption></figure>

Select the necessary fields for enrichment and save your changes. The enrichment insight will be applied immediately to all existing [products](/fundamental-concepts/data-management.md) within its scope.

### Combining Enrichment Insights with Business Rules

Integrating [business rules](/tutorials/guides/how-to-use-business-rules.md) with enrichment insights is an effective way to automate logic, ensuring [products](/fundamental-concepts/data-management.md) adhere to specific rules based on their type. For our example, we want to make sure that all dangerous goods are accurately labeled and include a safety datasheet, as mandated by the dangerous goods regulations.

<figure><img src="/files/GOrf5phxDjWujvnkoJgp" alt="The business rule that is applied to the enrichment insight."><figcaption><p>Business rule applying the logic.</p></figcaption></figure>

We have developed a business rule that monitors changes to the "dangerous goods" property added to the enrichment insight above. If a [product](/fundamental-concepts/data-management.md) is flagged as a dangerous good, the [product structure](/fundamental-concepts/channels-and-distribution.md) will update to 'Dangerous goods'. This [product structure](/fundamental-concepts/channels-and-distribution.md) includes a property for attaching the safety datasheet.

<figure><img src="/files/vnK6grzt39MwJyw4JSpG" alt="The product is as of yet not marked as a dangerous good."><figcaption><p>Product is not marked as dangerous goods as of yet.</p></figcaption></figure>

Checking the 'Dangerous goods' boolean property will change the [product structure](/fundamental-concepts/channels-and-distribution.md) to 'Dangerous goods', which means the field, 'Safety datasheet' will be added to the section 'Delivery information'.

<figure><img src="/files/Lg1cDyuRuLg6k2ahjiSt" alt="The product is marked as dangerous good, adds the property for uploading a datasheet."><figcaption><p>Product is marked as dangerous goods.</p></figcaption></figure>

Notice that an 'Enrichment insights' box has popped up in the right side, making sure that a [product ](/fundamental-concepts/data-management.md)that is marked as dangerous goods must be enriched by a safety datasheet document.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.struct.com/tutorials/guides/how-to-use-enrichment-insights/how-to-use-rules-in-an-enrichment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
