I want to create a custom Rule?
Rules are very important and most common using thing in Drupal. We can create custom rules programmatically using the hook_rules_action_info. There is a useful hook hook_rules_action_info() provided by rules api to create custom rules programmatically. Using this We can use our custom functions to perform the actions that we require.

Following is a sample of the hook_rules_action_info implementation

function sample_custom_rules_action_info() {
  return array(
    'sample_custom_action' =&gt; array(
      'label' =&gt; t('Custom Rule Action'),
      'parameter' =&gt; array(
        'param1' =&gt; array(
          'type' =&gt; 'int',
          'label' =&gt; t('Sample Label'),
        ),
        'param2' =&gt; array(
          'type' =&gt; 'commerce_order',
          'label' =&gt; t('Sample Label2'),
        ),
      ),
      'configurable' =&gt; FALSE,
      'group' =&gt; t('sample Custom module action'),
      'callbacks' =&gt; array(
        'execute' =&gt; 'sample_custom_action',
      ),
    ),
  );



Label for the rule action appears in the Rules interface.
Parameter that needs to be passed to the custom action function
A group for this element, used for grouping the actions in the
interface.
callbacks are array of custom functions that to be used for this
action's functioning.


This function has more parameters, but the above are most required ones to create a custom action.

Video tutorial

Creating a Rules Action