Frontly's Previous Step variable, represented syntactically as 'step' today and as 'actionSteps' before, is a variable that is situationally used with some actions in your custom action flow.
This article will help clarify its various use cases whilst configuring your actions, while also clearing up any formal changes between the new 'step' variable the old 'actionSteps' one.
Background
Frontly's Custom Action System enables your app to perform automated tasks that are triggered by your users interactions with it. You can run multi-layered actions that can cascade in sequence and create multiple pathways based on your run conditions.
For an overview and full list of Frontly's Custom Actions, click here.
As part of their set up modules, recall that most actions allow you to use Dynamic Variables to fetch values from different parts of your app either to help fulfill the action, or as one of the conditions for your run conditions. Here are some key examples:
Form Variable
Using the {{form.Field}} syntax, store the value of a form input by either referencing its field name in your data source or its field ID if you're using an Input Block or Full Screen Form.
Use case: Using the submitted form inputs to update a row field value in a Google Sheet with the Google Sheet action.
Record Variable
Using the {{record.Field}} syntax, store and use the value of the corresponding field or row that was clicked by the user.
Use case: Clicking on a 'products' grid will update a local state value that will be used to filter the related product records in a table block.
Note that almost all variables in Frontly follow a format that consists of two parts, "Data Source" and "Specifier", the latter of which could either be a field, object, key or step.
In some cases, variables may include a third component that adds an extra another layer of detail to the data stored and used, which in all cases is a field. This leads us into the next section.
Click here for the full comprehensive list of Frontly's Dynamic Variables.
Using the 'step' Variable
The Previous Step variable, as it suggests in its name, uses the output of a previous step action as the input for any subsequent steps that may need to use it after.
As visualized in the image above, the OpenAI Request action is an example of an action that will produce an output, whereby its output can be used as the input for the subsequent Google Sheet action.
In order to reference these action outputs, you'll need to use the 'step' variable formatted just like the other dynamic variables noted in the previous section. However, with this variable, there are two viable formats:
Format A: {{step.StepNumber}}
โFormat B: {{step.StepNumber.Field}}
When to Use Format A:
Use Option 1 when the referenced action step only has a single output.
Example: Referencing the OpenAI Request sequence from earlier, if the Response Type is set to 'Text', the action will only generate one output. This way, you will only need to reference the step it occupies in your action hierarchy.
OpenAI Request Action:
Google Sheet Action:
Other uses for Format A:
When using the data parsed from a Web Scraper action as one of the inputs for an OpenAI Request step.
When using the Logic action to add / remove values from a designated list of values into or out of a data source, respectively.
When returning an HTTP response from a Webhook action to complete additional steps.
As part of a run condition for subsequent action steps in conjunction with the Form Validation action on a custom form block.
When to Use Format B:
Use Option 2 when the scope of the action output needs to be refined further. This is limited to fewer use cases, but will be required over Format A otherwise you may not get the outcome you want out of your actions.
Example: Using the same OpenAI Request to Google Sheet action sequence from above, if the Response Type has instead been set to 'Object', each 'key' you define in the action will have to be referenced in the 'Field' portion, just after filling the 'StepNumber' component to the variable.
OpenAI Request Action:
Google Sheet Action:
Other uses for Format B:
When receiving a response from a Real Time Webhook and you want to access the data from its structured response usually entailing multiple fields and their values.
Changes from 'actionSteps' Variable
As of 08/21/2024, the change from the original 'actionSteps' variable to the current 'step' one was a change meant to address the redundancy of the 'response' field and to streamline the variable itself to make it simpler.
Now, in a past situation where you're typing {{ actionSteps.1.response }}, you can now simply use {{ step.1 }}. This new variable is shorter, cleaner, and easier to work with in text fields
It is worth noting that the original 'actionSteps' variable will still function as before, so no changes are required for existing apps. However within Frontly, we have updated the variable injector and the rest of the documentation to reflect the new 'step' variable.
As always, if you have any questions or issues, our support team is here to help!