Edit

Share via


Add skills to a declarative agent created with Microsoft 365 Agents Toolkit

You can enhance the abilities of your agent by adding skills. Skills can be added either by enabling built-in capabilities like image generator or code interpreter, or by adding API plugins as custom actions.

Important

This guide assumes you have completed the Create declarative agents using Microsoft 365 Agents Toolkit tutorial.

Add image generator to the agent

The image generator capability enables agents to generate images based on user prompts.

  1. Open the appPackage/declarativeAgent.json file and add the GraphicArt entry to the capabilities array.

    {
      "name": "GraphicArt"
    }
    

    For more information, see Graphic art object.

  2. Select Provision in the Lifecycle pane of the Agents Toolkit.

The declarative agent will have the ability to generate images after you reload the page.

A screenshot showing a response from the declarative agent that contains generated graphic art

Add code interpreter to the agent

Code interpreter is an advanced tool designed to solve complex tasks via Python code.

  1. Open the appPackage/declarativeAgent.json file and add the CodeInterpreter entry to the capabilities array.

    {
      "name": "CodeInterpreter"
    }
    

    For more information, see Code interpreter object.

  2. Select Provision in the Lifecycle pane of the Agents Toolkit.

The declarative agent will have the code interpreter capability after you reload the page.

A screenshot showing a response from the declarative agent that contains a generated graph

A screenshot showing the Python code used to generate the requested graph

Add an API plugin as a custom action to the agent

API plugins add new abilities to your agent by allowing your agent to interact with a REST API.

Before you begin, create a file named posts-api.yml and add the code from the Posts API OpenAPI description document.

  1. Select Add Action in the Development pane of Agents Toolkit.

  2. Select Start with an OpenAPI Description Document.

  3. Select Browse and browse to the posts-api.yml file.

  4. Select all available APIs, then select OK.

    A screenshot of the API selection dialog in Visual Studio code

  5. Select manifest.json.

  6. Review the warning in the dialog. When you're ready to proceed, select Add.

  7. Select Provision in the Lifecycle pane of the Agents Toolkit.

The declarative agent will have access to your plugin content to generate its answers after you reload the page.

A screenshot showing a response from the declarative agent that contains API plugin content

Posts API OpenAPI description document

The following OpenAPI description is for the JSONPlaceHolder API, a free online REST API that you can use whenever you need some fake data.

openapi: '3.0.2'
info:
  title: Posts API
  version: '1.0'
servers:
- url: https://jsonplaceholder.typicode.com/

components:
  schemas:
    post:
      type: object
      properties:
        userId:
          type: integer
          description: The ID of the user that authored the post.
        id:
          type: integer
        title:
          type: string
        body:
          type: string
    user:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        username:
          type: string
        email:
          type: string
        phone:
          type: string
        website:
          type: string
        address:
          $ref: '#/components/schemas/address'
        company:
          $ref: '#/components/schemas/company'
    address:
      type: object
      properties:
        street:
          type: string
        suite:
          type: string
        city:
          type: string
        zipcode:
          type: string
        geo:
          $ref: '#/components/schemas/coordinates'
    coordinates:
      type: object
      properties:
        lat:
          type: string
          description: The latitude of the ___location
        lng:
          type: string
          description: The longitude of the ___location
    company:
      type: object
      properties:
        name:
          type: string
        catchPhrase:
          type: string
        bs:
          type: string
  parameters:
    post-id:
      name: post-id
      in: path
      description: 'key: id of post'
      required: true
      style: simple
      schema:
        type: integer
    user-id:
      name: user-id
      in: path
      description: 'key: id of user'
      required: true
      style: simple
      schema:
        type: integer

paths:
  /posts:
    get:
      description: Get posts
      operationId: GetPosts
      parameters:
      - name: userId
        in: query
        description: Filter results by user ID
        required: false
        style: form
        schema:
          type: integer
          maxItems: 1
      - name: title
        in: query
        description: Filter results by title
        required: false
        style: form
        schema:
          type: string
          maxItems: 1
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/post'
    post:
      description: 'Create post'
      operationId: CreatePost
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/post'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/post'
  /posts/{post-id}:
    get:
      description: 'Get post by ID'
      operationId: GetPostById
      parameters:
      - $ref: '#/components/parameters/post-id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/post'
    patch:
      description: 'Update post'
      operationId: UpdatePost
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/post'
      parameters:
      - $ref: '#/components/parameters/post-id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/post'
    delete:
      description: 'Delete post'
      operationId: DeletePost
      parameters:
      - $ref: '#/components/parameters/post-id'
      responses:
        '200':
          description: OK
  /users:
    get:
      summary: Get users
      description: Returns details about users
      operationId: GetUsers
      parameters:
      - name: name
        in: query
        description: The user's real name
        schema:
          type: string
      - name: username
        in: query
        description: The user's login name
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/user'
  /users/{user-id}:
    get:
      description: 'Get user by ID'
      operationId: GetUserById
      parameters:
      - $ref: '#/components/parameters/user-id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/user'

You've completed the declarative agent guide for Microsoft 365 Copilot. Now that you're familiar with the capabilities of a declarative agent, you can learn more about declarative agents in the following articles.