Skip to main content

Stages

A stage is a step in your Workflow. It is a Python file that will be executed when your Workflow reaches that point in its run.

Depending on the trigger you need for that stage, you can create it as a Form, Hook, Job or Script.

  • Forms: manually triggered stages with a friendly UI. Add them into a Workflow whenever user input is needed in a process.

  • Jobs: stages scheduled to be executed periodically.

  • Hooks: stages triggered by authorized HTTP requests sent to their endpoint.

  • Scripts: a plain Python script, whose trigger is simply the completion of the previous step in the Workflow.

Let's check the Apply to Dunder Mifflin stage. Click on the Stages tab in the sidebar.

Go to Stages Page

And select the Apply to Dunder Mifflin stage.

Stages Page

Form Editor

The Apply to Dunder Mifflin stage is a Form. The Editor shows the Form's code to the left and a preview of the UI to the right.

Form Editor

By executing the form in the preview, you can see how the python code is shown to the user. The code is executed procedurely until it reaches an Abstra widget.

Form Preview

info

Forms executed in preview will not create new threads unless you toggle the Workflow OFF switch at the top of the preview.

With this knowledge, you can easily update the code to your needs. For example, you can add a display widget before the best_movie input to show a welcome message to the user. By saving and executing the form you will see the new display after the start message.

af.display("Welcome to Dunder Mifflin!")

New widget

You can check the complete list of widgets here.

The input widgets will get an input from the user, and you can assign it to a variable as we did with the best_movie variable.

best_movie = af.read_multiple_choice("What is the best movie ever made?", options=[
"Die Hard",
"Devil Wears Prada",
"Weekend at Bernie's",
"American Psycho",
"Legally Blond",
"Wall-E",
"Threat Level: Midnight"
])

The code of this form is just getting inputs from the user. In the other script, Application Review, that you can access by getting back to the Stages page by clicking on the left arrow in the top left corner and selecting the Application Review stage, we process this data, processing it and sending an email to the user with the application status.

To share variables between stages, you can use the set_data function from the abstra.workflows module. To retrieve the data, you can use the get_data function from the same module. More info about this in the SDK Reference/Workflows/Get Data.

In the Application Review stage, we are retrieving the user inputs, adding to the variable reasons why the user wasn't hired if the answers were not certain values, and sending the approval/rejection email. Once this stage is a script, instead of a form, it doesn't require user interaction and it doesn't have a preview.

Once it depends on certain data to be present on the thread, you can simulate thread data by clicking the Thread collapse button and filling the data you want to test.

Thread Data

And that's the basics about stages! You can get more info about the different types of stages in the docs of each type: Forms, Jobs and Hooks.