Take a look at CoRE, a rules engine.
It an be a little daunting at first but you can get help from here.