The planning of this is an outcome of the unconference we had in Januari in London, with LLR, Amnesty Flanders, MAF Norway, Decaid Consulting and CiviCooP. The aim for this sprint, which last for only one week, is to create a trigger/action functionality for civicrm. E.g. we want a trigger that a donor becomes a member of a group of its total contributions are more than 25.000 euro's. Or when a contribution is completed we want to sent out a thank you message based on the communication preferences (e.g. e-mail, sms, postal mail).
What we have done today is to brainstorm on how we want to setup the extension for the trigger and actions. We have created a data structure and started working on the first draft of the user interface. In this blog I want to introduce and explain the data structure and the working of the triggers.
Internal working
The internal working of the trigger action extension is based on three components:
- A trigger (e.g. amount of total completed contribution is more than 25.000 euros)
- An defined action (e.g. add contact to a specific group)
- Trigger-Action definition. This is combining a trigger with an action and adding information on when to do the processing (e.g. every morning, always, weekly).
The Trigger-Action mechanism will be checked with a regular cron job. So that the triggers and actions can be delayed/processed at a specific time and so that they don't block the user interface.
Data structure
The data structure for the extension follows the internal working except that another tabel is added. So we and up with four tables
- civicrm_trigger_rule - the trigger (description of the entity e.g. contribution)
- civicrm_trigger_condition - the conditions for the triggers (e.g. sum of total amount of contributions, e.g. only contribution with status complete). Multiple conditions can be combined for a trigger
- civicrm_action_rule - the definition of what to do, which consist of the api parameters, api entity and api action. This way we make it possible to define every action which is possible through the api
- civicrm_trigger_action - linking of triggers and actions together with a schedule parameter
The data structure might change during the week so for a more actual description of the data structure see the documentation of the extension on GitHub: https://github.com/CiviCooP/org.civicoop.triggers/blob/master/docs/dataStructure.md
For developers: The trigger extension and its documentation can be found at https://github.com/CiviCooP/org.civicoop.triggers so if you want to contribute feel free to fork and do pull requests of this repo.