Release

Workflow Major Update: Iteration, Parameter Extractor and Publish Workflow as a Tool

Aug 1, 2023

·

May 31, 2024

Since we launched the first version of our workflow v0.6.0 a month ago, it has been popular amongst our community. Based on our observations, over 90% of users need to use workflows to ensure that the output of AI applications, so AI applications can align with real-world business scenarios. We are excited that the excellent user experience of Dify workflow helps customers build production-grade AI applications with minimal effort.

To streamline our user's experience in even more scenarios, we are excited to introduce new enhancements in v0.6.9:

  • Enables publishing Workflows as Tools;

  • New Iteration nodes for more flexible multi-step generation;

  • Parameter Extractor, for extracting structured parameters from unstructured information using natural language, enabling more natural tool invocation within workflows;

  • Enhanced capabilities of various nodes.

In this article, we will introduce these capabilities one by one, and finally, demonstrate the use of these nodes through a use case.

Publishing Workflows as Tools

You can publish a Workflow in Dify as a tool now. Any AI agent or another workflow can invoke the workflow automatically. This is suitable for scenarios where a workflow needs to be encapsulated as input. For example, wrap a workflow that provides personalized customer service recommendations for an order processing Agent to call when needed; or a workflow that automatically executes data collection, cleaning, analysis, and visualization steps, which can be used as an analysis tool by a marketing Agent.

Iteration: Loop through nodes

An iteration node executes the same steps for each item in a array until all results are output. The condition for using iteration is that the input value must be formatted as a list object. Iteration nodes allow AI workflows to handle more complex logic and have a more flexible multi-step generation. They are suitable for tasks that require repetitive steps, such as batch translating article paragraphs, processing emails, or distributing daily marketing content across different social media platforms.

Iteration nodes enable workflows to handle more complex business logic and meet richer automation needs.

Parameter Extractor: Extracting Structured Parameters from Natural Language

The principle of the parameter extractor is to use LLM inference capabilities to extract structured parameters from natural language, making it easy to use tools and make HTTP requests within a Workflow. For example, extracting an order number from a customer's natural language to locate the customer's full profile for subsequent services. Parameter extraction nodes greatly reduce the threshold for tool invocation and better use of Dify's rich toolset.

You can extract keywords from a website by using Web Crawler tool and parameter extractor. For example, we used parameter extractor to extract all the technical terms in the Wikipedia page Semiconductor.

Variable Aggregator

In this version, we have also improved the design of the variable aggregator, changing its original name "Variable Assigner" to "Variable Aggregator" and supporting more flexible variable selection. Additionally, we have enhanced the user experience by enhancing the UI for connecting other nodes to Variable Aggregator.

The variable aggregation node (formerly known as the Variable Assigner) is a key node in workflows. It integrates the output results of different branches, ensuring that no matter which branch is executed, its results can be referenced and accessed through one variable. This is very useful when there are multiple branches split by a Question Classifier, as it maps variables with the same function under different branches to a single output variable. It avoids redundant information on these nodes in nodes downstream.

Use Case: Batch Processing Emails using Workflow

Here, we will provide a simple example to illustrate how to apply the above nodes in your actual business.

Objective: We need to create a workflow that automatically processes customer support emails, categorizing them based on different email subjects/content types, and automatically executing email routing, processing, replies, and other operations.

Using Google Gmail as an example, we can call the official Gmail API to perform various operations on email content such as searching, retrieving, and modifying emails. (Note: If you want to implement your own email auto-receiving and sending in business, you need to configure the official OAuth Access Token in the Google Cloud Console first.)

The main nodes we need to use are:

Custom Tool: Use the Gmail API to search, retrieve, and modify emails, performing various operations on the mailbox.

Code Execution: Extract key information from received customer emails, such as customer identity information, email content, and email addresses.

Iteration: Use the same step logic to iterate through each email in the queue (set a value, e.g., the last 10 emails).

Variable Aggregator: Aggregate different branches after classification. For different issues, we can categorize emails into corresponding intelligent assistants. For customer service, we can classify issues into categories such as technical issues, non-technical issues, and suggestions. Intelligent assistants can then respond more effectively. For example, technical issues may require using RAG to query technical documents for user reference, non-technical issues may need human intervention, and suggestions can be forwarded to various department databases to collect corresponding requirements.

New Tool Management Page

In addition to the greatly enhanced workflow-building nodes mentioned above, we have updated the UI interface of the tools and added tool classification tags, making it more intuitive and user-friendly, helping you quickly find the tool you want among the numerous options.

So far, Dify supports 14 nodes and nearly 50 tools, with this number continuously increasing. We aim to continually enhance our excellent product experience, helping you easily build useful, production-grade AI applications in real business scenarios.

We welcome you to explore together and also invite you to:

Contribute useful tools: View the contribution guide.

Provide feedback on your real business scenario needs.

Join our Discord community and share your usage experience with us.