Imagine an agent that understands you. Your flow of work, the context you need to do your job faster. Or, just get to an answer faster. You do not need to repeat the obvious. Like the specific property site you are on when booking a room at your favourite location.
When building agents in Copilot Studio, we have an opportunity to get things right for end users. Instead of focusing on MVP’s (Minimum Viable Products), we can create MLP’ s (Minimum Lovable Products). And Power Pages is a great place to start!
So, how do we pass the content of a Power Pages site into our agent?
Let’s recap our scenario. We got a custom hotel booking agent in multiple properties’ Power Pages sites. Potential customers browse the different sites, maybe ask a few questions and eventually are ready to book. Regardless of where they are on the purchasing lifecycle, we want them to feel heard and understood.
So how about we start by letting the agent automatically recognise which specific property site they are on?
We will do so by passing the property as a parameter to the agent upon the conversation starting. In the context of a topic, this can multiply across different branches so we can pass on different parameters and have different outcomes and customer interactions.
Edit the Iframe URL of your agent in the different Power Pages sites.
In particular, we will add a parameter string at the end, which you can see as an example in the below URL in amber reading as ¤tWebsite=Paris.
The variable name is currentWebsite and the value Paris in this case is the name of the property location. In other words, we are at the Paris location of our hotel chain.
https://copilotstudio.preview.microsoft.com/environments/2c30dda2-16b3-ea9d-a2eb-2a270169d91b/bots/cr03b_harmony/webchat?__version__=2¤tWebsite=Paris
Similarly, for our other locations, e.g. Chicago, the new Iframe URL will read:
https://copilotstudio.preview.microsoft.com/environments/2c30dda2-16b3-ea9d-a2eb-2a270169d91b/bots/cr03b_harmony/webchat?__version__=2¤tWebsite=Chicago
Go to your agent’s System Topics in Copilot Studio and select the Conversation Start topic.
What you’ll see inside this topic is the personalised message you have added when your custom agent launches for the user.
We are going to go ahead and add a question after the Trigger. This can be anything as we are not planning to really use the question itself.
Instead, and stick with me her for a moment, what this will do is absorb the website parameter we have added into the agent’s Iframe URL in each Power Pages site so it can receive that context awareness and address the user accordingly.
In other words, we are inheriting that parameter through the Identify User’s entire response route and saving it as a global variable.
In this case, we will name it currentWebsite, just like in the Iframe URL we saw earlier.
Some things to note when setting up our global variable:
It is a string type
Global means any topic can access, which is useful as we will use that parameter context in a specific topic to showcase the agent’s awareness towards the user mid-conversation
Ensure to tick External sources can set values as this allows for the Iframe URL to pass on the specific parameter value from each Power Pages site
Now we are ready to use that parameter value in the context of a topic.
Just to recap our scenario, we want the agent to recognise the property website the prospect customer is on when asking questions or ready to make a booking. To showcase this, we have Power Pages sites for property locations in Paris and Chicago.
Let’s create a custom topic from blank called Property Website Specific Questions.
The Phrases trigger will be added, and we will Edit to add the following phrases. Of course, you can add whatever phrases you would like that suit your scenario.
I have questions about the hotel policies
I have questions about the hotel
If you have, at the Agent settings level, enabled Generative AI and thus generative orchestration, then you will not be able to access the Phrases trigger. Instead, you will get the Triggered by agent on trigger nodes (instead of Phrases), which allows you to add or edit the description for the topic. It means topics are selected based on the description of their purpose. This explains why you are not able to locate the Phrases trigger (No, you were never crazy or blind!).
Word to the wise, do not do it straight into a production system. This sounds obvious, but there is more than just general ALM reasons for this. When you switch to generative AI orchestration, topics with a Phrases trigger will transform into the Triggered by agent. Do not assume your phrases will automatically be translated into a fully functioning description for the agent to behave the same way. Amend and test it yourself in your dev environment to confirm the desired behaviour is there. Then, by all means, go into production. I personally noticed that switch before realizing all this behaviour and panicked (mildly) about not only losing the Phrases trigger but most importantly the topic not working anymore. Once I read the reasoning in the dedicated MS Learn article here, kindly shared by Bas Brekelmans, Copilot Studio CTO at Microsoft, it all became clear and I sorted things out pretty easily.
Otherwise, you can keep things simple with classic orchestration as highlighted in the option below.
Now that we sorted out our Phrases trigger, we are ready to Add a condition with multiple branches and showcase the different metadata passed from different websites and thus subsequent behaviour.
Full segmentation and personalisation power for you!
As explained earlier, in our scenario, we are customizing the behaviour of two different Power Pages sites.
Thus, we need two bespoke condition branches plus a catch all for anything else not falling into that category.
By default, you get one bespoke condition branch and a catch all one. Let’s go ahead and add another bespoke branch by clicking on the three-dot ellipsis.
Once we have our extra condition, we are ready to start setting each one up.
Start with one of the empty conditions by selecting Select a variable and choosing the custom global variable we created earlier for the Conversation Start topic.
Then, all we have to do is add in each condition the value we are passing on from each site (Paris and Chicago as our property locations) with equal to.
After that, we want to showcase to the user the agent’s context awareness by adding a customized question for both branches. In essence, the agent asks the user what questions they have about the property by stating the property itself.
This also is a safeguard reminder in case the user suddenly wants to switch context to another property.
So, we need to do 3 things for each condition branch.
Here is the Chicago branch example for you to explore:
Add a question acknolwedging the context and thus making the user aware.g. Of course, what is your question about the Marriot Marquis Chicago?
In Identify, select the option for User’s entire response.
In Save user response as, create a new custom variable e.g. with the name ChicagoQuestion and capture the answer as a string.
Now that the agent has saved the user’s question, it is time to decide what to do with that context further.
Of course, recognizing context in the user’s eyes is cool, but you know what else is cool?
Honing in even further on where the agent should take its knowledge source from.
To do that, we will add after the Question another step to our topic by selecting Advanced and then Generative answers.
We will add in the Input section the users’ question we saved earlier as a custom variable e.g. ChicagoQuestion for the Chicago branch.
Then, we can select Edit to start customizing the agent’s knowledge sources used in the branch.
Once we click on Edit, the below customization pane appears.
To recap, the scenario is to tailor the knowledge source based on the property context/ location and only allow answers based on specific related files.
To do that, we first toggle the Search only selected sources options. Once we do that, the full list of knowledge sources appears.
We can tick, as per example on the right the ones you will restrict answers to.
Some side notes:
We will be able to see all the knowledge sources you have set up. From public websites, to document uploads and Dataverse collections (and anything else), it will all be there.
We also need to disable the Classic data toggle for Allow the AI to use its own general knowledge (preview) option for the same reason.
N.B.:
We only want to retrieve existing knowledge in the classic manner.
Repeat the same process for all bespoke branches based on the different parameter values.
For the catch-all remaining branch, we can just respond through the agent with a bespoke clarification message to understand which specific property the user is inquiring about at the time.
This allows the users to specify it when the agent has not retrieved the property context in any way (e.g. located elsewhere/ testing mode etc.).
Enjoy and let me know what you think. Even better, try extending this with other kinds of parameters.
Check Angeliki Patsiavou’s original post https://www.empoweredhumans.net/post/context-aware-agents on www.empoweredhumans.net which was published 2025-01-31 23:18:00