All Collections
Integrations
From a Flow to another using Public API (Webhooks)
From a Flow to another using Public API (Webhooks)

This article describes how to create workflows to push and pull information from one Flow to another using Public API (Webhook)

H
Written by Helias Soares
Updated over a week ago

In this article we will send information from one Workflow and create another one carrying the same data using Webhooks and Azure Logic Apps.

The user creates a workflow where it will be sending information to another workflow. Flowingly pushes a JSON that is manipulated by the AZURE Logic App where the data is validated, parsed and sent back to Flowingly, creating a new Workflow automatically with the values entered in the form from the first Workflow.

Our example is based on an

  • 1.Webhook Workflow (Example-PUSH) (Flowingly)

  • Logic Apps (MS Azure)

  • 2.Webhook Workflow (Example-PULL) (Flowingly)

In this example, the Webhook is added in the "Webhook - Form" step in the first workflow and the form contains the fields below:

  • Short text

  • Long text

  • Option list

  • Date field



1. Create Flow Model (Web-hook / Integration)

  • Click on Library > Add Flow Model

  • Design the form that contains the data for the Web-hook.

  • Add the Web-Hook integration

  • Fill the Web-hook form with the information below

  • NOTE: The Endpoint URL will come later from the Logic App built in the Microsoft Azure (When a HTTP request is received)



2. Create Logic App (Microsoft Azure)

Click the button to know how to create an Azure Logic App:

That is the Logic App designer when finished.


2.1. When a Http request is received

  • Click on the 'When a HTTP request is received' trigger.

  • Click on 'Save'

You will notice a URL appear in your trigger and we will be using this URL into the integration on Flowingly.

This URL is where the Web-hook will send form data to when the form is submitted.

  • Go on the website https://typedwebhook.tools/

  • Copy Your unique webhook URL

  • In the Workflow with the Web-hook, paste in the Endpoint URL field and click in Test button

  • Get back to the Web-Hook site, copy the information from the JSON SCHEMA (2) in the Types tab (1)

  • And in your Logic App, paste the information in the field "Request Body JSON Schema", click on "Use sample payload to generate schema to add the data", follow the information below to get the information to paste on this field.


2.2. HTTP authorise

To authorise the integration to POST into Flowingly

  • Add a "+ New step" and fill in the fields with the information below:

  • URI : https://publicapi.flowingly.net/public/authorise

NOTE: YOUR_PASSWORD and YOUR_USERNAME (Must be a Business Admin) refer to Flowingly access


2.3. Parse JSON - authorise

  • Click on '+ New step' and add a Data operation.

  • Select the Parse JSON data operation.

  • Set the content to the body of the previous step.

    • This step will now parse the HTTP response from the previous step to be in a format acceptable by Flowingly's Public API.

  • Copy the code below.

    • This is the definition of what the response looks like from the authorise API.

{
"properties": {
"accessToken": {
"type": "string"
},
"expiresIn": {
"type": "integer"
},
"idToken": {
"type": "string"
},
"refreshToken": {},
"tokenType": {
"type": "string"
}
},
"type": "object"
}
  • Paste it in the following schema code under 'Schema'


2.4. HTTP - start flow

We are now going to tell our Logic App the necessary information to be able to start a Flowingly flow using the Public API.

Configure start flow POST request

  • Click on '+New step' and add a HTTP step.

  • URI : https://publicapi.flowingly.net/public/startflow

Add a HTTP header to contain the bearer access token from the previous step.

  • Key : Authorization

  • Value: Bearer {accessToken from the previous Parse JSON step}

  • Copy the following code (this is Flowingly's start flow API request)

{
"Name": "string",
"Subject": "string",
"ActorsToStartFlowFor": [
{
"UserEmail": "string",
"Team": "string"
}
],
"CCActors": [
{
"UserEmail": "string",
"Team": "string"
}
],
"AssignedActor": "string",
"FlowInitiator": "string"
}

Configure this further with the following information:

  • Name - Flow model name which is used to uniquely identify a flow model in Flowingly.

  • Subject - Flow instance subject which is required to start a flow.

  • ActorsToStartFlowFor - Array of either

    • UserEmail - User email to start the flow for.

    • Team- Name of the team if starting the flow for a team.

  • CCActors - (Optional) Array of either

  • UserEmail - User email to start the flow for.

  • Team- Name of the team if starting the flow for a team.

  • FlowInitiator - Email of the user who initiate the flow.

  • AssignedActor - (Optional) Email of the user to assign the first step of the flow while starting a new flow. Only required in case when the flow’s first step requires approvers to be selected.

In this example:

  • "helias@flowingly.net" is the ActorsToStartFlowFor, the AssignedActor and the FlowInitiator.

  • The flow model Name is: "2.Webhook Workflow (Example-Pull)"

  • The flow Subject is: "Integration Test"

NOTE: you may have to delete some items such as Team, if the actor to start the flow for is a person and not a team. If you delete Team, please don't forget to delete the ',' otherwise you will get an error.


2.5. Parse JSON - start flow

  • Click on '+ New step' and add a Data operation.

  • Select the Parse JSON data operation.

  • Set the content to the body of the previous step (HTTP step to start the flow).

  • Copy and paste the following schema code in the Schema.

    • This is the definition of what the response looks like from the start flow API.

{
"properties": {
"dataModel": {
"items": {
"properties": {
"flowIdentifier": {
"type": "string"
},
"stepIdentifier": {
"type": "string"
}
},
"required": [
"flowIdentifier",
"stepIdentifier"
],
"type": "object"
},
"type": "array"
},
"errorCode": {},
"errorMessage": {},
"success": {
"type": "boolean"
}
},
"type": "object"
}


2.6. For Each (Update business step fields for first step with Flowingly Public API 2)

  • Click on '+ New step' and add a For each.

  • Select "dataModel" of the output from previous step

  • Click "Add an action" and select HTTP

Configure the HTTP as below:

  • Method : POST

  • URI : https://publicapi.flowingly.net/public/flow/{flowIdentifier}/step/{stepIdentifier}

  • Headers

Key

Value

Authorization

{accessToken}

Content-Type

application/json

The end result for the top part should look like this:


2.6.1. Insert data to the Body

  • Get the step fields from Flowingly

In Flowingly start the flow and note the flow identifier and first step name. E.g. ‘FLOW-66' and ‘Webhook - Form’

Perform a HTTP POST to the authorise the Flowingly Public API to get an access token. The access token is required in order to call the GET step fields Public API.

To do this open up command prompt and type in:

curl --location --request POST "https://publicapi.flowingly.net/public/authorise?username={YourEmailAddress}&password={YourPassword}" --header "Content-Type: application/x-www-form-urlencoded" --header "Content-Length: 0"

Replace {YourEmailAddress} and {YourPassword} with your Flowingly user account credentials. The user account must be a Flowingly Business Administrator.

For example:

https://publicapi.flowingly.net/public/authorise?username=user@testflowingly.co.nz&password=testflowingly123" --header "Content-Type: application/x-www-form-urlencoded" --header "Content-Length: 0

Please note: using a tool such as Postman is a lot more use friendly than command prompt.

When you press enter command prompt should retrieve the access token. It will look something like this:

Please note: the word "test" is used here for demonstration purposes. Your access token will have a variety of letters and numbers in it.

If formatted the response looks like this:

{
"accessToken": "TheAccessTokenValue",
"refreshToken": null,
"idToken": "",
"tokenType": "Bearer",
"expiresIn": 0
}

The next step is to copy TheAccessTokenValue and add it into the HTTP header of the request to the get all step fields from the Public API.

HTTP Header

  • Key : authorization

  • Value : Bearer {TheAccessTokenValue}

Copy the access token value highlighted in blue (in between the quotation marks):

To do this, open command prompt again and type in:

curl --location --request GET "https://publicapi.flowingly.net/public/flow/{The Flow Identifier}/step/{The Step Name}" --header "authorization: Bearer {TheAccessTokenValue}" --header "Content-Length: 0"

Replace {The Flow Identifier} and {The Step Name} with the Flow identifier and step name that you retrieved in the above step.

For example:

curl --location --request GET "https://publicapi.flowingly.net/public/flow/FLOW-66/step/Webhook%20-%20Form" --header "authorization: Bearer {TheAccessTokenValue}" --header "Content-Length: 0"

Please note that if using curl commands you will need to replace spaces with %20 see above example.

Then replace {TheAccessTokenValue} with the access token that you retrieved above.

For example:

curl --location --request GET "https://publicapi.flowingly.net/public/flow/FLOW-66/step/Webhook%20-%20Form" --header "authorization: Bearer testesttestestestesttestesttestestestesttestesttestestestesttestesttestestestesttestesttestestestesttestesttestestestesttestesttestestestesttestesttestestestesttestesttestestestesttestesttestestestesttestesttestestestesttestest" --header "Content-Length: 0"

When you press Enter the Flowingly API will return all the step fields of the requested step. It's a good idea to copy the output into a text editor such as Notepad or Notepad++ . This should then look something like this and will make editing easier.

[
{
"identifier": "field98746739097",
"name": "Position Title",
"options": null,
"order": 0,
"type": "Text",
"value": "@{triggerBody()?['Step']?['Values'][1]?['FieldValue']}"
},
{
"identifier": "field98746739099",
"name": "Report to",
"options": null,
"order": 1,
"type": "Text",
"value": "@{triggerBody()?['Step']?['Values'][2]?['FieldValue']}"
},
{
"identifier": "field15019202809",
"name": "Has this role been through the Hiring Request Flow",
"options": [
{
"isSelected": false,
"key": "1",
"value": "Yes"
},
{
"isSelected": false,
"key": "2",
"value": "No"
}
],
"order": 2,
"type": "RadioButtonList",
"value": "@if(equals(triggerBody()?['Step']?['Values'][3]?['FieldValue'], 'No'),json('{key:\"2\",value:\"No\",isSelected:true}'),json('{key:\"1\",value:\"Yes\",isSelected:true}'))"
},
{
"identifier": "field98746739103",
"name": "If Yes, enter the flow number of the completed Hiring Request Flow or insert a link to it",
"options": null,
"order": 3,
"type": "TextArea",
"value": "@{triggerBody()?['Step']?['Values'][4]?['FieldValue']}"
},
{
"identifier": "field98746739105",
"name": "Preferred Publication Date",
"options": null,
"order": 4,
"type": "Date",
"value": "@{triggerBody()?['Step']?['Values'][5]?['FieldValue']}"
},
{
"identifier": "field98746739107",
"name": "Application Closing Date",
"options": null,
"order": 5,
"type": "Date",
"value": "@{triggerBody()?['Step']?['Values'][6]?['FieldValue']}"
}
]


3. Test, test and test.

  • Test starting the Workflow in which you implemented the Webhook

  • Check that after submitting the form, if a flow is automatically initialised

  • Confirm if the first step has been filled correctly with the right values

Did this answer your question?