{"kind":"Skill","metadata":{"namespace":"community","name":"typespec-create-api-plugin","version":"0.1.0"},"spec":{"description":"Generate a TypeSpec API plugin with REST operations, authentication, and Adaptive Cards for Microsoft 365 Copilot","files":{"SKILL.md":"---\nname: typespec-create-api-plugin\ndescription: 'Generate a TypeSpec API plugin with REST operations, authentication, and Adaptive Cards for Microsoft 365 Copilot'\n---\n\n# Create TypeSpec API Plugin\n\nCreate a complete TypeSpec API plugin for Microsoft 365 Copilot that integrates with external REST APIs.\n\n## Requirements\n\nGenerate TypeSpec files with:\n\n### main.tsp - Agent Definition\n```typescript\nimport \"@typespec/http\";\nimport \"@typespec/openapi3\";\nimport \"@microsoft/typespec-m365-copilot\";\nimport \"./actions.tsp\";\n\nusing TypeSpec.Http;\nusing TypeSpec.M365.Copilot.Agents;\nusing TypeSpec.M365.Copilot.Actions;\n\n@agent({\n  name: \"[Agent Name]\",\n  description: \"[Description]\"\n})\n@instructions(\"\"\"\n  [Instructions for using the API operations]\n\"\"\")\nnamespace [AgentName] {\n  // Reference operations from actions.tsp\n  op operation1 is [APINamespace].operationName;\n}\n```\n\n### actions.tsp - API Operations\n```typescript\nimport \"@typespec/http\";\nimport \"@microsoft/typespec-m365-copilot\";\n\nusing TypeSpec.Http;\nusing TypeSpec.M365.Copilot.Actions;\n\n@service\n@actions(#{\n    nameForHuman: \"[API Display Name]\",\n    descriptionForModel: \"[Model description]\",\n    descriptionForHuman: \"[User description]\"\n})\n@server(\"[API_BASE_URL]\", \"[API Name]\")\n@useAuth([AuthType]) // Optional\nnamespace [APINamespace] {\n  \n  @route(\"[/path]\")\n  @get\n  @action\n  op operationName(\n    @path param1: string,\n    @query param2?: string\n  ): ResponseModel;\n\n  model ResponseModel {\n    // Response structure\n  }\n}\n```\n\n## Authentication Options\n\nChoose based on API requirements:\n\n1. **No Authentication** (Public APIs)\n   ```typescript\n   // No @useAuth decorator needed\n   ```\n\n2. **API Key**\n   ```typescript\n   @useAuth(ApiKeyAuth\u003cApiKeyLocation.header, \"X-API-Key\"\u003e)\n   ```\n\n3. **OAuth2**\n   ```typescript\n   @useAuth(OAuth2Auth\u003c[{\n     type: OAuth2FlowType.authorizationCode;\n     authorizationUrl: \"https://oauth.example.com/authorize\";\n     tokenUrl: \"https://oauth.example.com/token\";\n     refreshUrl: \"https://oauth.example.com/token\";\n     scopes: [\"read\", \"write\"];\n   }]\u003e)\n   ```\n\n4. **Registered Auth Reference**\n   ```typescript\n   @useAuth(Auth)\n   \n   @authReferenceId(\"registration-id-here\")\n   model Auth is ApiKeyAuth\u003cApiKeyLocation.header, \"X-API-Key\"\u003e\n   ```\n\n## Function Capabilities\n\n### Confirmation Dialog\n```typescript\n@capabilities(#{\n  confirmation: #{\n    type: \"AdaptiveCard\",\n    title: \"Confirm Action\",\n    body: \"\"\"\n    Are you sure you want to perform this action?\n      * **Parameter**: {{ function.parameters.paramName }}\n    \"\"\"\n  }\n})\n```\n\n### Adaptive Card Response\n```typescript\n@card(#{\n  dataPath: \"$.items\",\n  title: \"$.title\",\n  url: \"$.link\",\n  file: \"cards/card.json\"\n})\n```\n\n### Reasoning \u0026 Response Instructions\n```typescript\n@reasoning(\"\"\"\n  Consider user's context when calling this operation.\n  Prioritize recent items over older ones.\n\"\"\")\n@responding(\"\"\"\n  Present results in a clear table format with columns: ID, Title, Status.\n  Include a summary count at the end.\n\"\"\")\n```\n\n## Best Practices\n\n1. **Operation Names**: Use clear, action-oriented names (listProjects, createTicket)\n2. **Models**: Define TypeScript-like models for requests and responses\n3. **HTTP Methods**: Use appropriate verbs (@get, @post, @patch, @delete)\n4. **Paths**: Use RESTful path conventions with @route\n5. **Parameters**: Use @path, @query, @header, @body appropriately\n6. **Descriptions**: Provide clear descriptions for model understanding\n7. **Confirmations**: Add for destructive operations (delete, update critical data)\n8. **Cards**: Use for rich visual responses with multiple data items\n\n## Workflow\n\nAsk the user:\n1. What is the API base URL and purpose?\n2. What operations are needed (CRUD operations)?\n3. What authentication method does the API use?\n4. Should confirmations be required for any operations?\n5. Do responses need Adaptive Cards?\n\nThen generate:\n- Complete `main.tsp` with agent definition\n- Complete `actions.tsp` with API operations and models\n- Optional `cards/card.json` if Adaptive Cards are needed\n"},"import":{"commit_sha":"541b7819d8c3545c6df122491af4fa1eae415779","imported_at":"2026-05-18T20:05:35Z","license_text":"MIT License\n\nCopyright GitHub, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","owner":"github","repo":"github/awesome-copilot","source_url":"https://github.com/github/awesome-copilot/tree/541b7819d8c3545c6df122491af4fa1eae415779/plugins/typespec-m365-copilot/skills/typespec-create-api-plugin"}},"content_hash":[95,244,70,71,0,54,137,16,140,119,14,203,174,245,235,20,247,86,238,244,232,84,178,33,151,173,219,228,196,37,221,88],"trust_level":"unsigned","yanked":false}
