Using ConfiForms IFTTT macro for integrations

Since version 1.4.12, ConfiForms plugin has a new macro to enable integrations: IFTTT - If This Then That

As of now the macro supports 3 events and 3 actions:

  • send emails
  • create a Confluence page.
  • make request to another service

Email body (and page content) are defined by the user and are the combination of Velocity templates together with RichText Confluence macros.

Where the macro should be placed?

Macro should be placed inside the ConfiForms form macro. You can place any number of IFTTT macros for one form. Here is how it looks like in the editor

Sending email when new record is added

Here is an example how this can be done:

The macro to be added inside the ConfiForms form macro.

  
    Your record has been added, [owner]
    onCreated
    Send Email
    [owner]
    
      

Hello ${ownedBy}

There was a new record added to the form.


You can add as many 'confiform-ifttt' macros as you want. The events are processed in the same order as you define them.

The list of exact parameters available you can see in the 'confiform-ifttt' macro preview.

Additionally this objects are also exposed:

  • user - with properties: name, fullName, email.As documented here
  • page - with many properties documented here. Please note that you can use getters only. Example: ${page.displayTitle}, to refer to getDisplayTitle() method (no space after $)

Creating a Confluence page when a record is deleted

The example below assumes you have a ConfiForms form with fields: employee (of type User)

  
    onDeleted
    Create Page
    Access has been revoked from [entry.employee]
    [owner],access@somecompany.com
    
      

Hello ${ownedBy}

Record has been deleted. Here is the copy of the data:

Name: ${employee.fullName}

Login: ${employee.username}

Record created: ${created}

How to reference form data when constructing a email subject/page title/url

As it is a macro parameter we have decided to use the following syntax [entry.FIELD_NAME] (using $ and curly braces {} inside parameter ruins macro editor L&F in Confluence)

There are some reserved variables to reference metadata.

  • [modifier] - to conveniently reference record last modifier
  • [owner] - to conveniently reference record owner
Example

Assuming the form has a field 'caseNumber' defined and you want to reference it in the email subject, as well as put the name of the user who has changed the data Here is how the subject will look like:

[modifier] has changed the details of [entry.caseNumber]

The [modifier] with the full name of the user who has changed the data and [entry.caseNumber] will be replaced with the data value of "caseNumber" field

This is how it looks like in the Confluence editor

How to reference form data when constructing a email body/page content/data to send to url

Macro body is basically taken in as Velocity template. Therefore to reference fields you need to use velocity notation and syntax, ${FIELD_NAME} or ${entry.FIELD_NAME} (especially if you need to access Field's metadata properties) Also, User object is accessible through: ${user} and Page object is accessible through: ${page} See, plugin documentation for IFTTT macro to see the list of properties you can reference there

Example

Assuming the form has a field 'caseNumber' defined and you want to reference it in the email body,

Hi!
There is an update to your case: ${caseNumber}
Last updated by: ${user.fullName}

Your ConfiForms team

Email template has 3 parameters: ${entry.id}, ${caseNumber} and ${user.fullName}

So, we reference record id, caseNumber and the current user metadata

'caseNumber' could be referenced also using slightly more complex syntax: ${entry.raw.get('caseNumber')}

This is how it looks like in the Confluence editor

What can be referenced

Each entry always has the following metadata

  • id - record id, unique uuid for every saved record
  • ownedBy - username of the user who owns the record (and can fully control it)
  • ownedByName - full name of the user who owns the record
  • createdBy - username of the user who has created the record (admin users can create records for other users)
  • createdByName - full name of the user who has created the record
  • created - timestamp when the record was created
  • dateCreatedFormatted - formatted way to see created timestamp
Additionally to user-defined form's fields (fields you have defined for your form using ConfiForms Field Definition macros)