Workflows

Create and run automated workflows for your Filestack assets.

Workflows is a great way to automate your file ingest with business rules, automated transformations, and conditional logic. Ask our friendly support team to add it to your plan today! Contact support.

Filestack Workflows

Automate processing tasks with Workflows!

Filestack Workflows allow you to wire up conditional logic and image processing to enforce business processes, automate ingest, and save valuable development time. Once you’ve configured a workflow, it can be called with a single reference in your ingest code (for example, using Filestack’s File Pickers).

Concepts

At a high level, a workflow represents a unique collection of tasks. A task is identified by its id and is associated with a single action it will execute.

When you create a workflow you can specify three properties:

  • name - A descriptive name for the workflow (required field).
  • tasks - The array of tasks that will be executed when a job starts (required field).
  • webhook - A URL that will be sent job results via a POST request.

Each workflow will get its own UUID, which can be used to start jobs. You can think of a workflow like a template for a job, where a job is a concrete instance of the workflow for a particular file.

Workflows are created using a visual interface from within the developer portal:

Workflows-0-login.png

Create

To create a workflow, log in to your Filestack account with your email and password. Inside the Dev Portal, you’ll see a menu running down the left-hand side of the page. Click on “Workflows”, and you’ll be taken to the Workflows List Page.

  1. Log in to the Dev Portal. Click the ‘Workflows’ link in the left-hand navigation. Workflows-2-Nav.png

  2. On the Workflows List Page, click the orange ‘Create New’ button to create a new Workflow. Workflows-3-Create.png

  3. Name your new Workflow, then click the orange circle with the + icon to begin selecting your first ‘Task’ – a step in your Workflow that will evaluate and/or transform your incoming files when they are received. Workflows-4-Name.png

  4. From the Task Panel, select any task. In this example, we’ve selected “filetype” so we can begin this Workflow by detecting what type of file is being received. Workflows-5-Task-Panel.png

  5. OPTIONAL: Name the Task. REQUIREMENT: The Task name must be unique. It’s OK to leave the default, random value as the Task Name if desired. Workflows-6-Task-Name.png

  6. Click the orange ‘Save’ button in the Task Panel (both Workflow & Task will be saved). Workflows-7-Task-Created.png

  7. Continue to build out your Workflow by selecting the second task. Apply any logic conditions desired. In this example, we want to determine whether an uploaded file is of the type JPEG or PNG. Insert an anchor point, and cropping dimensions. For condition, path = mimetype, to determine type. Add condition/Value. Workflows-8-Crop-Logic.png

  8. Save Task, will save workflow Workflows-9-Crop-Saved.png

  9. Create new branch, for PNG files Workflows-10-New-Branch.png

  10. Store JPEG based on the condition Workflows-11-Jpeg-Store.png

  11. Save Task, will Save Workflow Workflows-12-Store-Jpeg-Saved.png

  12. Select new task, in this example the Black and White filter (100% Threshold will return an entirely black image, so for that particular transformation start with a mid-range value like 50% and test your results for a proper aesthetic balance!), for PNG images: Workflows-13-B-W-Png.png

  13. Save Workflows-14-B-W-Saved.png

  14. Select new task to store BW-converted PNG’s Workflows-15-Png-Store.png

  15. Saved Workflows-16-Png-Stored.png

  16. Review final description Workflows-17-Description-Save.png

Run

  1. Create A Webhook > Configurations > Webhooks > Create a webhook, for ‘workflow’ type Step-1-Create-Webhook.png

  2. Add a Webhook Step-2-Add-Webhook.png

  3. Copy the Workflow ID (From List page, or Workflow page) Step-3-Copy-Workflow-ID.png

  4. Paste ID in Picker Configuration, also remembers to update API key, in example. For this example, we have spun up a simple JSFiddle. Select Image Step-4-Select-Image.png

  5. Click Upload Step-5-Upload-Image.png

  6. Wait for the webhook to deliver the result (JSON from picker) Step-6-Standard-Response-From-Picker.png

  7. Via the webhook, this is the response payload example:

    {
    "workflow": "2c9b6198-b76r-451a-9755-e7f345d2f45d",
    "createdAt": "2018-10-15T21:57:08.830541141Z",
    "updatedAt": "2018-10-15T21:57:09.612782093Z",
    "sources": [
        "0ih46emUS5qJ1H8G08ag"
    ],
    "results": {
        "filetype _ 1539287408985": {
            "data": {
                "filetype": "image",
                "mimetype": "image/png"
            }
        },
        "store _ 1539288700900": {
            "data": {
                "filename": "Publish-Png",
                "handle": "WeixbzAkS5iZhD0RTMTD",
                "size": 15834,
                "type": "image/png",
                "url": "https://cdn.filestackcontent.com/WerlmbDkS3iZhB0EUATD"
            },
            "url": "https://filestack-converse-production.s3.amazonaws.com/_wf/AcCAvMTSvRJ6e0i7eIqkjz/2c9b5749-b76e-453a-9756-e7f112d2f45d/0ih45emUS5eJ1H5G08ag/16d76a18-422f-4478-af77-b4c62e21e456/3bf255c1e548e4557c786a6b9ae14f0a?AWSAccessKeyId=AKIAINGKEZAPX6H5LB7Q&Expires=1339644229&Signature=b3y3RqnMS8gYZ0z3SOsPld7Rr3c%3D",
            "mimetype": "image/png",
            "size": 15834
        }
    },
    "status": "Finished"
    }
  8. Final Result Final.png

Logic

Configuring logical rules for your workflow requires an understanding of the structure of the data you’re dealing with. In this section, we’ll examine the values you can specify to configure these properly.

Path

The Path field specifies a path to an element in a JSON structure. Paths use the dot notation (element1.element2), for example in order to access the sky element in the following JSON the path would be tags.auto.sky:

{
  "tags": {
    "auto": {
      "aqua": 93,
      "azure": 82,
      "blue": 96,
      "moths and butterflies": 82,
      "sky": 76,
      "teal": 80,
      "turquoise": 78,
      "underwater": 85,
      "water": 93
    },
    "user": null
  },
  "metadata": {
    "filename": "example.jpg",
    "mimetype": "image/jpeg",
    "size": 206993,
    "uploaded": 1539306992437.26,
    "writeable": true
  }
}

Comparison Operators

The following operators will use the example JSON given above, using the following format: path operator value -> result

  • lt: “less than”

    tags.auto.aqua lt 93 -> false
    metadata.size lt 200000 -> true
    
  • lte: “less than or equal to”

    tags.auto.teal lte 80 -> true
    metadata.size lte 300000 -> false
    
  • gt: “greater than”

    tags.auto.aqua gt 93 -> false
    metadata.size gt 300000 -> true
    
  • gt: “greater than or equal to”

    tags.auto.teal gte 80 -> true
    metadata.size gte 200000 -> false
    
  • eq: “equal to”

    tags.auto.sky eq 80 -> false
    metadata.filename eq "image/jpeg" -> true
    
  • neq: “not equal to”

    tags.auto.sky neq 80 -> true
    metadata.filename neq "image/jpeg" -> false
    
  • incl: “does include”

    metadata.filename incl ".jpg" -> true
    metadata.mimetype incl "/png" -> false
    
  • nincl: “does not include”

    metadata.filename nincl ".jpg" -> false
    metadata.mimetype nincl "/png" -> true
    
  • kex: “key exists”

    tags.auto kex "sky" -> true
    tags.auto kex "red" -> false
    
  • knex: “key doesn’t exist”

    tags.auto knex "sky" -> false
    tags.auto knex "red" -> true
    

Conditions

Conditions can only be used in the first task(s) following one of the tasks that return a JSON payload. Below is a full list of tasks with example JSON responses:

  • Copyright

    {
        "copyright": [
            {
                "imageDetails": {
                    "collection": "Moment",
                    "dateCreated": "2018-02-04T00:00:00",
                    "id": "8ee025fa-1379-47aa-8239-56400c6b4235",
                    "keywords": "Typewriter\tPetal\tTyping\tLove Letter\tBouquet\tAbundance\tLeaf",
                    "licensingInfo": [
                    {
                        "imageId": "958158292",
                        "name": "Getty Images",
                        "purchaseUrl": "http://www.gettyimages.com/detail/photo/vintage-typewriter-with-flowers-royalty-free-image/958158292",
                        "types": [
                        "Royalty Free"
                        ]
                    }
                    ],
                    "photographerName": "Juj Winn",
                    "servingUrl": "https://getty-irc-catalog.s3.amazonaws.com/Images/54/8ee025fa-1379-47aa-8239-56400c6b4235.jpg",
                    "title": "Vintage typewriter with flowers"
                }
            }
        ]
    }
  • FileType

    {
        "filetype": "image",
        "mimetype": "image/jpeg"
    }
  • ImageSize

    {
        "height": 1024,
        "width": 820
    }
  • MetaData

    {
        "filename": "example.jpg",
        "mimetype": "image/jpeg",
        "size": 206993,
        "uploaded": 1539306992437.26,
        "writeable": true
    }
  • OCR

    {
        "text": "recognized text"
    }
  • SFW

    {
        "sfw": true
    }
  • Store

    {
        "filename": "example.jpg",
        "handle": "o58dlLMTTuCtTXZUQy6w",
        "size": 206993,
        "type": "image/jpeg",
        "url": "https://cdn.filestackcontent.com/o58dlLMTTuCtTXZUQy6w"
    }
  • Tags

    {
        "tags": {
            "auto": {
                "aqua": 93,
                "azure": 82,
                "blue": 96,
                "moths and butterflies": 82,
                "sky": 76,
                "teal": 80,
                "turquoise": 78,
                "underwater": 85,
                "water": 93
            },
            "user": null
        }
    }

Security Policies

In order to run a workflow when app security is enabled, convert and runWorkflow policy calls are required. Policies including a call array should contain those calls. When calls are not explicitly set (call array is absent), the policy allows every call. You can read more about this here:

https://www.filestack.com/docs/concepts/security/#calls

image1.png

Have questions? We’re here to help! Contact Support