Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ $: npm run test
- [`@microsoft/teams.api`](./packages/api/README.md)
- [`@microsoft/teams.botbuilder`](./packages/botbuilder/README.md)
- [`@microsoft/teams.cards`](./packages/cards/README.md)
- [`@microsoft/teams.cli`](./packages/cli/README.md)
- [`@microsoft/teams.client`](./packages/client/README.md)
- [`@microsoft/teams.common`](./packages/common/README.md)
- [`@microsoft/teams.config`](./packages/config/README.md)
Expand All @@ -94,8 +93,8 @@ $: npm run test
> ℹ️ used to test the SDK or as a visual sample of how certain features can be implemented.

> ⚠️ **WARNING** these apps are changed often and are not intended to be used outside the
> projects monorepo. To easily setup a new project please use the **templates** available via
> the `@microsoft/teams.cli` and follow the
> projects monorepo. To create and manage Teams apps for these samples, use the official
> Teams CLI (`@microsoft/teams.cli`) and follow the
> [Getting Started](https://microsoft.github.io/teams-sdk/typescript/getting-started) documentation!
Comment thread
heyitsaamir marked this conversation as resolved.

- [`@examples/echo`](./examples/echo/README.md)
Expand All @@ -112,4 +111,4 @@ $: npm run test
## Links

- [Teams Developer Portal: Apps](https://dev.teams.microsoft.com/apps)
- [Teams Toolkit](https://www.npmjs.com/package/@microsoft/teamsapp-cli)
- [Teams CLI](https://www.npmjs.com/package/@microsoft/teams.cli)
18 changes: 18 additions & 0 deletions examples/a2a/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,24 @@ Fill in:
- `BOT_SELF_URL` — `http://localhost:<PORT>` for local dev.
- `PEER_NAME` / `PEER_URL` — the other bot.

## Teams CLI

Use the official Teams CLI (`@microsoft/teams.cli`) to create and manage the Teams app for this sample:

```bash
npm install -g @microsoft/teams.cli
teams --version
Comment thread
heyitsaamir marked this conversation as resolved.
teams login
```

Expose this sample's local `/api/messages` endpoint with a tunnel, then create the Teams app:

```bash
teams app create --name "a2a" --endpoint "https://<your-tunnel>/api/messages" --env .env --json
```

The CLI writes `CLIENT_ID`, `CLIENT_SECRET`, and `TENANT_ID` to your `.env` file and prints an install link for Teams.

## Run

In two terminals:
Expand Down
20 changes: 19 additions & 1 deletion examples/ai-mcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,27 @@ This is the TypeScript counterpart to the .NET [`ExtAIBot`](https://github.com/m
- An **Azure OpenAI resource** with a deployed model (e.g. `gpt-4o`) and an API key. No Foundry project required.
- A Teams bot registration (App ID + secret).

## Teams CLI

Use the official Teams CLI (`@microsoft/teams.cli`) to create and manage the Teams app for this sample:

```bash
npm install -g @microsoft/teams.cli
teams --version
teams login
```

Expose this sample's local `/api/messages` endpoint with a tunnel, then create the Teams app:

```bash
teams app create --name "ai-mcp" --endpoint "https://<your-tunnel>/api/messages" --env .env --json
```

The CLI writes `CLIENT_ID`, `CLIENT_SECRET`, and `TENANT_ID` to your `.env` file and prints an install link for Teams.

## Setup

Create a `.env` in this directory:
Add the Azure OpenAI settings to the `.env` created by the CLI:

```env
AZURE_OPENAI_ENDPOINT=https://<your-resource>.openai.azure.com
Expand Down
18 changes: 18 additions & 0 deletions examples/botbuilder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

A bot that implements a Bot Builder Adapter.

## Teams CLI

Use the official Teams CLI (`@microsoft/teams.cli`) to create and manage the Teams app for this sample:

```bash
npm install -g @microsoft/teams.cli
teams --version
Comment thread
heyitsaamir marked this conversation as resolved.
teams login
```

Expose this sample's local `/api/messages` endpoint with a tunnel, then create the Teams app:

```bash
teams app create --name "botbuilder" --endpoint "https://<your-tunnel>/api/messages" --env .env --json
```

The CLI writes `CLIENT_ID`, `CLIENT_SECRET`, and `TENANT_ID` to your `.env` file and prints an install link for Teams.

## Run

```bash
Expand Down
16 changes: 12 additions & 4 deletions examples/cards/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@ a demo of adaptive cards
npm install
```

To run on teams, run:
## Teams CLI

Use the official Teams CLI (`@microsoft/teams.cli`) to create and manage the Teams app for this sample:

```bash
npx @microsoft/teams.cli config add atk.basic
npm install -g @microsoft/teams.cli
teams --version
Comment thread
heyitsaamir marked this conversation as resolved.
teams login
```

This will add all the atk related configs.
Expose this sample's local `/api/messages` endpoint with a tunnel, then create the Teams app:

```bash
teams app create --name "cards" --endpoint "https://<your-tunnel>/api/messages" --env .env --json
```

Then run the sample via atk.
The CLI writes `CLIENT_ID`, `CLIENT_SECRET`, and `TENANT_ID` to your `.env` file and prints an install link for Teams.
16 changes: 12 additions & 4 deletions examples/dialogs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,20 @@ A demo of dialogs (task modules) in Teams.
npm install
```

To run on teams, run:
## Teams CLI

Use the official Teams CLI (`@microsoft/teams.cli`) to create and manage the Teams app for this sample:

```bash
npx @microsoft/teams.cli config add atk.basic
npm install -g @microsoft/teams.cli
teams --version
Comment thread
heyitsaamir marked this conversation as resolved.
teams login
```

This will add all the atk related configs.
Expose this sample's local `/api/messages` endpoint with a tunnel, then create the Teams app:

```bash
teams app create --name "dialogs" --endpoint "https://<your-tunnel>/api/messages" --env .env --json
```

Then run the sample via atk.
The CLI writes `CLIENT_ID`, `CLIENT_SECRET`, and `TENANT_ID` to your `.env` file and prints an install link for Teams.
18 changes: 18 additions & 0 deletions examples/echo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

A bot that echos back what the user said to it.

## Teams CLI

Use the official Teams CLI (`@microsoft/teams.cli`) to create and manage the Teams app for this sample:

```bash
npm install -g @microsoft/teams.cli
teams --version
Comment thread
heyitsaamir marked this conversation as resolved.
teams login
```

Expose this sample's local `/api/messages` endpoint with a tunnel, then create the Teams app:

```bash
teams app create --name "echo" --endpoint "https://<your-tunnel>/api/messages" --env .env --json
```

The CLI writes `CLIENT_ID`, `CLIENT_SECRET`, and `TENANT_ID` to your `.env` file and prints an install link for Teams.

## Run

```bash
Expand Down
142 changes: 88 additions & 54 deletions examples/graph/README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,104 @@
# Auth test
# Graph auth sample

Run this first to get all the config files:
This sample demonstrates signing a user in and calling Microsoft Graph with the `userGraph` client.

## Teams CLI

Use the official Teams CLI (`@microsoft/teams.cli`) to create and manage the Teams app for this sample:

```bash
npm install -g @microsoft/teams.cli
teams --version
Comment thread
heyitsaamir marked this conversation as resolved.
teams login
```
teams config add atk.oauth

Expose this sample's local `/api/messages` endpoint with a tunnel, then create the Teams app:

```bash
teams app create --name "graph" --endpoint "https://<your-tunnel>/api/messages" --env .env --json
```

Then run via ATK.
The CLI writes `CLIENT_ID`, `CLIENT_SECRET`, and `TENANT_ID` to your `.env` file and prints an install link for Teams. Save the `teamsAppId` and `botId` from the JSON output for the auth setup below.

## Configure Graph auth

This sample expects an OAuth connection named `graph`, matching `defaultConnectionName: 'graph'` in `src/index.ts`.

Follow the Teams SDK [SSO setup guide](https://github.com/microsoft/teams-sdk/blob/main/plugins/teams-sdk/skills/teams-dev/references/guide-setup-sso.md) flow:

1. Make sure Azure CLI is installed and signed in with the same account used for `teams login`:

```bash
az account show
```

## Teams Toolkit Configuration: Oauth
2. Check where the bot is hosted:

Use this if you want to enable user authentication in your Teams application.
```bash
teams app bot get <teamsAppId>
```

## How to update scopes
If the bot is Teams-managed, migrate it to Azure first:

1. In the `aad.manifest.json` file, update the `requiredResourceAccess` list to add the required scopes.
```bash
az group create --name <resourceGroup> --location <azureRegion>
teams app bot migrate <teamsAppId> --resource-group <resourceGroup>
```

2. In the `infra/botRegistration/azurebot.bicep` file, under the `botServicesMicrosoftGraphConnection` resource, update the `properties.scopes` string to be a comma-delimited list of the required scopes.
3. Create or reuse the bot client secret from `.env`, then configure the AAD app identifier URI, `access_as_user` scope, Teams pre-authorization, and Bot Framework redirect URI as described in the SSO setup guide.

### Example
4. Create the Azure Bot OAuth connection named `graph`:

```bash
az bot authsetting create \
--name <botId> \
--resource-group <resourceGroup> \
--setting-name "graph" \
--service Aadv2 \
--client-id <botId> \
--client-secret <clientSecret> \
--provider-scope-string "User.Read" \
--parameters tenantId=<tenantId> tokenExchangeUrl=api://botid-<botId> \
--subscription <subscription>
```

5. Set the Teams app SSO identity fields:

```bash
teams app update <teamsAppId> \
--web-app-info-id "<botId>" \
--web-app-info-resource "api://botid-<botId>"
```

6. Verify the setup:

```bash
teams app doctor <teamsAppId>
```

## Updating Graph scopes

The default OAuth connection uses `User.Read`. To request more Microsoft Graph delegated permissions, update the OAuth connection scopes in Azure Bot Service. For example:

```bash
az bot authsetting create \
--name <botId> \
--resource-group <resourceGroup> \
--setting-name "graph" \
--service Aadv2 \
--client-id <botId> \
--client-secret <clientSecret> \
--provider-scope-string "User.Read People.Read User.ReadBasic.All" \
--parameters tenantId=<tenantId> tokenExchangeUrl=api://botid-<botId> \
--subscription <subscription>
```

If you want to add the `People.Read.All` and `User.ReadBasic.All` scopes.
> Admin consent may be required depending on the scopes you add.

1. Your `requiredResourceAccess` property should look like:
## Run

```json
"requiredResourceAccess": [
{
"resourceAppId": "Microsoft Graph",
"resourceAccess": [
{
"id": "People.Read.All",
"type": "Scope"
}
]
},
{
"resourceAppId": "Microsoft Graph",
"resourceAccess": [
{
"id": "User.ReadBasic.All",
"type": "Scope"
}
]
},
]
```bash
npm run dev
```

2. Update the `properties.scopes` to be `People.Read.All,User.ReadBasic.All`.

## Configuring a Regional Bot
NOTE: This example uses west europe, but follow the equivalent for other locations.

1. In `azurebot.bicep`, replace all `global` occurrences to `westeurope`
2. In `manifest.json`, in `validDomains`, `*.botframework.com` should be replaced by `europe.token.botframework.com`
2. In `aad.manifest.json`, replace `https://token.botframework.com/.auth/web/redirect` with `https://europe.token.botframework.com/.auth/web/redirect`
3. In `index.ts`, update `AppOptions` to include `apiClientSettings`

```typescript
const app = new App({
oauth: {
defaultConnectionName: 'graph',
},
logger: new ConsoleLogger('@examples/auth', { level: 'debug' }),
apiClientSettings: {
oauthUrl: "https://europe.token.botframework.com",
}
});
```
In Teams, send any message to start sign-in. After sign-in succeeds, the bot calls `GET /me` through Microsoft Graph and replies with the signed-in user's display name.
18 changes: 18 additions & 0 deletions examples/http-adapters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,24 @@ An adapter bridges your HTTP framework with teams.ts. You create your server, pa
- **[hono/](./hono/)** - Build a custom adapter and manage the lifecycle yourself
- **[fastify/](./fastify/)** - Build a custom adapter and let App manage its lifecycle

## Teams CLI

Use the official Teams CLI (`@microsoft/teams.cli`) to create and manage the Teams app for this sample:

```bash
npm install -g @microsoft/teams.cli
teams --version
Comment thread
heyitsaamir marked this conversation as resolved.
teams login
```

Expose this sample's local `/api/messages` endpoint with a tunnel, then create the Teams app:

```bash
teams app create --name "http-adapters" --endpoint "https://<your-tunnel>/api/messages" --env .env --json
```

The CLI writes `CLIENT_ID`, `CLIENT_SECRET`, and `TENANT_ID` to your `.env` file and prints an install link for Teams.

## Running

```bash
Expand Down
18 changes: 18 additions & 0 deletions examples/mcp-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@ Teams AAD user id of someone in the same tenant. For the simplest setup,
message the bot once with a real user, then read the user id off the first
`message` activity in the server log and use that.

## Teams CLI

Use the official Teams CLI (`@microsoft/teams.cli`) to create and manage the Teams app for this sample:

```bash
npm install -g @microsoft/teams.cli
teams --version
Comment thread
heyitsaamir marked this conversation as resolved.
teams login
```

Expose this sample's local `/api/messages` endpoint with a tunnel, then create the Teams app:

```bash
teams app create --name "mcp-server" --endpoint "https://<your-tunnel>/api/messages" --env .env --json
```

The CLI writes `CLIENT_ID`, `CLIENT_SECRET`, and `TENANT_ID` to your `.env` file and prints an install link for Teams.

## Run

```bash
Expand Down
Loading
Loading