Using “onComplete”

Using “onComplete

Using “onComplete”

When launching your flow, you have the option to supply an onComplete function to be executed prior to your subscriber exiting the flow.
The onComplete function is called prior to any exit actions defined within your flow and it’s executed for all paths that result in the user leaving the flow:
  • Canceled
  • Incomplete
  • Accepted a Response
 
The function will receive a single argument - the outcome of the flow.
If the function returns a Promise, Raaft will wait for it to be resolved before continuing.
Here's what a typical promise based onComplete function would look like:
raaft('startCancelFlow', subscriptionId: 'sub_fdak4k3k4223m', authKey: '<security-token>' //... onComplete: function (result) { return new Promise(function (resolve, reject) { // example: retrieve new data and update UI }); } }
 
The result object has all the details of what your customer did during their interaction with the Flow. The main value you'll want to look for is result.outcome, which will have a value of "canceled", "saved", "aborted", or "error" depending on the how the user exited the flow.
Here are a few ideas for how to use the onComplete function:
  • Update your CRM with the results of the flow
  • Retrieve new data from your subscription processor
  • Log out canceled users
  • Update UI elements based on outcome