---
title: "Walkthrough: Customizing interaction purge conditions"
slug: "walkthrough--customizing-interaction-purge-conditions"
abstract: "Walkthrough to extend the purging tool with custom filters of interaction data."
---
# Walkthrough: Customizing interaction purge conditions

You can extend the purging tool with custom conditions to further filter interaction data extraction before purging. This option is useful to refine the selection of interaction data to purge for more specific use cases.

This walkthrough describes how to:

- Implement the `IInteractionCondition` interface
- Register the custom condition

<details>
<summary><h2>Implement the IInteractionCondition interface</h2></summary>

To create a custom condition:

- Implement the `Sitecore.XConnect.DataTools.Abstractions.Conditions.IInteractionCondition` interface with a unique `ConditionId`.

    > [!note]
    > The `ConditionId` is a string you set that uniquely identifies it in the system. You must pass the `ConditionId` in the `Conditions` POST parameter during [task registration](https://doc.sitecore.com/xp/en/developers/104/sitecore-experience-platform/register-a-purge-contacts-api-task.html "Register a purge contacts API task").

    For example:

    ```csharp
    public interface IInteractionCondition
    {
        bool IsAccepted(Interaction interaction);
        string ConditionId { get; }
    }

    public class ChannelInteractionCondition : IInteractionCondition
    {
        public static readonly Guid ChannelId = new Guid("DF9900DE-61DD-47BF-9628-058E78EF05C6");

        public string ConditionId { get; } = nameof(ChannelInteractionCondition);

        public bool IsAccepted(Interaction interaction)
        {
            return interaction?.ChannelId == ChannelId;
        }
    }
    ```

> [!note]
> The conditions are limited to filter by interaction data. You cannot create a condition based on the interaction facet data in Sitecore 10.2.

</details>

<details>
<summary><h2>Register the custom condition</h2></summary>

You must register the condition in the Cortex Processing Engine and the Processing Worker instance.

To register the condition:

1. Open the configuration file `/App_Data/Config/Sitecore/Processing/sc.XConnect.DataTools.Conditions.xml`.
2. Under the `<Settings>/<Sitecore>/<Processing>/<Services>` tag, register the new condition.

    For example:

    ```xml
    <Settings>
      <Sitecore>
        <Processing>
          <Services>
            <Condition.ChannelInteractionCondition>
              <Type>Sitecore.XConnect.DataTools.SampleConditions.ChannelInteractionCondition,Sitecore.XConnect.DataTools.SampleConditions</Type>
              <As>Sitecore.XConnect.DataTools.Abstractions.Conditions.IInteractionCondition,Sitecore.XConnect.DataTools.Abstractions</As>
              <LifeTime>Singleton</LifeTime>
            </Condition.ChannelInteractionCondition>
          </Services>
        </Processing>
      </Sitecore>
    </Settings>
    ```
3. Repeat this step for the configuration file `/App_Data/jobs/continuous/ProcessingEngine/App_Data/Config/Sitecore/Processing/sc.XConnect.DataTools.Conditions.xml.`.
4. To allow the custom condition to be passed to a data purge task, the `AllowedInteractionConditionIds` node should be modified in the Processing Engine file: 
`/App_Data/Config/Sitecore/Processing/sc.XConnect.DataPurge.Validation.xml`.

    For example:

    ```xml
    <AllowedInteractionConditionIds>
        <YourCondition>ChannelInteractionCondition</YourCondition>
    </AllowedInteractionConditionIds>
    ```
5. Restart the Processing Engine and the Processing Worker to pick up the configuration changes.

> [!note]
> You cannot get a list of all the registered conditions. After you extend processing with a custom condition, you must make a note of the `ConditionId`.

</details>