How to trigger Flow Studio via API

Scope

This section will explain how a Flow can be triggered via API using the webhook trigger component. This will help users to cover use cases around triggering omnichannel communications via a single API, Flexible payload configuration based on Flow variables.

Also, this capability will allow integrating Flow Studio with Unifonic Chatbot by using the Service call widget on Unifonic Chatobt and then using the Webhook trigger API to execute the flow required.

Steps

  1. Access to our Unifonic platform via https://cloud.unifonic.com/

  2. Once you are logged in to the platform, go to Flow Studio product from the top left side of the menu navigation, expand the menu, and go to my flows section.

1911
  1. Select any flow you have previously created with Webhook as a trigger or create one from scratch and select Webhook as a trigger while configuring it.
1911

📘

Selecting a Flow

Note that to select a flow from the flow list just click on the edit icon on the actions column of the flows table.

  1. Once you are on the Flow builder page, double-check what is the status of the flow if it is on the draft status please make sure you publish the flow by clicking on the publish button on the top right side.
1912
  1. Once the flow is published, click on the Webhook trigger icon, and the Parameters tab will be visible on the right side of the screen as shown below.
1914
  1. Once the parameters tab is displayed you will have access to 2 APIs. the first one is the POST request that will show you the URL and a cURL example of how to trigger a flow. So once you click the link “SHOW POST REQUEST”, it will display a pop-up with all the details below.
1907

📘

NOTE:

This URL is unique per Flow. The uniqueness parameter in the URL is the Flow Id which is the string shown right after flow in the path For example https://flow-api.cloud.unifonic.com/api/v1/execution/flow/**dc000000-190c-4f2c-8176-dbcb4806091c**/execute. So every time you want to execute a different flow you just need to change the flow Id that will appear in the same section for every flow and replace the Flow ID.

  1. Now to get the API Key of the previous API you just need to click the “SHOW AUTH REGENERATION POST REQUEST” link and it will display a pop-up with the Regeneration token API that you can use to generate your API access token. There is also a cURL example on how to do the query and you just need to replace the refresh token value in the body with the one highlighted in the pop-up.
1916
  1. Once you send the POST request to that API in the response you will get the Access token value that should be used as an API key for the Flow execution endpoint.

📘

Response message definition

Once you execute the flow Execution API. This API will return a parameter called a message. This is the execution Id that later on you can use in the Executions section to track all the journey and the steps executed in the Flow.