LoopAI-103

Exercise - Create an Agent-driven Workflow

Unit 9 of 10 · Module 12: Build agent-driven workflows using Microsoft Foundry

Before you start

Short explainers for ideas this lesson builds on. Watch these first if they're new to you.

0 of 1 watched · about 2 min
Read this lesson

The plan

In this lab, you'll build a support triage workflow for Tillwise, a company that handles invoices and payments for other businesses. You'll need an Azure subscription, VS Code, Python, and Git, and it takes about thirty minutes. The workflow starts with a list of three sample tickets and handles them one at a time. A Triage agent labels each one Billing, Technical, or General, with a confidence score. Unsure tickets get a request for more details. Billing tickets are escalated to people, and a Resolution agent drafts replies for the rest.

Building it in the portal

In a new project, go to Build, then Workflows, create a blank workflow, and save it as Tillwise Customer Support Triage. Add a Set variable node that stores the three tickets as a list called SupportTickets. Add a For each node that walks through that list, saving each item as CurrentTicket. Inside the loop, invoke a new agent called Triage-Agent. Give it a JSON schema with the customer's issue, a category, and a confidence number, plus instructions that define each category. Save its text as TriageOutputText and its JSON as TriageOutputJson. Then add an If/Else node: if the confidence is above 0.6, carry on; otherwise, send a message asking for more details. On the confident path, add a second If/Else: Billing gets the message, escalate to the human support team. Everything else goes to a new Resolution-Agent, which drafts a short, friendly reply. Save, select Preview, and type a message to start it.

Running it from code

Next, clone the lab repository, open workflow.py, and put your project endpoint in the dot env file. Add the imports, connect with the project client, and name your workflow. Create a conversation and start the workflow with streaming on. When the completed event arrives, fetch the response and print each ticket's category, confidence, and reply. Then delete the conversation. Sign in with az login, run the script, and when you're finished, delete the resource group. Before the real thing, practice here: the Guided lab builds the workflow step by step, and the Coding exercise runs it from Python.

Facts from Microsoft's documentation: Build a workflow in Microsoft Foundry (Preview); Use and migrate declarative agent workflows with Microsoft Foundry Toolkit (CC BY 4.0), rewritten in Loop's own words and examples. Narration, animation, and quiz by Loop. The coding lab is based on Microsoft's lab files for the agent exercises (MicrosoftLearning/mslearn-ai-agents, MIT License; notice). Microsoft, Azure, and Microsoft Foundry are trademarks of Microsoft. Loop is independent and not affiliated with or endorsed by Microsoft.