LE MÉDIA DE L’IA QUI SERT VRAIMENT.Édition française · Comprendre & passer à l’action
Microsoft

Construire un agent multicanal M365, Teams ou Copilot Studio en TypeScript

m365-agents-ts

En bref

Cette skill documente le SDK TypeScript Microsoft 365 Agents (`@microsoft/agents-hosting` selon le texte source). Elle permet de construire un agent multicanal pour Teams, M365 ou Copilot Studio, avec le routage `AgentApplication`, un hébergement Express, des réponses en flux et un client Copilot Studio. Ce n’est pas le SDK Python équivalent (`m365-agents-py`). Une `AZURE_API_KEY` peut apparaître dans certains exemples d’authentification documentés. L’installation typique pose `@microsoft/agents-hosting`, `@microsoft/agents-hosting-express` et `@microsoft/agents-activity`, plus, au besoin, `@microsoft/agents-copilotstudio-client`. Les gestionnaires typiques reçoivent un `TurnContext` (`onMessage`, `onConversationUpdate`, `onActivity`). Les variables d’exemple comprennent aussi `AZURE_RESOURCE_NAME` et `AZURE_OPENAI_DEPLOYMENT_NAME`.

Ce que ça fait

  • Construire un agent multicanal pour Teams, M365 ou Copilot Studio, avec le routage `AgentApplication`, un hébergement Express, des réponses en flux et un client Copilot Studio.
  • Ce n’est pas le SDK Python équivalent (`m365-agents-py`).
  • Une `AZURE_API_KEY` peut apparaître dans certains exemples d’authentification documentés.
  • La variable d’environnement typique est `AZURE_API_KEY`.
  • Le client documenté est `CopilotStudioClient`.
  • Le langage de référence est TypeScript.

Pour qui, et un exemple

Côté Node, celles et ceux qui écrivent un agent TypeScript pour Teams ou Copilot Studio, avec Express et AgentApplication, plutôt qu’en Python.

Exemple de demande : « Branche un AgentApplication TypeScript, hébergé par Express, avec un flux de réponses et le client Copilot Studio. »

On s’en sert pour un agent multicanal TypeScript (Teams, M365, Copilot Studio), avec AgentApplication, Express et des réponses en flux. Exemple rédigé par iadujour.fr à partir du SKILL.md, non testé.

Installer

npx skills add microsoft/skills (sélection de la skill dans l’assistant, README).

npx skills add microsoft/skills

Fonctionne avec

  • GitHub Copilot
  • Copilot CLI

Source : README : exemples de « Copilot CLI » et « GitHub Copilot in VS Code » ; l’installation `npx skills add` envoie les fichiers vers le répertoire de l’agent choisi, sans liste exhaustive.

Niveau : Intermédiaire

Suppose un projet de l’éditeur et la maîtrise du SDK ou de la CLI correspondante.

À savoir

Dépôt officiel Microsoft ; le README le présente comme un travail en cours (skills et tests encore enrichis).

Extrait du SKILL.md

La description d’origine, celle que l’agent lit pour décider de charger la skill (en anglais) :

Microsoft 365 Agents SDK for TypeScript/Node.js. Build multichannel agents for Teams/M365/Copilot Studio with AgentApplication routing, Express hosting, streaming responses, and Copilot Studio client integration. Triggers: "Microsoft 365 Agents SDK", "@microsoft/agents-hosting", "AgentApplication", "startServer", "streamingResponse", "Copilot Studio client", […]

Citée depuis le SKILL.md au commit e1f9cce .

Le SKILL.md compte 185 lignes et 10 sections principales :

  • Before implementation
  • Installation
  • Environment Variables
  • Core Workflow: Express-hosted AgentApplication
  • Streaming responses with Azure OpenAI
  • Invoke activity handling
  • Copilot Studio client (Direct to Engine)
  • Copilot Studio WebChat integration
  • Best Practices
  • Reference Links

Licence : MIT

Vérifiée le 10 novembre 2026 sur : fichier LICENSE du dépôt . Licence déclarée dans le frontmatter : « MIT ». Titulaire : Copyright (c) Microsoft Corporation..

La licence autorise la reprise : le texte intégral du SKILL.md est reproduit ci-dessous, sans modification, avec sa mention de licence.

Texte intégral du SKILL.md

Reproduit sans modification depuis microsoft/skills (commit e1f9cce) , © Microsoft, sous licence MIT (fichier de licence d’origine ).

Afficher le SKILL.md original (185 lignes, en anglais)
---
name: m365-agents-ts
description: |
  Microsoft 365 Agents SDK for TypeScript/Node.js. Build multichannel agents for Teams/M365/Copilot Studio with AgentApplication routing, Express hosting, streaming responses, and Copilot Studio client integration. Triggers: "Microsoft 365 Agents SDK", "@microsoft/agents-hosting", "AgentApplication", "startServer", "streamingResponse", "Copilot Studio client", "@microsoft/agents-copilotstudio-client".
license: MIT
metadata:
  author: Microsoft
  version: "1.0.0"
  package: "@microsoft/agents-hosting, @microsoft/agents-hosting-express, @microsoft/agents-activity, @microsoft/agents-copilotstudio-client"
---

# Microsoft 365 Agents SDK (TypeScript)

Build enterprise agents for Microsoft 365, Teams, and Copilot Studio using the Microsoft 365 Agents SDK with Express hosting, AgentApplication routing, streaming responses, and Copilot Studio client integrations.

## Before implementation

- Use the microsoft-docs MCP to verify the latest API signatures for AgentApplication, startServer, and CopilotStudioClient.
- Confirm package versions on npm before wiring up samples or templates.

## Installation

```bash
npm install @microsoft/agents-hosting @microsoft/agents-hosting-express @microsoft/agents-activity
npm install @microsoft/agents-copilotstudio-client
```

## Environment Variables

```bash
PORT=3978
AZURE_RESOURCE_NAME=<azure-openai-resource>
AZURE_API_KEY=<azure-openai-key>
AZURE_OPENAI_DEPLOYMENT_NAME=gpt-4o-mini

TENANT_ID=<tenant-id>
CLIENT_ID=<client-id>
CLIENT_SECRET=<client-secret>

COPILOT_ENVIRONMENT_ID=<environment-id>
COPILOT_SCHEMA_NAME=<schema-name>
COPILOT_CLIENT_ID=<copilot-app-client-id>
COPILOT_BEARER_TOKEN=<copilot-jwt>
```

## Core Workflow: Express-hosted AgentApplication

```typescript
import {
  AgentApplication,
  TurnContext,
  TurnState,
} from "@microsoft/agents-hosting";
import { startServer } from "@microsoft/agents-hosting-express";

const agent = new AgentApplication<TurnState>();

agent.onConversationUpdate("membersAdded", async (context: TurnContext) => {
  await context.sendActivity("Welcome to the agent.");
});

agent.onMessage("hello", async (context: TurnContext) => {
  await context.sendActivity(`Echo: ${context.activity.text}`);
});

startServer(agent);
```

## Streaming responses with Azure OpenAI

```typescript
import { azure } from "@ai-sdk/azure";
import {
  AgentApplication,
  TurnContext,
  TurnState,
} from "@microsoft/agents-hosting";
import { startServer } from "@microsoft/agents-hosting-express";
import { streamText } from "ai";

const agent = new AgentApplication<TurnState>();

agent.onMessage("poem", async (context: TurnContext) => {
  context.streamingResponse.setFeedbackLoop(true);
  context.streamingResponse.setGeneratedByAILabel(true);
  context.streamingResponse.setSensitivityLabel({
    type: "https://schema.org/Message",
    "@type": "CreativeWork",
    name: "Internal",
  });

  await context.streamingResponse.queueInformativeUpdate("starting a poem...");

  const { fullStream } = streamText({
    model: azure(process.env.AZURE_OPENAI_DEPLOYMENT_NAME || "gpt-4o-mini"),
    system: "You are a creative assistant.",
    prompt: "Write a poem about Apollo.",
  });

  try {
    for await (const part of fullStream) {
      if (part.type === "text-delta" && part.text.length > 0) {
        await context.streamingResponse.queueTextChunk(part.text);
      }
      if (part.type === "error") {
        throw new Error(`Streaming error: ${part.error}`);
      }
    }
  } finally {
    await context.streamingResponse.endStream();
  }
});

startServer(agent);
```

## Invoke activity handling

```typescript
import { Activity, ActivityTypes } from "@microsoft/agents-activity";
import {
  AgentApplication,
  TurnContext,
  TurnState,
} from "@microsoft/agents-hosting";

const agent = new AgentApplication<TurnState>();

agent.onActivity("invoke", async (context: TurnContext) => {
  const invokeResponse = Activity.fromObject({
    type: ActivityTypes.InvokeResponse,
    value: { status: 200 },
  });

  await context.sendActivity(invokeResponse);
  await context.sendActivity("Thanks for submitting your feedback.");
});
```

## Copilot Studio client (Direct to Engine)

```typescript
import { CopilotStudioClient } from "@microsoft/agents-copilotstudio-client";

const settings = {
  environmentId: process.env.COPILOT_ENVIRONMENT_ID!,
  schemaName: process.env.COPILOT_SCHEMA_NAME!,
  clientId: process.env.COPILOT_CLIENT_ID!,
};

const tokenProvider = async (): Promise<string> => {
  return process.env.COPILOT_BEARER_TOKEN!;
};

const client = new CopilotStudioClient(settings, tokenProvider);

const conversation = await client.startConversationAsync();
const reply = await client.askQuestionAsync("Hello!", conversation.id);
console.log(reply);
```

## Copilot Studio WebChat integration

```typescript
import { CopilotStudioWebChat } from "@microsoft/agents-copilotstudio-client";

const directLine = CopilotStudioWebChat.createConnection(client, {
  showTyping: true,
});

window.WebChat.renderWebChat(
  {
    directLine,
  },
  document.getElementById("webchat")!,
);
```

## Best Practices

1. Use AgentApplication for routing and keep handlers focused on one responsibility.
2. Prefer streamingResponse for long-running completions and call endStream in finally blocks.
3. Keep secrets out of source code; load tokens from environment variables or secure stores.
4. Reuse CopilotStudioClient instances and cache tokens in your token provider.
5. Validate invoke payloads before logging or persisting feedback.

## Reference Links

| Resource                               | URL                                                                                                                 |
| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| Microsoft 365 Agents SDK               | https://learn.microsoft.com/en-us/microsoft-365/agents-sdk/                                                         |
| JavaScript SDK overview                | https://learn.microsoft.com/en-us/javascript/api/overview/agents-overview?view=agents-sdk-js-latest                 |
| @microsoft/agents-hosting-express      | https://learn.microsoft.com/en-us/javascript/api/%40microsoft/agents-hosting-express?view=agents-sdk-js-latest      |
| @microsoft/agents-copilotstudio-client | https://learn.microsoft.com/en-us/javascript/api/%40microsoft/agents-copilotstudio-client?view=agents-sdk-js-latest |
| Integrate with Copilot Studio          | https://learn.microsoft.com/en-us/microsoft-365/agents-sdk/integrate-with-mcs                                       |
| GitHub samples                         | https://github.com/microsoft/Agents/tree/main/samples/nodejs                                                        |
Source. Fiche rédigée par iadujour.fr à partir de : Frontmatter, sections et corps du SKILL.md, README du dépôt. Consultée le 10 novembre 2026. Dépôt : microsoft/skills .

Dans l’annuaire

Cas d’usage et guides qui partagent un thème, un métier ou un outil avec cette skill.

DANS L’ANNUAIRE

Cas d’usage liés.

Des fiches de l’annuaire qui partagent au moins deux mots-clés précis avec cette skill.

Support client

Réduire les demandes au helpdesk interne avec un agent virtuel sur Teams

Groupama a déployé « SAM », un agent virtuel sur Teams conçu avec Copilot Studio et la Power Platform, pour automatiser les demandes de support informatique : Microsoft indique une baisse d’à peu près 25 % des sollicitations du helpdesk, pour plus de 5 000 collaborateurs.

Outil : SAM (Groupama, Copilot Studio)Type : Repéré
MÊME ÉDITEUR

Autres skills Microsoft : Agents et skills

Toute la catégorie
MicrosoftAgents et skills

Recommander une skill Azure adaptée à la tâche

discover-azure-skills

On recourt à cette skill pour la recherche dans le catalogue des skills Azure, pour recommander une skill d’agent installable qui correspond à une tâche Azure : lister les greffons et les skills depuis l’API GitHub du dépôt `microsoft/azure-skills`, lire les descriptions, retrouver le nom du greffon dans `plugin.json` (qui peut différer du nom de dossier), puis proposer les instructions d’installation selon le client (Copilot CLI, Claude Code, ou autre).

Outils : GitHub Copilot, Copilot CLINiveau : Intermédiairemàj 03/11/2026
ÉCHANGES

Commentaires.

Un retour d’expérience, une question, une précision sur cette skill ? Les commentaires sont relus avant publication.

Commentaires publiés

Chargement des commentaires…

    Laisser un commentaire

    Charte de modération. Chaque commentaire est relu avant publication. Sont refusés : l’incitation à la haine, les propos injurieux ou discriminatoires, la publicité, le spam et les liens promotionnels, le hors-sujet et les données personnelles d’autrui.