Langsung ke konten
Skillpedia
Agen40k · #7459

typespec-create-api-plugin

Fungsinya

Kode ini membantu membuat 'agent' untuk Microsoft 365 Copilot yang bisa berinteraksi dengan layanan lain melalui internet (REST API). Kode ini mendefinisikan bagaimana Copilot memahami dan menggunakan koneksi tersebut.

Kapan dipakai

  • ✓Saat Anda ingin Copilot menggunakan layanan eksternal untuk mengambil atau mengirim informasi.
  • ✓Saat membuat asisten khusus yang perlu mengakses data dari aplikasi lain.
  • ✓Untuk menghubungkan Copilot ke sistem non-Microsoft.

Link skill

https://github.com/github/awesome-copilot/blob/main/skills/typespec-create-api-plugin/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/github/awesome-copilot/blob/main/skills/typespec-create-api-plugin/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit →

Contoh permintaan ke AI

“Buatkan agent untuk Copilot yang bisa mengambil informasi dari katalog produk online.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Kode ini mendefinisikan 'agent' dengan nama dan deskripsi, lalu menentukan 'actions' yang bisa dilakukannya, seperti mengambil data. Kode ini juga mengatur bagaimana Copilot melakukan autentikasi dan bagaimana respons ditampilkan.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

Create TypeSpec API Plugin

Create a complete TypeSpec API plugin for Microsoft 365 Copilot that integrates with external REST APIs.

Requirements

Generate TypeSpec files with:

main.tsp - Agent Definition

import "@typespec/http";
import "@typespec/openapi3";
import "@microsoft/typespec-m365-copilot";
import "./actions.tsp";

using TypeSpec.Http;
using TypeSpec.M365.Copilot.Agents;
using TypeSpec.M365.Copilot.Actions;

@agent({
  name: "[Agent Name]",
  description: "[Description]"
})
@instructions("""
  [Instructions for using the API operations]
""")
namespace [AgentName] {
  // Reference operations from actions.tsp
  op operation1 is [APINamespace].operationName;
}

actions.tsp - API Operations

import "@typespec/http";
import "@microsoft/typespec-m365-copilot";

using TypeSpec.Http;
using TypeSpec.M365.Copilot.Actions;

@service
@actions(#{
    nameForHuman: "[API Display Name]",
    descriptionForModel: "[Model description]",
    descriptionForHuman: "[User description]"
})
@server("[API_BASE_URL]", "[API Name]")
@useAuth([AuthType]) // Optional
namespace [APINamespace] {
  
  @route("[/path]")
  @get
  @action
  op operationName(
    @path param1: string,
    @query param2?: string
  ): ResponseModel;

  model ResponseModel {
    // Response structure
  }
}

Authentication Options

Choose based on API requirements:

  1. No Authentication (Public APIs)

    // No @useAuth decorator needed
    
  2. API Key

    @useAuth(ApiKeyAuth<ApiKeyLocation.header, "X-API-Key">)
    
  3. OAuth2

    @useAuth(OAuth2Auth<[{
      type: OAuth2FlowType.authorizationCode;
      authorizationUrl: "https://oauth.example.com/authorize";
      tokenUrl: "https://oauth.example.com/token";
      refreshUrl: "https://oauth.example.com/token";
      scopes: ["read", "write"];
    }]>)
    
  4. Registered Auth Reference

    @useAuth(Auth)
    
    @authReferenceId("registration-id-here")
    model Auth is ApiKeyAuth<ApiKeyLocation.header, "X-API-Key">
    

Function Capabilities

Confirmation Dialog

@capabilities(#{
  confirmation: #{
    type: "AdaptiveCard",
    title: "Confirm Action",
    body: """
    Are you sure you want to perform this action?
      * **Parameter**: {{ function.parameters.paramName }}
    """
  }
})

Adaptive Card Response

@card(#{
  dataPath: "$.items",
  title: "$.title",
  url: "$.link",
  file: "cards/card.json"
})

Reasoning & Response Instructions

@reasoning("""
  Consider user's context when calling this operation.
  Prioritize recent items over older ones.
""")
@responding("""
  Present results in a clear table format with columns: ID, Title, Status.
  Include a summary count at the end.
""")

Best Practices

  1. Operation Names: Use clear, action-oriented names (listProjects, createTicket)
  2. Models: Define TypeScript-like models for requests and responses
  3. HTTP Methods: Use appropriate verbs (@get, @post, @patch, @delete)
  4. Paths: Use RESTful path conventions with @route
  5. Parameters: Use @path, @query, @header, @body appropriately
  6. Descriptions: Provide clear descriptions for model understanding
  7. Confirmations: Add for destructive operations (delete, update critical data)
  8. Cards: Use for rich visual responses with multiple data items

Workflow

Ask the user:

  1. What is the API base URL and purpose?
  2. What operations are needed (CRUD operations)?
  3. What authentication method does the API use?
  4. Should confirmations be required for any operations?
  5. Do responses need Adaptive Cards?

Then generate:

  • Complete main.tsp with agent definition
  • Complete actions.tsp with API operations and models
  • Optional cards/card.json if Adaptive Cards are needed
Pertanyaan umum

Apa itu TypeSpec?

TypeSpec adalah bahasa untuk mendeskripsikan API, sehingga alat seperti Copilot lebih mudah memahami cara berinteraksi dengannya.

Apa itu 'Adaptive Cards'?

Ini adalah kartu visual yang bisa ditampilkan Copilot untuk menyajikan informasi secara terorganisir atau meminta konfirmasi.

Apakah saya perlu bisa coding untuk menggunakan ini?

Tidak perlu. Tujuannya, Anda cukup mendeskripsikan apa yang dibutuhkan, dan tool akan menghasilkan kodenya untuk Anda.

Detail

Deskripsi asli dari pembuat

Generate a TypeSpec API plugin with REST operations, authentication, and Adaptive Cards for Microsoft 365 Copilot

repo: github/awesome-copilot

Popularitas

Bintang GitHub
40k
Peringkat
#7459
Lisensi
MIT
Diperbarui
15/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa