# 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="https://2141378775-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuUonpFWM7AJ0xVVXV1tr%2Fuploads%2F9dpVeBUQ2MRH8Kv9AW6R%2Fimage.png?alt=media&#x26;token=ac1b289c-211f-4943-bc87-437169b39ac2" 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](https://docs.struct.com/fundamental-concepts/products-and-variants) with the 'Dangerous goods' [product structure](https://docs.struct.com/fundamental-concepts/product-structures).

<figure><img src="https://2141378775-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuUonpFWM7AJ0xVVXV1tr%2Fuploads%2FUt7apBnaO5n7nE5pRhy7%2Fimage.png?alt=media&#x26;token=8705b19b-840a-4b47-9e8c-ff3e5600caab" 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="https://2141378775-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuUonpFWM7AJ0xVVXV1tr%2Fuploads%2FITudAVemsrUwSnwME9Qz%2Fimage.png?alt=media&#x26;token=e721e739-9a93-4f9d-86dd-1f051cabc495" 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](https://docs.struct.com/fundamental-concepts/products-and-variants) within its scope.

### Combining Enrichment Insights with Business Rules

Integrating [business rules](https://docs.struct.com/tutorials/guides/how-to-use-business-rules) with enrichment insights is an effective way to automate logic, ensuring [products](https://docs.struct.com/fundamental-concepts/products-and-variants) 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="https://2141378775-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuUonpFWM7AJ0xVVXV1tr%2Fuploads%2FHoqeQSZVf0bTomA0oAuk%2Fimage.png?alt=media&#x26;token=d4326d56-389c-490c-9f7e-30ca88da68f8" 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](https://docs.struct.com/fundamental-concepts/products-and-variants) is flagged as a dangerous good, the [product structure](https://docs.struct.com/fundamental-concepts/product-structures) will update to 'Dangerous goods'. This [product structure](https://docs.struct.com/fundamental-concepts/product-structures) includes a property for attaching the safety datasheet.

<figure><img src="https://2141378775-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuUonpFWM7AJ0xVVXV1tr%2Fuploads%2FcBDrLXoj6IJ5N1px9xmc%2Fimage.png?alt=media&#x26;token=dc6c09d9-99b9-4a2e-999f-dd3cd3951ca8" 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](https://docs.struct.com/fundamental-concepts/product-structures) to 'Dangerous goods', which means the field, 'Safety datasheet' will be added to the section 'Delivery information'.

<figure><img src="https://2141378775-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuUonpFWM7AJ0xVVXV1tr%2Fuploads%2FIsgvFc25qTAEy5GMzA9X%2Fimage.png?alt=media&#x26;token=d19f24d4-7878-4fa3-abee-76bc56ca23e2" 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 ](https://docs.struct.com/fundamental-concepts/products-and-variants)that is marked as dangerous goods must be enriched by a safety datasheet document.
