Triggers, automation, etc

I have huge issue. To be short, question is: How to build automation (or
triggers) for my application, save them to database and call when
condition is true.

Longer:

Tickets system have that feature.

Customer opens new ticket, system (after_create, update) probably calls
trigger model and do some actions based on conditions. How to prepare
tables, saving conditions and actions etc? Biggest question is how to
compare what happened with model (action, attributes) so I can run
actions based on changes.

Is there any sample or something so I can check on my own.

Do a search for any rails forum software and look through the models in
github for what you are seeking. Callbacks are your best bet here,
although there is a notifications system in place you can use as well.
I find the notifications system a little memory intensive at times
though.

If you want to go towards notifications, look at this screencast here: