Extension Steps

This Extension is a Step in a Flow.

It is executed for all relevant recipients in a flow as they pass through the step, just like any standard Step type. It’s useful if you need to do some more advanced calculations on particular recipients or if you’re pushing/loading data from a remote server in a way not supported by the standard features provided by Agillic.

See our Recipient API, Export Flow, Webhook, or Side Effect documentation pages to see if there is already a standard functionality which solves your use case

Extension Steps are present in Agillic’s Flow UI, as a Step:

Execution Method

The execution method for an Extension Step must be called execute, assumed to return a boolean value. It should return true if the execution was successful and false otherwise.

If the script doesn’t return a value, returns something which is not a boolean, or throws an exception it’s treated as false.

If an exception is thrown, or the extension returns false, you can define if there should be retries with an interval, and if the recipient should be kicked from the flow on failure.

//@id:"ExtensionStep"
//@type:"step"
function execute(recipient,global,settings) {
   return true;
}

All data-writing operations are queued up during a step for each recipient. If the execution method does not return true, these writes do not take place. See writing data for more details.

Arguments

The input arguments for Extension Steps are:

  • recipient: provides access to the recipient (Person Data, One To Many Tables, Target Groups, and Event Achieving)
  • global: provides access to global data (Global Data and Global Data Tables)
  • settings: enables configurators to provide setting attributes from the Flow Step UI, for each particular implementation of this extension.
  • flowContext: provides access to data regarding the current execution.

See the Read and Write section for details on how to use these arguments.

Optimizations

In Extension Steps & Condition Extensions you can optimize the extension data-read time by declaring which Person Data fields, Target Groups, and One To Many tables you need access to during evaluation. These input values are defined with additional methods in your extension code.

Agillic will pre-load the specified data to optimize execution.

We strongly recommend that these pre-loading functions are used when possible. You can even use the same settings argument (if present in the extension type’s execution method) to define what entities need to be pre-loaded.

None of the methods are required, and if they are not declared in the script we treat it as an empty list of requirements. The methods are assumed to return a list of strings with the names of the relevant items to load.

If you want to read the Target Groups a recipient belongs to, it is mandatory to declare them in this pre-loading function, as the performance overhead would otherwise be too great. If you try to load a Target Group that you have not pre-loaded, the script will fail.

function getRequiredPersonData(settings) {
    return ["AGE","LASTNAME"];
}
 
 
function getRequiredOneToManyTables(settings) {
    return ["PURCHASE","COUPONS",settings["INPUT_OTM_1"]];
}

 
function getRequiredTargetGroups(settings) {
    return ["Gold customers","All recipients"];
}