Skip to main content

Build a workflow in Microsoft Foundry

Workflows are UI-based tools in Microsoft Foundry. Use them to create declarative, predefined sequences of actions that orchestrate agents and business logic in a visual builder. Workflows enable you to build intelligent automation systems that seamlessly blend AI agents with business processes in a visual manner. Traditional single-agent systems are limited in their ability to handle complex, multifaceted tasks. By orchestrating multiple agents, each with specialized skills or roles, you can create systems that are more robust, adaptive, and capable of solving real-world problems collaboratively.

Prerequisites

Decide when to use workflows

Workflows are ideal for scenarios where you need to:
  • Orchestrate multiple agents in a repeatable process.
  • Add branching logic (for example, if/else) and variable handling without writing code.
  • Create human-in-the-loop steps (for example, approvals or clarifying questions).
If you want to edit workflow YAML in Visual Studio Code or run workflows in a local playground, see:

Understand workflow patterns

Foundry provides templates for common orchestration patterns. Start with a blank workflow or select a template:
PatternDescriptionTypical use case
Human in the loopAsks the user a question and awaits user input to proceedCreating approval requests during workflow execution and waiting for human approval, or obtaining information from the user
SequentialPasses the result from one agent to the next in a defined orderStep-by-step workflows, pipelines, or multiple-stage processing
Group chatDynamically passes control between agents based on context or rulesDynamic workflows, escalation, fallback, or expert handoff scenarios
For more information, see Microsoft Agent Framework workflow orchestrations.

Create a workflow

This procedure shows how to create a sequential workflow. The same general steps apply to other workflow types.
  1. Sign in to Microsoft Foundry. Make sure the New Foundry toggle is on. These steps refer to Foundry (new).
  1. On the upper-right menu, select Build.
  2. Select Create new workflow > Sequential.
  3. Assign an agent to the agent nodes by selecting each agent node in the workflow and either selecting the desired agent or creating a new one. For more information, see Add agents later in this article.
  4. Select Save in the visualizer to save the changes.
Foundry doesn’t save workflows automatically. Select Save after every change to preserve your work.
  1. Select Run Workflow.
  2. Interact with the workflow in the chat window.
  3. Optionally, add new nodes to your workflow. The next section in this article provides information about nodes.

Verify your workflow run

After you select Run Workflow, verify that:
  • Each node completes in the visualizer.
  • You see the expected responses in the chat window.
  • Any variables you save (for example, JSON output from an agent node) contain the values you expect.

Add nodes

Nodes are the building blocks of your workflow. Each node performs a specific action in sequence. Common node types include:
  • Agent: Invoke an agent.
  • Logic: Use if/else, go to, or for each.
  • Data transformation: Set a variable or parse a value.
  • Basic chat: Send a message or ask a question to an agent.
When you select a prebuilt workflow, the builder displays the nodes in sequence. To reorder nodes, select the three dots on a node and then select move. To add nodes, select the plus (+) icon in the workspace.

Add agents

Add any Foundry agent from your project to the workflow. Agent nodes also let you create new agents with customized capabilities by configuring their model, prompt, and tools. For advanced agent creation options, go to the Foundry Agent tab in the Foundry portal.

Add an existing agent

  1. In the workflow visualizer, select the plus sign.
  2. In the pop-up dropdown list, select Invoke agent.
  3. In the Create new agent window, select existing.
  4. Enter the agent name to search for existing agents in your Foundry project.
  5. Select the desired agent to add it into your workflow.

Create a new agent

  1. In the workflow visualizer, select the plus sign.
  2. In the pop-up dropdown list, select Invoke agent.
  3. Enter an agent name and description of what the agent does.
  4. Select Add.
  5. In the Invoke an agent window, configure the agent.
  6. Select Save.

Configure an output response format

To configure an agent to return structured JSON output:
  1. In the Invoke agent configuration window, select Create a new agent.
  2. Configure the agent to send output as a JSON schema:
    1. Select Details.
    2. Select the parameter icon.
    3. For Text format, select JSON Schema.
Screenshot that shows the window for configuring a JSON schema format for output.
  1. Copy the desired JSON schema and paste it in the Add response format window. The following screenshot shows a math example. Select Save.
Screenshot that shows the addition of a response format in JSON.
Don’t include secrets (passwords, keys, tokens) in JSON schemas, prompts, or saved workflow variables.
{
  "name": "math_response",
  "schema": {
    "type": "object",
    "properties": {
      "steps": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "explanation": {
              "type": "string"
            },
            "output": {
              "type": "string"
            }
          },
          "required": [
            "explanation",
            "output"
          ],
          "additionalProperties": false
        }
      },
      "final_answer": {
        "type": "string"
      }
    },
    "additionalProperties": false,
    "required": [
      "steps",
      "final_answer"
    ]
  },
  "strict": true
}
  1. Select Action settings. Then select Save output json_object/json_schema as.
  2. Select Create new variable. Choose a variable name, and then select Done.
Screenshot that shows options for creating a new variable in a Microsoft Foundry workflow.

Configure additional features

  • YAML visualizer view: Set the YAML Visualizer View toggle to On to store the workflow as a YAML file. Edit in either the visualizer or the YAML view. Saving creates a new version with full version history. Both the visualizer and YAML are editable. Changes to the YAML file appear immediately in the visualizer.
  • Versioning: Each save creates a new, unchangeable version. To view version history or delete older versions, open the Version dropdown list to the left of the Save button.
  • Notes: Add notes to the workflow visualizer for extra context. In the upper-left corner of the visualizer, select Add note.

Create expressions with Power Fx

Power Fx is a low-code language that uses Excel-like formulas. Use Power Fx to create complex logic that lets your agents manipulate data. For example, a Power Fx formula can set a variable value, parse a string, or evaluate a condition. For more information, see the Power Fx overview and formula reference.

Use variables in a formula

To use a variable in a Power Fx formula, you must add a prefix to its name to indicate the variable’s scope:
  • For system variables, use System.
  • For local variables, use Local.
Here are the system variables:
NameDescription
ActivityInformation about the current activity
BotInformation about the agent
ConversationInformation about the current conversation
Conversation.IdUnique ID of the current conversation
Conversation.LocalTimeZoneTime zone of the user, in the IANA Time Zone Database format
Conversation.LocalTimeZoneOffsetTime offset from UTC for the current local time zone
Conversation.InTestModeBoolean flag that represents if the conversation is happening on a test canvas
ConversationIdUnique ID of the current conversation
InternalIdInternal identifier for the system
LastMessageInformation about the previous message that the user sent
LastMessage.IdID of the previous message that the user sent
LastMessage.TextPrevious message that the user sent
LastMessageIdID of the previous message that the user sent
LastMessageTextPrevious message that the user sent
RecognizerInformation about intent recognition and the triggering message
UserInformation about the user currently talking to the agent
User.LanguageUser language locale per conversation
UserLanguageUser language locale per conversation

Use literal values in a formula

In addition to using variables in a Power Fx formula, you can enter literal values. To use a literal value in a formula, you must enter it in the format that corresponds to its type. The following table lists the data types and the format of their corresponding literal values:
TypeFormat examples
String"hi", "hello world!", "copilot"
BooleanOnly true or false
Number1, 532, 5.258,-9201
Record and table[1], [45, 8, 2], ["cats", "dogs"], { id: 1 }, { message: "hello" }, { name: "John", info: { age: 25, weight: 175 } }
Date and timeTime(5,0,23), Date(2022,5,24), DateTimeValue("May 10, 2022 5:00:00 PM")
ChoiceNot supported
BlankOnly Blank()

Common Power Fx formulas

The following table lists the Power Fx formulas that you can use with each data type.

Set a variable with Power Fx

This example shows how to store and output a customer’s name in capital letters:
  1. Create a workflow and add an Ask a question node.
  2. On the pane that appears, in the Ask a question box, enter What is your name? or another message. In the Save user response as box, enter a variable name; for example, Var01. Then select Done.
Screenshot that shows the configuration of a question for sending a message.
  1. Add a Send message action. On the pane that appears, in the Message to send area, enter {Upper(Local.Var01)}. Then select Done.
Screenshot that shows the variable instantiation for the action of sending a message.
  1. Select Preview.
  2. On the preview pane, send a message to the agent to invoke the workflow.
Screenshot that shows the preview of a question for the action of sending a message.

Create if/else flows with Power Fx

This example shows how to add an if/else flow and build a condition with system variables.
  1. Create a workflow and add an Ask a question node.
  2. Select the + icon and add an if/else flow.
  3. Type System. in the Condition box to build a condition statement for each if/else branch.
A screenshot showing the system variables in the if-else condition text box.
  1. Select a Next Action for the next step in the workflow.
  2. Select Done. Select Save to save your workflow.

Troubleshooting

IssueSolution
Workflows option not visible or can’t create/edit workflowsConfirm you have the Contributor role or higher on your project. See Azure role-based access control (RBAC) in Foundry.
Changes don’t appear after editingSelect Save in the visualizer. Foundry doesn’t save changes automatically.
Workflow run produces unexpected outputVerify each agent node has an agent assigned. Check that saved outputs (JSON schema) are valid.
Power Fx formula error: “Name isn’t valid”Add the correct scope prefix. Use System. for system variables and Local. for local variables.
Power Fx formula error: “Type mismatch”Verify the variable type matches the expected input. Use conversion functions like Text() or Value() if needed.
Workflow times outBreak complex workflows into smaller segments. Check that external services respond within expected timeframes.

Clean up resources

To delete a workflow you no longer need:
  1. Open the workflow in the Foundry portal.
  2. Select the Version dropdown list to the left of the Save button.
  3. Select Delete for the version you want to remove.