Exercise - Write instructions and conversation starters

Completed

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.

  1. Open Visual Studio Code and navigate to your project folder containing the main.tsp file.

  2. Open the main.tsp file.

  3. Locate the @instructions decorator 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.
    """)
    
  4. Save the changes to the main.tsp file.

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.

  1. Open the main.tsp file in Visual Studio Code.

  2. Locate the commented @conversationStarter decorator. 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?" 
    })
    
  3. Save the changes to the main.tsp file.

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.

  1. In Visual Studio Code, ensure all changes to the main.tsp file are saved.

  2. Open the Microsoft 365 Agents Toolkit sidebar.

  3. In the Lifecycle pane, select Provision to deploy the agent.

    A screenshot of the Provision option in the Lifecycle pane of the Microsoft 365 Agents Toolkit.

  4. Navigate to the Microsoft 365 Copilot application at https://m365.cloud.microsoft/chat.

  5. Select your declarative agent (e.g., "My Agent") from the conversation drawer.

  6. Test the agent by asking questions or interacting with the conversation starters.

    A screenshot showing the conversation starters from the declarative agent in Microsoft 365 Copilot.

Check your work: Provision and test the agent

To verify the agent's functionality:

  1. Confirm that the agent responds according to the instructions you defined in Task 1.
  2. Ensure the conversation starters added in Task 2 are visible and functional.
  3. Test various interactions to validate the agent's behavior and response accuracy.