Flow Scripts

Flow Scripts contain your automation logic. Within them, you define what you want to automate and how to do so. 

Depending on the complexity of your automated process, it can consists of one or many Flow Scripts. Flow Scripts can start other Flow Scripts and pass inputs and outputs between each other. 

Tipp: small Flow Scripts with well-defined scope can be re-used by many automated processes. We recommend breaking automated processes down into several Flow Scripts which automate specific tasks. In addition to simpler re-use, it also makes it easier to maintain and extend your automated processes. 

Working with Flow Scripts

The Flows section shows all flow scripts that you currently have available on the Cloudomation platform. Here, you can manually create new Flow Scriptsrun Flow Scriptsedit existing Flow Scripts and delete Flow Scripts

Once you press the „new“ button on the top left of the Flows section view, a flow script editor will open. The editor will already contain a few sample code lines. Replace the # TODO: write your automation line with your automation. 

The flow script editor provided in the Cloudomation user interface is mainly intended for writing small flow scripts, or doing small edits on existing flow scripts. For larger projects, it is recommended to use an editor of your choice and synchronise your flow scripts to the Cloudomation platform via git (or any other remotely accessible store which you can access via a flow script) or to use a helper script to run your local flow scripts remotely.

Old versions of Flow Scripts will not be saved by Cloudomation, so be sure to have a backup of your Flow Scripts if you make significant changes. Or even better: use a version control system for your Flow Scripts.

A newly created flow will automatically be assigned an ID and a name. The ID is a random number that uniquely identifies the flow which can not be edited. The name is „new flow“ plus a time stamp in ISO 8601 format. You can edit the name of a flow in the flow details view.

Clicking the run button on top of the flow view will execute the flow and automatically redirect you to the Executions view. Read more about executing Flow Scripts in the documentation on Development and Productive Mode

Interaction between Flow Scripts

Flow Scripts can be called from another flow:

def handler(system, this):
    my_flow = this.flow('my_other_flow_name')
    return this.success('all done')

A Flow Script calling another Flow Script establishes a parent-child relationship between the two Flow Scripts:

If a child Flow Script fails, it will raise an exception, causing the parent Flow Script to fail as well. To avoid the parent failing, you can catch the exception: 

def handler(system, this):
    try:
        my_flow = this.flow('my_other_flow_name')
    except Exception:
        this.log('my flow failed')
    else:
        this.log('my flow succeeded')
    return this.success('all done') 

Interaction with other services: Tasks

In order to connect with services outside of the Cloudomation plattform, you can call Tasks from your Flow Script. 

Calling a Task from your Flow Script is simple: 

def handler(system, this):
    my_task = this.task(
        'GIT',
        command='get',
        url='https://github.com/starflows/library.git'
    )
    return this.success('all done')

Access the „output_value“ field of a Task to get the outputs of the task: output_dict = my_task.get('output_value').

Read the Task documentation to learn more about available Tasks. 

Read the Tutorial to learn more about getting started with writing your own Flow Scripts.

To learn more about how other systems can trigger Flow Scripts in Cloudomation, refer to the webhooks documentation.