Exercise - Write instructions and conversation starters
In this exercise, learners will configure and customize a declarative agent using TypeSpec in Visual Studio Code, including writing effective instructions and conversation starters to enhance agent behavior and user interaction.
Task 1: Write and update instructions in the main.tsp file to define the agent's behavior
Goal: Define the behavior of your declarative agent by adding specific instructions in the main.tsp file. These instructions will guide how the agent responds to user queries.
Open Visual Studio Code and navigate to your project folder containing the
main.tspfile.Open the
main.tspfile.Locate the
@instructionsdecorator in the file. Replace its content with the following code:@instructions(""" You are a declarative agent and were created with Team Toolkit. You are an expert at creating poems. Every time a user asks a question, you **must** turn the answer into a poem. The poem **must** not use the quote markdown and use regular text. """)Save the changes to the
main.tspfile.
Task 2: Add conversation starters in the main.tsp file to guide users on how to interact with the agent
Goal: Add conversation starters to help users understand how to interact with the declarative agent effectively.
Open the
main.tspfile in Visual Studio Code.Locate the commented
@conversationStarterdecorator. Replace it with the following content:@conversationStarter(#{ title: "Getting started", text: "How can I get started with Agents Toolkit?" }) @conversationStarter(#{ title: "Getting Help", text: "How can I get help with Agents Toolkit?" })Save the changes to the
main.tspfile.
Task 3: Provision the declarative agent and test its functionality
Goal: Provision the declarative agent and test its functionality in the Microsoft 365 Copilot application.
In Visual Studio Code, ensure all changes to the
main.tspfile are saved.Open the Microsoft 365 Agents Toolkit sidebar.
In the Lifecycle pane, select Provision to deploy the agent.
Navigate to the Microsoft 365 Copilot application at https://m365.cloud.microsoft/chat.
Select your declarative agent (e.g., "My Agent") from the conversation drawer.
Test the agent by asking questions or interacting with the conversation starters.
Check your work: Provision and test the agent
To verify the agent's functionality:
- Confirm that the agent responds according to the instructions you defined in Task 1.
- Ensure the conversation starters added in Task 2 are visible and functional.
- Test various interactions to validate the agent's behavior and response accuracy.