How to identify which Rule is triggered? I have a collection of email notifications created with Drupal Rules module and a separate custom database table with the ID's of the rules and emails to exclude from individual notifications.

I need to know which rule is being triggered so I can query my custom table for the correct emails to exclude. Creating custom conditions would not work because I have 20+ rules using the same custom action.

The only hook that I can find that is triggered after a rule is executed is hook_rules_config_execute but it does not give me information only on the specific rule that triggered.
Below are 2 approaches that might work ...

Approach 1

Create a NEW Rules Component like so:


It uses some "identifier" as a parameter, of type something like "text" or "integer".
All this component does, is to also perform your custom action.


For each of your existing rules, rework that Rules Action like so:


Replace it by performing the new Rules Component.
For the (required) parameter of the Rules Component, use some unique value (just an integer, or maybe the machine name of the rule?), so that when the Rules Component is executing, you do know which rule it was that triggered the execution of the Rules Component.


Approach 2

Update each of your rules to contain and pass in a unique identifier. You can just do that by adding another parameter to the existing Rules Action in your rules_action_info hook. Though you'd have to update all your existing rules to make that work.