Useful Ziflow webhooks and JsonPath examples

Mike Salyga
Mike Salyga
  • Updated

Many Ziflow customers use Ziflow API & webhooks to integrate with internal or third-party services. This document provides common JsonPath variables and webhooks.

 

  1. Webhooks

  2. JsonPath variables

  3. Using JSONata regular expressions

 

Webhooks

  • Endpoint URL: https://api.ziflow.io/v1/folders

    Code:

     { "name": "New Folder Name" } 

    Notes: This creates a new folder based on an action. Variables can be used to name the folder according to a custom property.

  • Endpoint URL: https://api.ziflow.io/v1/proofs/#{$.proof.id}#

    Code:

    { "minor_version": false or true }

    Notes: To turn on, set the value to true. To turn it off, set the value to false.

  • Endpoint URL: https://api.ziflow.io/v1/proofs/#{$.proof.id}#

    Code:

    { "folder_id": "PLACE FOLDER ID HERE" }

    Notes: To find the folder ID, open the folder in webapp and copy the ID from the end of the URL. e.g. https://demo.ziflow.io/#/folders/50826969-889a-49a6-a8fa-ea8b8dc56cee

  • Endpoint URL: https://api.ziflow.io/v1/proofs/#{$.proof.id}#

    Code:

    #{$.{"stages":$append($spread($.proof.stages)[id][[0..1-2]],$append($spread($.proof.stages)[id][[1..100]],$.proof.stages[1-1].{"id":id,"deadline":"${$.proof.custom_properties.[?(@.id=='PLACE
        PROPERTY GROUP ID HERE')].properties[?(@.id=='PLACE PROPERTY ID HERE')].value}"&"T12:00:00.000Z"}[]))}}#

    Notes: This automatically pulls the requested due date property from an intake form and sets that date as the deadline within the assigned workflow template.

  • Endpoint URL: https://api.ziflow.io/v1/proofs/#{$.proof.versions[-2].version_id}#

    Code:

    { "allow_source_download": false }

    Notes: Use it to turn off the download original file setting for a previous proof version.

  • Endpoint URL: https://api.ziflow.io/v1/proofs/#{$.proof.id}#

    Code:

    { "brief": { "text": "Put Brief Verbiage Here"} }

    Notes: With this webhook, you can update a brief section on a proof.

  • Endpoint URL: https://api.ziflow.io/v1/proofs/#{$.zibot[0].data.id}#/stages/#{$.zibot[0].data.stages[0].id}#/reviewers

    Code:

     [ { "email": "#{$.form.submitter_email}#", "view":
          true, "comment": true, "decision": false, "manage": false, "share": true
          } ] 

    Notes: Edit “Proof ID” and “Stage ID” as needed; this refers to the first stage of the proof created by a “Create Proof” zibot, with that zibot being the first zibot in a flow.

 

JsonPath variables

  • JSONata Variable:

     #{$.proof.id}#

    Notes: Use this if you want to reference a proof ID.

  • JSONata Variable:

     #{$.proof.versions[-2].version_id}#

    Notes: You can use this in a webhook to change the previous version after a new version is added, for example, to turn off download of original file for the previous version.

  • JSONata Variable:

    #{$.proof.custom_properties[name="Property
          Group Name"].properties[name="Property Name"].value}#

    Notes: This can be used when referencing a text property in either webhook bodies or paths. When using the second version, ensure you add `#` on either side, denoting the use of JSONata.

  • JSONata Variable:

    #{$.proof.custom_properties[name="Property
          Group Name"].properties[name="Property Name"].value_enum[*].value}#

    Notes: Used for single select lists in webhook bodies or paths. To display values, use `.value_enum[0].value`. Multi-select lists require custom handling.

  • JSONata Variable:

     #{$exists($.proof.custom_properties[name="group
        name"].properties[name="custom property name"].value_enum[0].value)}# 

    Notes: Use this in paths to check for the existence of a value.

  • JSONata Variable:

     #{$.form.custom_properties[name="Property
          Name Here"].value}#

    Notes: This is used when referencing custom properties on an intake form.

  • JSONata Variable:

     #{$.form.custom_properties[name="Property
          Name Here"].value_enum[0].value}#

    Notes: Used for single select lists or radio buttons on intake forms.

  • JSONata Variable:

     #{$exists($.form.custom_properties[name="property
          name"].value_enum[*].value)}#

    Notes: Use this in a path to verify the existence of a value.

  • JSONata Variable:

     #{$.form.submitter_email}# 

    Notes: Use this to reference the email of the form submitter.

  • JSONata Variable:

    #{$.stage.name}#

    Notes: Used to reference the current stage name or push it to another tool.

  • JSONata Variable:

    #{$.reviewer.email}#

    Notes: Use this to reference a reviewer’s email.

  • JSONata Variable:

    #{$.zibot[0].data.id}#

    Notes: Used to reference the ID of a task/card/issue created in a previous step of a connect flow.

  • JSONata Variable:

    #{$.zibot[0].data.id}#

    Notes: Use this to reference proofs and stages created via an intake form flow.

  • JSONata Variable:

    #{$exists($.trigger.proofUpdateInfo.fields.new_value[name="Asana"].
          properties[name="Asana Task ID"].name)}#

    Notes: Use this to limit a flow to trigger only for a specific custom property update.

  • JSONata Variable:

    #{$fromMillis($.trigger.proofSerializedModel.calculatedProofStatusDate)}#

    Notes: Use this token to populate a custom property with the approval date.

  • JSONata Variable:

    #{$.comment.comment}#

    Notes: Use this to add comments as a subtask to a PM tool task.

  • JSONata Variable:

    {$.proof.public_link}#{$.comment.id}#

    Notes: This will open the proof with the comment highlighted.

  • JSONata Variable:

    #{$.comment.labels.label}#

    Notes: Displays the label of a comment.

  • JSONata Variable:

    #{$.trigger.proofSerializedModels.formTextToReview}#

    Notes: Sends text from an intake form to a PM tool column.

  • JSONata Variable:

    #{$.proof.thumbnail_link}#

    Notes: Sends a thumbnail preview to a PM tool.

  • JSONata Variable:

    #{$.proof.workflow_template.name}#

    Notes: Reference a workflow template name.

  • JSONata Variable:

    #{$.proof.folder.name}#

    Notes: Reference a folder name.

  • JSONata Variable:

    #{$.proof.stages[$.name="XYZ"].status.status}#

    Notes: Trigger a Zibot action based on a stage status.

  • JSONata Variable:

    #{$.proof.source_files.name}#

    Notes: Reference a proof source file name.

 

Using regex in JSONata

You can use regular expressions when building flows/paths using JSONata (query and transformation language) to work with JSON data. Many regex functions can help you with formatting data according to your needs.

Please refer to the JSONata docs for more information about using regular expressions.

Testing your regex expressions combined with Ziflow data can be done using the JSONata Exerciser. You can send a built token #{$}# to the Webhook.site to view request details. To achieve this, add a Webhook Zibot to your Ziflow flow with a POST request to the Webhook site using a created regex token.

Ziflow does not manage or support external services like Webhook.site and https://try.jsonata.org/. We recommend caution when using these third-party tools in your workflows, as Ziflow cannot take responsibility for their performance or security.

 

JSONata expressions with regex

Comment text, including the email address of the mentioned reviewer.
#{$replace($.comment.comment, /\$\{reviewer[^\}]+\}/, $.proof.stages.members[id=$match($$.comment.comment, /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/).groups[0]].email)}#

 

 

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.