@Hansauto here are some examples of rule detection algorithms. Based on transactions.
You could also check this example (maybe improve using ChatGPT).