Skip to content

Microsoft Teams

Where: Menu → Manage → Integrations → Teams, Slack & calendar → Microsoft Teams

Microsoft Teams

The academy as an app in Teams:

  • a tab with each person’s required trainings, and one with their team’s, signed in with Teams;
  • notices in the Teams activity feed (optional);
  • a knowledge bot: people ask their organisation’s documents in a personal chat with the app (optional; needs the knowledge sources and the AI companion).

The app uses your organisation’s own Entra app registration, the one of your Microsoft sign-in. Nothing is registered at Microsoft on the Academy’s side.

The setup happens in four places. Each needs its own admin rights at Microsoft; often several people do one part each.

Step Where Role needed
1 Choose the sign-in and options the academy Administrator of your organisation
2 Expose an API (Application ID URI, scope, Teams as clients) Microsoft Entra admin centre Application Administrator or Cloud Application Administrator, or an owner of the app registration
3 Graph permission TeamsActivity.Send (only for notices) Microsoft Entra admin centre Adding it: as step 2. Granting admin consent: Privileged Role Administrator or Global Administrator (the two roles of step 2 can’t consent to Microsoft Graph application permissions)
4 Azure Bot with the Teams channel (only for the knowledge bot) Azure portal An Azure subscription, and the Azure role Contributor or Owner on the resource group. Registering the provider Microsoft.BotService once needs Contributor on the subscription. These are Azure roles, not Entra roles. Pricing tier F0 and the Teams channel are free.
5 Upload the app package and make it available Teams admin centre Teams Administrator (or Global Administrator)
  1. Set up the Microsoft sign-in under Manage → Sign-in, with your domains proven, if it isn’t there yet (see “Company sign-in”).
  2. Under Microsoft sign-in to use, choose it.
  3. Tick Notices in the Teams activity feed if people should get notices in Teams.
  4. Tick Knowledge bot if people should ask your documents in a chat with the app.
  5. Click Save. The section now shows the values for the next steps: the Application ID URI, the scope, the two Teams client ids and, with the knowledge bot, the messaging endpoint. Keep the page open; each value has to be entered exactly as shown.

In the Microsoft Entra admin centre (entra.microsoft.com):

  1. Go to Applications → App registrations → All applications and open the app registration of your Microsoft sign-in. Its Application (client) ID must be the one the academy shows in the Application ID URI.
  2. Open Expose an API. Next to Application ID URI, click Add (or Edit), paste the URI from step 1 of the academy (api://<your API address>/<client id>) and Save.
  3. Click Add a scope: scope name access_as_user, Who can consent: Admins and users, fill in the display names and descriptions (for example “Access the academy as the user”), state Enabled, then Add scope.
  4. Under Authorized client applications, click Add a client application twice, once for each Teams client id the academy shows (1fec8e78-bce4-4aaf-ab1b-5451cc387264 for the Teams desktop and mobile apps, 5e3ce6c0-2b1f-4285-8d4b-75ee78787346 for Teams on the web). Tick the scope access_as_user each time and click Add application.

3. Microsoft Entra: permission for notices (only with notices)

Section titled “3. Microsoft Entra: permission for notices (only with notices)”
  1. In the same app registration, open API permissions → Add a permission → Microsoft Graph → Application permissions.
  2. Search for TeamsActivity.Send, tick it and click Add permissions.
  3. Click Grant admin consent for and confirm. This needs a Privileged Role Administrator or a Global Administrator. The status of the permission turns to “Granted”.

4. Azure: the bot (only with the knowledge bot)

Section titled “4. Azure: the bot (only with the knowledge bot)”

Teams finds the knowledge bot through an Azure Bot that carries the same client id as your app registration. Without it, or with a bot that has a new app id of its own, Teams answers “Invalid bot” (see “When something goes wrong”).

In the Azure portal (portal.azure.com):

  1. Create a resource, search for Azure Bot, and click Create.
  2. Fill in:
    • Bot handle: a name that is unique worldwide, for example academy-bot-<your organisation>;
    • Subscription and Resource group (a new one is fine);
    • Pricing tier: change it to Free (F0);
    • Type of App: Single Tenant;
    • Creation type: Use existing app registration;
    • App ID: the client id of your app registration; App tenant ID: your directory (tenant) id.
  3. Review + create, then Create. If Azure says the provider Microsoft.BotService isn’t registered, someone with Contributor on the subscription registers it (Subscription → Resource providers → Microsoft.BotService → Register).
  4. Open the new bot → Settings → Configuration. Set Messaging endpoint to the address the academy shows (https://<your API address>/v1/teams/bot/messages) and Apply.
  5. Open Channels, choose Microsoft Teams, accept the terms and Apply. The channel must show as running.

Teams can take a few minutes to see a new bot.

  1. In the academy, click Download the app package. Download it again after every change in the academy: its version goes up each time (shown as Package version).
  2. In the Teams admin centre (admin.teams.microsoft.com), go to Teams apps → Manage apps and choose Upload new app (under Actions), then the package. For an update, open the app in the list and upload the new package there.
  3. Open the app → Users and groups (or Available to) and make it available to everyone, or to the groups that should have it.
  4. If uploads are refused, custom apps are switched off: under Teams apps → Manage apps → Org-wide app settings, allow custom apps.
  1. Click Send me a test notice (with notices) and look in your Teams activity feed. It reaches only people who have opened the app once.
  2. On the sub-tab Where messages go, under How people hear about trainings, choose Microsoft Teams if everyone should hear about trainings there; each person can change it under My account.

Instead of clicking, steps 2 to 5 can be done with PowerShell. These are single commands to copy, not a script: paste each block into the same PowerShell window, check its output, then go on.

Values. Take them from the sub-tab Microsoft Teams of the academy and from your sign-in under Manage → Sign-in:

Terminal window
$TenantId = "<directory (tenant) id>"
$ClientId = "<client id of the Microsoft sign-in's app registration>"
$ApiHost = "api.academy.example.com" # your academy's API address, as the Application ID URI shows it
$IdUri = "api://$ApiHost/$ClientId"
$BotEndpoint = "https://$ApiHost/v1/teams/bot/messages"
$SubscriptionId = "<Azure subscription id>"
$ResourceGroup = "rg-academy"
$BotName = "academy-bot-<short name of your organisation>"
$Package = "$HOME\Downloads\<the downloaded package>.zip"

$IdUri and $BotEndpoint must look exactly as the academy shows them. $BotName must be unique worldwide (letters, digits, -).

Install the modules once:

Terminal window
Install-Module Microsoft.Graph.Authentication, Microsoft.Graph.Applications -Scope CurrentUser
Terminal window
Install-Module Az.Accounts, Az.Resources -Scope CurrentUser
Terminal window
Install-Module MicrosoftTeams -Scope CurrentUser

Step 2: Application ID URI and scope.

Terminal window
Connect-MgGraph -TenantId $TenantId -Scopes "Application.ReadWrite.All","AppRoleAssignment.ReadWrite.All"
Terminal window
$app = Get-MgApplication -Filter "appId eq '$ClientId'"
$app | Format-List DisplayName, AppId, IdentifierUris, SignInAudience

Check that this is the app registration of your Microsoft sign-in before going on.

Terminal window
Update-MgApplication -ApplicationId $app.Id -IdentifierUris (@($app.IdentifierUris) + $IdUri | Select-Object -Unique)
Terminal window
$app = Get-MgApplication -ApplicationId $app.Id
$api = $app.Api
if (-not ($api.Oauth2PermissionScopes | Where-Object Value -eq "access_as_user")) {
$api.Oauth2PermissionScopes += [Microsoft.Graph.PowerShell.Models.MicrosoftGraphPermissionScope]@{
Id = [guid]::NewGuid(); Value = "access_as_user"; Type = "User"; IsEnabled = $true
AdminConsentDisplayName = "Access the academy as the user"; AdminConsentDescription = "Lets Teams sign the user in to the academy."
UserConsentDisplayName = "Access the academy as you"; UserConsentDescription = "Lets Teams sign you in to the academy." }
Update-MgApplication -ApplicationId $app.Id -Api $api
}

Step 2: Teams as authorised clients.

Terminal window
$app = Get-MgApplication -ApplicationId $app.Id
$api = $app.Api
$scopeId = ($api.Oauth2PermissionScopes | Where-Object Value -eq "access_as_user").Id
foreach ($teamsClient in "1fec8e78-bce4-4aaf-ab1b-5451cc387264", "5e3ce6c0-2b1f-4285-8d4b-75ee78787346") {
if (-not ($api.PreAuthorizedApplications | Where-Object AppId -eq $teamsClient)) {
$api.PreAuthorizedApplications += [Microsoft.Graph.PowerShell.Models.MicrosoftGraphPreAuthorizedApplication]@{ AppId = $teamsClient; DelegatedPermissionIds = @($scopeId) }
}
}
Update-MgApplication -ApplicationId $app.Id -Api $api

Check:

Terminal window
(Get-MgApplication -ApplicationId $app.Id).Api | Format-List @{n="Scopes";e={$_.Oauth2PermissionScopes.Value}}, @{n="Clients";e={$_.PreAuthorizedApplications.AppId}}

Step 3: TeamsActivity.Send (only with notices). Adding it needs the roles of step 2:

Terminal window
$graph = Get-MgServicePrincipal -Filter "appId eq '00000003-0000-0000-c000-000000000000'"
$role = $graph.AppRoles | Where-Object Value -eq "TeamsActivity.Send"
$app = Get-MgApplication -ApplicationId $app.Id
$rra = @($app.RequiredResourceAccess)
$g = $rra | Where-Object ResourceAppId -eq $graph.AppId
if (-not $g) { $g = [Microsoft.Graph.PowerShell.Models.MicrosoftGraphRequiredResourceAccess]@{ ResourceAppId = $graph.AppId; ResourceAccess = @() }; $rra += $g }
if (-not ($g.ResourceAccess | Where-Object Id -eq $role.Id)) { $g.ResourceAccess += [Microsoft.Graph.PowerShell.Models.MicrosoftGraphResourceAccess]@{ Id = $role.Id; Type = "Role" } }
Update-MgApplication -ApplicationId $app.Id -RequiredResourceAccess $rra

Admin consent (Privileged Role Administrator or Global Administrator):

Terminal window
$sp = Get-MgServicePrincipal -Filter "appId eq '$ClientId'"
New-MgServicePrincipalAppRoleAssignment -ServicePrincipalId $sp.Id -PrincipalId $sp.Id -ResourceId $graph.Id -AppRoleId $role.Id

Step 4: the Azure Bot (only with the knowledge bot). First look whether there is a bot already, and which app id it carries:

Terminal window
Connect-AzAccount -Tenant $TenantId -Subscription $SubscriptionId
Terminal window
Get-AzResource -ResourceType "Microsoft.BotService/botServices" -ExpandProperties | Select-Object Name, ResourceGroupName, @{n="AppId";e={$_.Properties.msaAppId}}, @{n="Type";e={$_.Properties.msaAppType}}, @{n="Endpoint";e={$_.Properties.endpoint}}
  • No bot whose AppId is your client id: create one with the next blocks.
  • A bot with another AppId (it was created with “Create new Microsoft App ID”): the academy can’t use it. Delete it or leave it, and create a new one with your client id.
Terminal window
Register-AzResourceProvider -ProviderNamespace Microsoft.BotService

Only if the resource group doesn’t exist yet:

Terminal window
New-AzResourceGroup -Name $ResourceGroup -Location westeurope
Terminal window
New-AzResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.BotService/botServices" -ResourceName $BotName -Location global -Kind azurebot -Sku @{ name = "F0" } -Properties @{ displayName = "Academy"; endpoint = $BotEndpoint; msaAppId = $ClientId; msaAppType = "SingleTenant"; msaAppTenantId = $TenantId } -Force

The Teams channel:

Terminal window
New-AzResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.BotService/botServices/channels" -ResourceName "$BotName/MsTeamsChannel" -Location global -Properties @{ channelName = "MsTeamsChannel"; properties = @{ isEnabled = $true } } -Force

Check:

Terminal window
Get-AzResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.BotService/botServices/channels" -ResourceName "$BotName/MsTeamsChannel" -ExpandProperties | Select-Object -ExpandProperty Properties

A new app package isn’t needed if it was downloaded after the knowledge bot was switched on in the academy: the bot id in it is the client id and doesn’t change.

Step 5: the app package.

Terminal window
Connect-MicrosoftTeams -TenantId $TenantId

Is the app there already?

Terminal window
Get-TeamsApp -DistributionMethod organization -DisplayName "<the app's name in the package>"

First upload:

Terminal window
New-TeamsApp -DistributionMethod organization -Path $Package

Update, after changes in the academy:

Terminal window
Set-TeamsApp -Identity "<Id from Get-TeamsApp>" -Path $Package

Making the app available to people isn’t reliable with PowerShell: do it in the Teams admin centre as in step 5 above.

“Invalid bot. Make sure the bot is registered and the Teams channel is enabled.” Teams shows this before a message reaches the academy: it finds no Azure Bot with a Teams channel for the bot id in the package (your client id). The causes, most likely first:

  1. The Azure Bot was created with a new app id instead of the existing app registration. Check with the Get-AzResource command of step 4, or in the bot’s Settings → Configuration (Microsoft App ID).
  2. The Azure Bot is there, but the Microsoft Teams channel wasn’t added.
  3. There is no Azure Bot at all.
  4. Bot and Teams are in different directories (the bot’s tenant id isn’t the tenant of the Teams users).

Only when this message is gone and the bot still doesn’t answer, the messaging endpoint or the client secret is wrong: compare the endpoint with the one the academy shows.

The tab doesn’t sign in. Compare the Application ID URI in Expose an API character by character with the one the academy shows, and check that the scope access_as_user and both Teams client ids are there (step 2).

No notices arrive. The person has to open the app once. Check that TeamsActivity.Send shows “Granted” under API permissions (step 3), then use Send me a test notice.

The upload is refused. Custom apps are switched off for your organisation (step 5.4), or you lack the Teams Administrator role.