Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Tipp
Empfohlen: Beginnen Sie mit Work IQ Dev Tools für unterstützte Pro-Code-, deklarative Agent- und Plug-In-Szenarien. Siehe WIQD-Schnellstart. Toolkitbasierte Anweisungen bleiben für vorhandene Projekte und Workflows verfügbar, die sie erfordern. Überprüfen Sie die Unterstützung der Funktionen und der Zielerfahrung , bevor Sie ein Tool auswählen: WIQD ist nicht für benutzerdefinierte Engine-Agenten vorgesehen.
Dieser Leitfaden enthält vollständige Beispiele zum Erstellen von TypeSpec-Agents für Microsoft 365 Copilot, von einfachen Basis-Agents bis hin zu komplexen Implementierungen mit mehreren Funktionen und Authentifizierungsmethoden.
Einfacher Agent ohne Funktionen
Anwendungsfall: Ein einfacher Agent, der grundlegende Informationen und Begrüßungen ohne externe Integrationen oder spezielle Funktionen bereitstellt.
Was es tut: Dieser Agent kann einfache Fragen beantworten, allgemeine Informationen bereitstellen und grundlegende Gespräche führen. Es muss nicht auf externe APIs zugreifen, das Web durchsuchen oder auf Microsoft 365-Daten zugreifen.
import "@typespec/http";
import "@typespec/openapi3";
import "@microsoft/typespec-m365-copilot";
using TypeSpec.Http;
using TypeSpec.M365.Copilot.Agents;
@agent("Basic Helper Agent", "A simple agent that provides basic information and assistance")
@instructions("""
You are a helpful assistant that provides basic information and support.
Be friendly, professional, and helpful in all interactions. Provide clear,
concise answers to user questions. If you don't know something, be honest
about your limitations and suggest alternative ways to find the information.
""")
namespace BasicHelperAgent {
// No capabilities defined - agent relies only on built-in conversational abilities
}
Agent mit mehreren Funktionen
Anwendungsfall: Ein Assistent eines Wissensarbeiters, der im Web nach Informationen suchen, auf die SharePoint-Inhalte einer organization zugreifen und Informationen zu Kollegen in der organization finden kann.
Was es tut: Dieser Agent hilft Wissensarbeitern, indem er die Websuche nach externen Informationen, den Dateizugriff zum Abrufen von Dokumenten und die Personensuche nach Kollegen und deren Kontaktinformationen kombiniert. Dieses Muster eignet sich für Forschungs- und Zusammenarbeitsszenarien.
import "@typespec/http";
import "@typespec/openapi3";
import "@microsoft/typespec-m365-copilot";
using TypeSpec.Http;
using TypeSpec.M365.Copilot.Agents;
@agent("Knowledge Worker Assistant", "An intelligent assistant that helps with research, file management, and finding colleagues")
@instructions("""
You are a knowledgeable research assistant specialized in helping knowledge workers
find information efficiently. You can search the web for external research, access
SharePoint documents for organizational content, and help locate colleagues within
the organization. Always provide comprehensive research results, cite your sources,
and suggest additional resources when relevant. When searching for people, respect
privacy and only share publicly available organizational information.
""")
namespace KnowledgeWorkerAgent {
// Web search capability for external research
op webSearch is AgentCapabilities.WebSearch<Sites = [
{
url: "https://learn.microsoft.com";
},
{
url: "https://www.microsoft.com";
}
]>;
// OneDrive and SharePoint access for document retrieval
op oneDriveAndSharePoint is AgentCapabilities.OneDriveAndSharePoint<
ItemsByUrl = [
{ url: "https://contoso.sharepoint.com/sites/IT" }
]
>;
// People search for finding colleagues
op people is AgentCapabilities.People;
}
Einfacher Agent mit anonymer API-Aktion
Anwendungsfall: Ein Facility-Management-Agent, der Benutzern hilft, Wartungsprobleme mithilfe einer API für öffentliche Reparaturen zu melden und zu verfolgen.
Was es tut: Dieser Agent ermöglicht es Benutzern, Probleme mit der Einrichtung (defekte Geräte, Beleuchtungsprobleme usw.) zu melden und den Status bestehender Reparaturanfragen zu überprüfen. Die Reparatur-API ist öffentlich zugänglich und erfordert keine Authentifizierung, sodass jeder Probleme leicht melden kann.
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("Facilities Repair Agent", "Report and track facility maintenance issues and repair requests")
@instructions("""
You are a facilities management assistant that helps employees report and track
maintenance issues. You can help users submit new repair requests by gathering
all necessary details (description, location, category, priority) and submit
them to the facilities team. You can also check the status of existing repair
tickets and provide updates on progress. Always be helpful in categorizing
issues correctly and setting appropriate priority levels based on safety and
business impact.
""")
namespace FacilitiesRepairAgent {
op reportIssue is RepairsAPI.reportIssue;
op getRepairStatus is RepairsAPI.getRepairStatus;
op getOpenRepairs is RepairsAPI.getOpenRepairs;
}
Erweiterter Agent mit API-Schlüssel-Authentifizierung
Anwendungsfall: Ein Reparaturmanagement-Agent, der Teams hilft, Wartungsaufgaben von Einrichtungen mithilfe einer öffentlich verfügbaren API mit API-Schlüsselauthentifizierung zu verfolgen und zu verwalten.
Funktionsweise: Dieser Agent bietet umfassende Reparaturverwaltungsfunktionen für Wartungsteams. Es kann Reparaturaufgaben auflisten, erstellen, aktualisieren und löschen, Reparaturen nach Zuständigkeit oder Beschreibung filtern und umfangreiche Karten-basierte Antworten mit Bildern bereitstellen. Die API-Schlüsselauthentifizierung gewährleistet einen kontrollierten Zugriff auf das Reparaturmanagementsystem und demonstriert gleichzeitig reale API-Integrationsmuster.
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("Repairs Hub Agent", "Smart repair management agent for tracking and coordinating facility maintenance tasks")
@instructions("""
You are a specialized repairs management assistant that helps teams efficiently track,
organize, and coordinate facility maintenance tasks. You excel at managing repair
workflows including creating detailed repair tickets, assigning tasks to team members,
tracking progress, and providing status updates. You can filter repairs by various
criteria such as assignee, keywords in descriptions, or completion status. Always
provide clear, organized information using tables and cards when displaying repair
data. When creating repairs, gather all necessary details and confirm the information
before submission. Help prioritize urgent repairs and ensure proper task assignment
for optimal team productivity.
""")
@conversationStarter(#{
title: "List repairs",
text: "List all repairs"
})
@conversationStarter(#{
title: "List Karin's repairs",
text: "List all repairs assigned to Karin"
})
@conversationStarter(#{
title: "Find oil repairs",
text: "List all repairs that are about oil"
})
@conversationStarter(#{
title: "Create repair",
text: "Create a new repair and assign it to me"
})
namespace RepairsAgent {
// Repair management operations
op listRepairs is RepairsHub.listRepairs;
op createRepair is RepairsHub.createRepair;
op updateRepair is RepairsHub.updateRepair;
op deleteRepair is RepairsHub.deleteRepair;
}
Komplexer Agent mit OAuth2- und GitHub-API-Integration
Anwendungsfall: Ein Projektmanagement-Agent, der Entwicklungsteams dabei hilft, ihre GitHub-Repositorys zu verwalten, Probleme zu verfolgen, Pull-Requests zu verwalten und Projektaktivitäten mithilfe der umfassenden API von GitHub zu koordinieren.
Funktionsweise: Dieser Agent dient als Projektmanagement-Assistent, der in GitHub integriert ist, um Entwicklungsteams bei der Optimierung ihrer Arbeitsabläufe zu unterstützen. Es kann Issues erstellen und verwalten, Pull Requests überprüfen und zusammenführen, Projektmeilensteine nachverfolgen und Einblicke in die Repository-Aktivität bieten. Die OAuth2-Authentifizierung gewährleistet einen sicheren Zugriff auf GitHub-Repositorys mit entsprechenden Berechtigungen, sodass Teams ihre Projekte effizient durch Interaktionen in natürlicher Sprache verwalten können.
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("GitHub Project Manager", "Smart project management agent with GitHub integration for issue tracking, pull request management, and project coordination")
@instructions("""
You are an intelligent project management assistant specialized in GitHub workflows
and development team coordination. You excel at managing GitHub repositories including
creating and tracking issues, reviewing pull requests, coordinating project milestones,
and providing insights about development activity. You can help prioritize work,
track progress, manage code reviews, and facilitate team collaboration through GitHub's
project management features. Always consider development best practices, help maintain
code quality through proper review processes, and provide actionable insights to
improve team productivity and project delivery.
""")
namespace GitHubProjectManager {
// GitHub API operations for project management
op createIssue is GitHubAPI.createIssue;
op getIssues is GitHubAPI.getIssues;
op updateIssue is GitHubAPI.updateIssue;
op getPullRequests is GitHubAPI.getPullRequests;
op createPullRequest is GitHubAPI.createPullRequest;
op mergePullRequest is GitHubAPI.mergePullRequest;
op getProjectInsights is GitHubAPI.getProjectInsights;
}
Zusammenfassung
Diese Beispiele veranschaulichen die Entwicklung von einfachen zu komplexen TypeSpec-Agents:
- Basis-Agent: Keine Funktionen, reine Konversations-KI
- Multifunktionaler Agent: Kombiniert Websuche, Dateizugriff und Personensuche
- Einfache API-Integration: Anonymer Zugriff auf externe Dienste
- Authentifizierte API-Integration: Sicherer Zugriff mit API-Schlüsseln
- Komplexe GitHub-Integration: Erweitertes OAuth2 mit umfassendem GitHub-API-Zugriff für das Projektmanagement
Jedes Beispiel baut auf den vorherigen auf und zeigt, wie Funktionen, Authentifizierung und benutzerdefinierte Aktionen hinzugefügt werden, um komplexere Agents für reale Szenarien zu erstellen.