In this tutorial you will learn how to send conditional emails with ConfiForms IFTTT macro, and also some tricks around it.
This tutorial uses the concept of IFTTT results chaining, described here: Advanced integrations with IFTTT macros with ConfiForms
If you are new to ConfiForms, please take a few minutes to read the Basic concepts Guide, or go through the video tutorial on that page.
Quite often we have been asked if ConfiForms could send emails with form data but only "when some checkbox is checked". And we have a solution for you to share. It is a bit advanced, so if you are very new to ConfiForms, please read the tutorial about basics and then come back. Also a concept about IFTTT results chaining and how to reference and use it would be beneficial to learn (See link above).
We will start, as usual, with form definition.
Simple form with just 2 fields: One of type "text" and another is of type "checkbox"
"Checkbox" field will tell us when an email should be send out.
Then we add 2 IFTTT handlers (we set to catch only onModified events, so if you want to have the same logic for new items you will need to add 2 more similar handlers, which will be executed on "onCreated" event). For simplicity we define only 2 here, one for sending emails when checkbox is selected and another one to put the checkbox field value back to "false". See screenshots below
See the "condition/filter" we set here: IFTTT is executed only if the checkbox value is set
Here we update the ConfiForms entry "back" after the email is sent. We can actually "optimize" it here a bit and only execute when checkbox is actually checked, but for simplicity we choose to execute it each time, and reset the value for checkbox on each "save".
This configuration allows us to support cases when email should be sent only when some field has a certain value set and then we are able to reset the field back to original/default value automatically.
Here is how the form configuration looks in Confluence editor, the ordering of IFTTT handlers is important
And the final view of the form when user enters data: