Adding Workflow Branches
This tutorial explains how to design a workflow that dynamically branches based on user input or specific output values. By integrating an intent classifier, you can ensure that queries are categorized accurately and directed to the appropriate agents.
This capability enables your AI Employee to handle diverse user intents -- such as GDPR-related questions, HIPAA inquiries, or general queries -- with targeted responses.
You can also follow these same instructions to branch your workflow using a Document Categorizer agent. Apart from user queries, branching can also be done based on the value or quality of agent outputs, external data points, or LLM reasoning.
Step 1: Add a Categorizer or Intent Classifier
To enable differential responses based on user input, incorporate a branching mechanism in your workflow using a categorizer or an intent classifier. The intent classifier analyzes the entire conversation data and determines the appropriate category for the query.
Step 2: Define Categories
Set up distinct categories within the classifier. For example:
- GDPR Questions -- Include clear descriptions and example phrases such as "What is a DPO?", "Tell me about GDPR compliance requirements."
- HIPAA Questions -- For compliance-related inquiries about healthcare data protection.
- General Inquiries -- A catch-all category for queries that do not fall under specific compliance topics.
Include detailed descriptions and example phrases for each category to improve categorization accuracy.
Step 3: Integrate the Intent Classifier
Integrate the intent classifier into your workflow so that it processes the full conversation to identify the user's intent. Based on the identified category, the classifier directs the workflow to branch accordingly. For example, if a conversation is categorized as "GDPR questions," subsequent tasks such as a file search will be focused solely on GDPR data.
Step 4: Create Workflow Branches
At the point in your workflow where a branch is required:
- Click on the relevant agent block.
- Open the agent's options (via the three dots) and choose Trigger When.
- Select the classifier you want to use for branching.
- Choose the specific category that should activate the agent.
For instance, selecting "GDPR questions" means the associated agent activates only when GDPR-related inquiries are detected.
Step 5: Set Up Additional Branches
To add another branch (for example, for HIPAA inquiries):
- Add a new search agent.
- Rename this agent to HIPAA Search.
- Create a new folder for HIPAA-related files, upload the relevant documents, and rename the folder to HIPAA Files.
- Verify that the HIPAA search agent is connected to the HIPAA files.
Step 6: Connect Query Inputs and Outputs
Provide a query input for the HIPAA search agent and connect it so that the agent can respond using the search results from the HIPAA Files. Submit a query and publish this output as part of the workflow.
Step 7: Incorporate a General LLM Response Flow
For queries that do not fit the compliance categories, integrate a simple LLM response flow. This flow directly processes the query and publishes the output without additional branching.
Step 8: Finalize and Test the Workflow
- Ensure that the HIPAA branch is properly configured to trigger when the intent is identified as HIPAA.
- Confirm that the general inquiry flow is also correctly set up.
- Save your changes.
- Test your AI Employee using a sample query (for example, "What is Taylor Swift's birthday?").
Observe that the intent classifier accurately identifies the query category and routes the request to the appropriate LLM model.
By following these steps, you can create an intent-based workflow that dynamically branches based on user input. This approach ensures that each inquiry is handled by the most relevant agents, providing accurate and context-specific responses.