AI-3016 Learning Portal
Objective 3.1 35 minhigh priorityprompt-flowchat-flowchat-historyflow-inputsflow-outputs

3.1 — Build Chat Flows with Prompt Flow

Create a Prompt Flow chat flow, configure required chat_history and chat_input fields, define flow inputs/outputs, and run end-to-end interactive testing.

Concept — What & Why

Prompt Flow is a development tool inside Azure AI Foundry (classic) that streamlines the full lifecycle of LLM-powered applications — from prototyping to production. It lets you orchestrate LLM nodes, Python nodes, and Prompt template nodes into a visual, executable graph. Each flow is stored as a folder containing a flow.dag.yaml file alongside source code files, making flows portable and version-controllable.

Prompt Flow supports three major flow types:

Flow TypePurposeKey Characteristic
Standard flowGeneral-purpose task automationFlexible inputs/outputs; no built-in chat history
Chat FlowA Prompt Flow type purpose-built for multi-turn conversational applications. Requires two reserved inputs — chat_input and chat_history — and exposes a Chat box UI for interactive testing.Conversational applications / chatbotsRequires chat_input and chat_history; exposes Chat box for testing
Evaluation flowAssessing quality of other flowsTakes another flow's outputs and scores them; used in batch evaluation

Each flow is stored as a folder containing a flow.dag.yamlThe YAML definition file that describes all nodes, inputs, outputs, and connections of a Prompt Flow. It is the portable, version-controllable source of truth for the flow graph. file alongside source code files, making flows portable and version-controllable.

Chat Flow Fundamentals

A chat flow has three elements unique to this type:

  • Chat input — the text message a user types in the chat box; you designate one flow input as chat input
  • chat_historyA reserved list-typed input in a Prompt Flow chat flow that is automatically managed by the portal during interactive chat box sessions. It stores all previous turns as a JSON list of input/output pairs — you cannot manually set it during chat box testing. — the reserved input managed automatically by the portal; stores all previous user inputs and assistant outputs as a JSON list
  • Chat output — the AI-generated reply; you designate one flow output as the chat output

Both chat_history and chat_input are required in a chat flow. A chat flow can have additional non-chat inputs (e.g., a system_prompt string), but the two reserved fields must always be present.

Flow Inputs and Outputs

Flow inputs define the data contract for the entire flow. Each input has a name, a type, and a default test value. Inside any node, reference a flow input with ${inputs.<input_name>}.

Flow outputs define what the flow returns after execution. Bind each output to a specific node's output using ${<node_name>.output} or ${<node_name>.output.<field_name>}.

Deep Dive — How It Works

Chat History Structure

The chat_history input is automatically structured as a list of turn objects:

[
  {
    "inputs": { "question": "What is Azure AI Foundry?" },
    "outputs": { "answer": "Azure AI Foundry is a unified platform..." }
  }
]

To incorporate conversation history into your LLM prompt, use a Jinja for-loop inside the prompt template:

{% for item in chat_history %}
user:
{{item.inputs.question}}
assistant:
{{item.outputs.answer}}
{% endfor %}
user:
{{question}}

This is the standard pattern for building context-aware, multi-turn prompts in Prompt Flow.

Running and Testing Flows

Test MethodHow to TriggerBest Used For
Single-node runClick the Run icon on the node cardDebugging one node in isolation
Whole-flow runClick Run top-rightEnd-to-end validation
Chat boxClick Chat buttonInteractive multi-turn testing
Batch runSubmit via Runs pageEvaluating across a dataset

After a whole-flow run, select View outputs to inspect the Outputs panel. Switch to the Trace tab for a span tree showing per-node duration and token cost.

Conditional Control — Activate Config

Any node can declare an Activate ConfigA conditional control on any Prompt Flow node that declares a "when" condition. If the condition evaluates to false, the node is marked Bypassed (not Failed) and skipped — enabling routing patterns within a single flow. — a "when" condition that determines whether the node runs. Example: ${inputs.mode} == "search". If the condition is not met, the node is Bypassed (not Failed). This enables routing patterns such as deciding whether to call a retrieval node based on the type of user question.

Node StatusMeaning
SucceededNode ran and returned a result
BypassedActivate config condition was false; node was intentionally skipped
FailedNode ran but encountered a runtime error
Hands-On Lab

Goal: Create a chat flow, define its inputs/outputs, and run it end-to-end in the Azure AI Foundry portal.

Step 1 — Open Prompt Flow. Sign in to ai.azure.com. Ensure the New Foundry toggle is off (classic portal). Select your project. From the left pane, select Prompt flow, then select + Create.

Step 2 — Create a Chat flow. On the "Create a new flow" page, locate the Chat flow tile and select Create. Enter a folder name (for example, my-chat-flow) and select Create. The authoring page opens with a sample chat flow template.

Step 3 — Start a compute session. Select Start compute session in the top banner. Wait for the session status to show Running before making changes. Without an active compute session, nodes cannot execute.

Step 4 — Define flow inputs. In the Inputs section, confirm that chat_history (type: list) and question (type: string, marked as Chat input) are present. To add a new input — for example, a system_prompt string — select + Add input, enter the name and type, and set a default test value.

Step 5 — Configure flow outputs. In the Outputs section, confirm the chat output field is bound to your LLM node's output using the expression ${<llm_node_name>.output}. To bind a different node output, type the reference expression directly into the value field or use the dropdown selector.

Step 6 — Run the flow end-to-end. Select the Chat button at the top of the authoring page to open the Chat box. Type a test question and press Enter. Observe the assistant response in the conversation pane.

Step 7 — Inspect outputs and trace. Select View outputs in the top banner. On the Outputs tab, review inputs, outputs, and run metadata. Switch to the Trace tab to see the execution span tree with per-node duration and token consumption. Expand individual nodes to see their inputs/outputs for debugging.

Exam Angle — What AI-3016 Tests

AI-3016 Assessment Focus

Chat flow required inputs, the chat_history management model, and Bypassed vs. Failed node status are the most frequently tested concepts. Also expect input/output reference syntax questions.

Exam Trap

"You can edit the graph view directly." The graph view is read-only and for visualization only. All editing is done in the flatten (text) view or Raw file mode.

Exam Trap

"chat_history is optional in a chat flow." Both chat_history and chat_input are required in a chat flow. Omitting either will cause the flow to fail validation.

Exam Trap

"You can manually set chat_history in the Inputs section during interactive chat testing." The portal manages chat_history automatically during chat box sessions. For batch runs, you must include chat history in your dataset or pass an empty list [].

Exam Trap

"A standard flow is the correct type for building a multi-turn chatbot." A chat flow is the purpose-built type for chatbots. Standard flows lack built-in chat history management and the Chat box testing UI.

Exam Trap

"Flow outputs reference node outputs using $ syntax." Flow outputs use ${<node_name>.output} syntax. The ${inputs.*} syntax is for referencing flow-level inputs inside node configurations — not for outputs.

Exam Trap

"Bypassed node status means the node encountered an error." Bypassed means the activate config condition was not met and the node was intentionally skipped. A node that errors shows Failed status.

Must Memorize

Reference syntax summary: flow input inside a node → ${inputs.name} | node output as flow output → ${node_name.output} | nested field → ${node_name.output.field}

Question — click to flip

Q: Which two inputs are REQUIRED in a Prompt Flow chat flow?

Question — click to flip

Q: How do you reference a flow-level input named 'user_query' inside a node's prompt template?

Question — click to flip

Q: A node's status shows 'Bypassed' after a flow run. What does this indicate?

Question — click to flip

Q: During interactive chat box testing, how is chat_history populated?

Question — click to flip

Q: How do you define what a chat flow returns to the caller?

Question — click to flip

Q: What file is the portable source-of-truth definition for a Prompt Flow graph?

Sources & Further Reading