Introduction
The CiviRules module adds advanced automation capabilities to CiviPlus by allowing you to to define and implement rule-based actions within your system. There is a user-friendly interface for creating and managing rules without needing to write any code, and since it is ntegrated with other CiviPlus modules, such as Contributions, Events, Memberships, and Activities you can automate processes across different aspects of the system.
There are several key features within CiviRules:
Automated Actions: CiviRules automates various actions, such as sending emails, based on certain conditions or triggers.
Triggers and Conditions: For each rule you first configure one or more triggers (events that start the rule) and conditions (criteria that must be met for the rule to be executed). For example:
Trigger: A new payment is made.
Condition: The payment amount is greater than £100.
Action: Send a personalised thank-you email
Customisable Actions: You can define the actions that should be taken when a rule is triggered and conditions are met. In this article we will focus on triggered emails, but actions can also include updating contact records, adding contacts to groups, or creating activities.
Creating a triggered email rule
You can see all the existing CiviRules, and create a new rule, by navigating to Administer -> CiviRules -> Manage CiviRules. Click the + ADD CIVIRULE button to start configuring a new rule (you can also edit existing rules from this page). In this example we'll create a rule to automatically send an email to an individual if they cancel their membership.
The first part of the page covers the Name and Description of the new rule, and you can also assign it a tag which is to organise and find rules if you have a lot of them (the tag(s) need to have already been created - see Administer -> CiviRules -> CiviRules Tags). You can also provide a more detailed description of what the rule is used for, and finally specify whether it is Enabled or not (rules will not be triggered if they aren't enabled).
Next we start to configure the rule, starting with the linked trigger. In our example this will be a change to the membership status:
After clicking NEXT we will add a condition that is linked to the trigger by clicking the ADD CONDITION button.
We want to trigger the rule when there is is a change of membership from Current to Cancelled, so we'll select the "Compare old Membership Status to new Membership Status" condition.
When you click SAVE you be asked to provide the old membership status value and the new membership status value that need to be compared - in our example Current is the old value and Cancelled is the new value. We only want the rule to trigger once, so it is the transition from one status to another that will cause it to be invoked one time.
Finally, having specified the trigger and conditions for this rule, we need to say that we want an email to be sent when the rule is triggered - click the ADD ACTION button to do this:
In the Select Action box we choose the "Send E-Mail" action, and since we want to send it straight away we choose the "- No Delay -" option in the next box. We could choose to delay the sending of the email using a variety of options, in which case the Don't recheck condition upon processing of delayed action option comes into play. If left unselected then the trigger and conditions will be checked a final time after the delay period, if selected a final check will not be made. So, in our example if we said we wanted to delay sending the email for 2 days after the cancellation, if the individual changed their mind and rejoined then the email would not be sent, even though the conditions were originally met.
Since the action we selected was to send an eMail, when you click the SAVE button you are asked to complete some details about the email to be sent:
The From Name is the name the email will be sent from and the From Email is the email address the email will be sent from. Leave these blank to use the defaults configured in your CiviPlus system, or add different ones if you want.
The From Email Addressess is where you select which From Email Address will be used to send an email (you can create and edit them in Administer>Communications>FROM Email Addresses)
The Message Template is where you select which CiviPlus message template will be used to compose the mai (you can create and edit them in Administer>Communications>Message Templates)
The next section allows you to manipulate where the email will be sent to.
By default the email will be sent to the primary email address of the contact in question. You have the option to deviate from that behaviour in 2 ways:
You can select to use an email address of a specific location type, for example Work. You do that by selecting the location type. The mail will be sent to the newest email address of that location type (if there are more than one for the contact). If no email address of the specified location type is found, the email will still be sent to the primary email address of the contact
If you do not select a location type you can tick the Send to Alternative Email Address box. You will then get the option to enter an alternative email address. Obviously you have to enter a valid email address here.
Finally you can specify an email address for the CC to (a copy of the email will be sent to this email address and the email address will be visible to the recipient of the email too) or the BCC to (a copy of the email will be sent to this email address and the email address will NOT be visible to the recipient of the email too).
The sending of the email will also lead to an activity of type Email being recorded for the contact in question, whatever email address will be used.
Click SAVE AND DONE to save the new rule. Now if someone cancels an active membership they will automatically be sent an email message, perhaps asking them to reconsider, or a reason for cancellation. This email itself will be logged against the contact's record.