Hello! Welcome back to your course on advanced Power Platform development.
In our last lesson, we laid the groundwork for building conversational AI by learning how to design chatbot topics with triggers, conditions, and basic conversation nodes. We saw how variables are used to store user responses, forming the basis of a chatbot's short-term memory.
Today, we're going to build on that foundation to significantly enhance our chatbot's intelligence. Our learning outcome is to manage conversation state using variables and extract user information with entities. This involves two key skills:
- Advanced Variable Management: We'll treat topics like modular code, passing data between them to create more sophisticated and reusable conversation flows.
- Entity Extraction: We'll learn how to make our chatbot understand the meaning behind a user's words, extracting structured data like dates, locations, or custom product codes from free-form text.
This lesson moves you from creating simple, linear bots to designing dynamic, context-aware conversational agents—a critical skill for the PL-400 exam and for building powerful real-world copilots.
1. Advanced Variable Management: Building Modular Conversations
In programming, you don't write all your code in a single, monolithic function. You create smaller, reusable functions that call each other and pass parameters. The same principle applies to Copilot Studio. Large topics can become difficult to manage. The best practice is to break them down into smaller, focused topics that can be called from other topics. This requires a robust way to manage and pass variables to maintain the conversational state.
To understand these concepts, we'll refer to the official Microsoft documentation, which provides clear, step-by-step examples.
Work with variables - Microsoft Copilot Studio
This Microsoft Learn article, 'Work with variables', is the definitive guide to this topic. We will use it to explore how to pass data between topics, much like passing arguments to and from a function in C#.
First, read the introduction to re-familiarize yourself with what variables are. Then, read the sections 'Variables panel', 'Pass variables between topics', and 'Return values to original topics'. Pay close attention to the example with the 'Greeting' and 'Talk to Customer' topics. This is a practical demonstration of the concepts we're discussing.
Let's break down the key patterns from that reading.
Passing Variables to Another Topic
This is analogous to calling a function with input parameters. It's essential for preventing your chatbot from asking for information it already has.
Scenario: A Greeting topic asks for the user's name. It then redirects to a Talk to Customer topic. Instead of asking for the name again, the Talk to Customer topic should use the name already collected.
How it works:
-
In the Destination Topic (
Talk to Customer):- You have a
Questionnode that asks for the user's name and saves it to a variable (e.g.,customerName). - You open the Variable properties for
customerNameand enable the setting Receive values from other topics. This "opens the door" for this variable to be populated from an external source.
- You have a
-
In the Source Topic (
Greeting):- After collecting the name into its own variable (e.g.,
customerNameFromGreeting), you add aRedirectnode pointing to theTalk to Customertopic. - In the
Redirectnode, you add an input mapping. You map the destination variable (customerName) to your source variable (customerNameFromGreeting).
- After collecting the name into its own variable (e.g.,
When the conversation flows, the Greeting topic passes the value of customerNameFromGreeting into the customerName variable in the Talk to Customer topic. The copilot sees that the customerName variable is already filled and intelligently skips the question that asks for it.
Returning Values from a Topic
This pattern is like a function that has a return value. A topic can be designed specifically to find a piece of information and then give it back to the topic that called it.
Scenario: The Talk to Customer topic now also asks for the user's city. The original Greeting topic needs this information to finish the conversation.
How it works:
-
In the "Called" Topic (
Talk to Customer):- You add a
Questionnode that asks for the city and saves it to a variable (e.g.,customerCity). - In the Variable properties for
customerCity, you enable Return values to original topics.
- You add a
-
In the "Calling" Topic (
Greeting):- The
Redirectnode that callsTalk to Customerwill now automatically show an output variable. - You can store this returned value in a new variable within the
Greetingtopic and use it in subsequent messages.
- The
Mastering these two patterns is fundamental to creating scalable and maintainable copilots.
2. Extracting Structured Data with Entities
So far, we've mostly stored the user's entire response in a text variable. But what if a user says, "I'd like to book a flight to Paris for next Tuesday"? That single sentence contains three critical pieces of information:
- Intent: Book a flight
- Destination: Paris (a City)
- Date: next Tuesday (a Date and Time)
Entities are the mechanism Copilot Studio uses to identify and extract these specific pieces of information from a user's input. Think of an entity as a data type that helps the NLU model recognize real-world objects.
Use entities and slot filling in agents - Microsoft Copilot ...
This documentation page, 'Use entities and slot filling in agents', provides a thorough explanation of what entities are, the different types available, and how to use them in a conversation.
Read the introduction, the 'Prebuilt entities' section, and the 'Use entities in a conversation' section. This will give you a solid understanding of how to apply entities in a Question node.
When you create a Question node, you'll see an Identify field. This is where you specify the entity. Instead of leaving it as "User's entire response", you can choose a specific entity.

Slot Filling: The Key to Natural Conversation
A powerful feature related to entities is slot filling. If the user provides information that matches an entity before the copilot asks for it, the copilot intelligently fills the corresponding variable (the "slot") and skips the question.
For example, if the first thing a user types is "I need to reset my password for the CRM system", and your topic has a question "Which system do you need help with?", the copilot will recognize "CRM", fill the variable, and skip the question, making the interaction much faster and more natural.
Types of Entities
Pre-built Entities
Copilot Studio includes a rich set of pre-built entities for common data types like Age, City, Color, Date and time, Email, Number, URL, and more. You should always use these when they fit your needs.
Custom Entities
When pre-built entities are not enough, you can create your own. This is where your developer skills become particularly valuable.
Use entities and slot filling in agents - Microsoft Copilot ...
Let's return to the documentation to learn about creating custom entities for your specific business needs.
Read the 'Custom entities' section. Focus on the two main types: 'Closed list' and 'Regular expression (regex)'.
-
Closed List Entities: Use these for a known, finite set of items. For example, product categories (
Hiking,Camping,Climbing) or departments (HR,IT,Finance). A key feature here is synonyms. You can define that "trekking" and "mountaineering" are synonyms for "hiking", so the copilot will understand them correctly. -
Regular Expression (Regex) Entities: This is a powerful tool for any developer. You can define a pattern to capture consistently formatted data. This is perfect for things like:
- Employee IDs (
EMP-\d{5}) - Order Numbers (
ORD-\d{4}-\d{4}) - License Plates
- Case Numbers (
CASE-[A-Z]{3}-\d{6})
- Employee IDs (
Your background in programming and scripting makes you well-equipped to leverage Regex entities to handle complex, domain-specific data extraction.
Test your understanding!
For each of the following scenarios, decide which entity type is the most appropriate choice: Pre-built, Custom (Closed List), or Custom (Regex).
- You need to capture the user's desired appointment date.
- You need to capture the specific model of a company's laptop: "Latitude 7420", "Surface Pro 9", or "MacBook Pro 16".
- You need to capture a shipment tracking number that always follows the format
TN-followed by 8 digits (e.g.,TN-12345678). - You need to ask for the user's phone number.
Show answer
- Pre-built (
Date and time): This entity is specifically designed to understand various date and time formats like "tomorrow", "next Tuesday at 3pm", or "01/01/2025". - Custom (Closed List): You have a finite, specific list of product models. You could also add synonyms if needed (e.g., "Surface" could be a synonym for "Surface Pro 9").
- Custom (Regex): This is a perfect use case for a regular expression. The pattern would be something like
TN-\d{8}. - Pre-built (
Phone number): The pre-built entity for phone numbers is capable of recognizing various common formats.
Conclusion
In this lesson, you've elevated your copilot development skills by moving beyond simple conversation flows. You now have the tools to manage a conversation's state effectively and to extract precise, structured data from user input.
Key Takeaways:
- Variable Passing: You can create modular, reusable topics by passing variables to them (like function parameters) and returning variables from them (like return values).
- Entities are Data Types: Entities are the key to unlocking Natural Language Understanding, allowing your copilot to identify specific information within a user's message.
- Pre-built vs. Custom: Always leverage pre-built entities for common data types. For domain-specific needs, create Closed List entities for finite sets or Regex entities for pattern-based data.
- Slot Filling: This intelligent feature makes conversations more efficient by capturing information proactively and skipping unnecessary questions.
What's Next?
Now that we can capture structured data from the user (like an email address or a product ID) and store it in variables, the next logical step is to perform actions with that data. In our next lesson, we will learn how to integrate Copilot Studio with Power Automate flows to perform backend actions. This will bridge the gap between conversation and execution, allowing your copilot to create records in Dataverse, send emails, start approval processes, and interact with hundreds of other systems.