Skip to main content

Call Workflow

The Call Workflow component can be used to send and retrieve data from a deployed Workflow Studio process. a deployed workflow.

This is very helpful to expand the capabilities of an AI agent. While agents are great at understanding natural language and can tell with large amounts of text, they are not very good at numbers. But that's the strength of Workflow Studio, where it's easy to build efficient data transformation processes and use machine learning models to make gain knowledge out of tabular data.

So having the option to call a deployed workflow with an AI agent, combines the flexibility of an Agent (including the option to make decisions on its own), with the analytic engine of Workflow Studio.

To call a workflow, it needs first to be deployed as a REST API endpoint (deploy/rest-api). If you want to send or return any data to the workflow, make sure the input and output ports are configured correctly. Additional input parameters can be configured as context variables.

Once the workflow is deployed and running, it can be selected in the Call Workflow component. The data input can be a JSON string that matches the expected table format of the workflow.

When sending a request via REST to your deployment, you can send values for your workflow variables as URL query parameters. The '|' symbol separates the key from the value and the key-value pairs are separated by commas, e.g., ' param1|value1,param2|value2' gets converted to '{"param1": "value1", "param2": "value2"}'

If used as a tool for an agent, it's helpful to specify the expected values and what the parameters do, so the agent can send the correct queries to the workflow.

Example: Cluster new data

For this example, we have created a simple workflow that takes in a data table and groups the data into a specified number of clusters. The benefit of the k-Means clustering model is, that it is an unsupervised learning algorithm, so we don't need to provide any additional training data.

clustering-workflow.png

The number of clusters we want to find is defined as a Context Variable, so its value can be changed when the workflow is called via a deployment. The description how to set up a deployment can be found here.

Next we create the agent flow. We add and configure an Agent component and use the Chat Input and Chat Output to interact with the agent in the playground.

As tools for the agent, there is an API Request component to get the data and the Call Workflow to cluster the new data.

agent-flow.png

In the description of the workflow actions, we state how the deployed workflow can be used. It describes the task it can perform and the available parameters and expected data.

tool-description.png

Now we can talk to the agent in the playground. We come directly to the point and ask it to fetch them data from a test page and then cluster it. In the execution details, we can follow the single steps:

First the agent makes the API call to get the data

api-request.png

and then the data is sent to deployed workflow with the desired number of clusters

call-workflow.png

Finally, the agent can format the results in a readable format, and we can see extra column "Cluster" that is the outcome of the k-Means algorithm.

agent-response.png