Setup Guide

MS Teams Setup

Overview

Citadel can send notifications as 1:1 Microsoft Teams messages from a bot. Setting it up takes four things: an Entra app registration, an Azure Bot with the Teams channel, a Teams app installed for the recipients, and four Citadel settings.

For each recipient, Citadel:

  1. gets a token from Entra for the Bot Framework, with the app registration's client id and secret;

  2. opens (or reuses) the personal chat between the bot and the user (POST v3/conversations);

  3. posts the rendered markdown message into it (POST v3/conversations/{id}/activities).

The bot only sends. It receives no messages, so it needs no messaging endpoint, no hosting and no Microsoft Graph permission. Recipients are identified by their Entra object id, not their email.

Prerequisites

The app registration, the Azure Bot and every recipient must be in the same Entra tenant: the bot is single-tenant.

Who / what

Needed for

An Entra role that can create app registrations (e.g. Application Developer)

Step 1, the app registration

An Azure subscription and resource group, with Contributor on it

Step 3, the Azure Bot resource

Teams Administrator, or a tenant that allows custom app upload

Step 4, installing the app for users

Citadel administrator on the tenant

Citadel settings and notification definitions

A Citadel version that includes Microsoft Teams notifications

The Teams channel itself

Azure and Teams setup

Steps 1 to 4 are done once per Entra tenant. Keep the tenant id, client id and secret value from steps 1 and 2: Citadel needs them.

Step 1 — Create the app registration

Azure portal → Microsoft Entra ID → App registrations → New registration.

Field

Value

Name

e.g. Memority Teams Notifications (users see the name from the Teams manifest, not this one)

Supported account types

Accounts in this organizational directory only (Single tenant)

Redirect URI

leave empty

Click Register. On the Overview page, note:

  • Application (client) ID → Citadel setting ntf.teams.clientId. It is also the bot id.

  • Directory (tenant) ID → Citadel setting ntf.teams.tenantId.

No API permission is needed: the token is issued for the Bot Framework (<https://api.botframework.com/.default),> not for Microsoft Graph. You can remove the default User.Read permission.

Step 2 — Create a client secret

App registration → Certificates & secrets → Client secrets → New client secret.

  • Description: e.g. memority-ntf.

  • Expires: per your policy (24 months max). Put the expiry date in a calendar: once it expires, every Teams notification fails with a configuration error.

Copy the Value column right away; it is shown only once. Do not copy the Secret ID. The Value goes into ntf.teams.clientSecret.

Step 3 — Create the Azure Bot resource

Azure portal → Create a resource → Azure Bot → Create.

Field

Value

Bot handle

any unique name, e.g. memority-citadel-ntf

Subscription / Resource group

yours

Data residency

Global (or Regional if required)

Pricing tier

Standard or Free (F0). Teams is a standard channel, so F0 has no message cost.

Type of App

Single Tenant

Creation type

Use existing app registration

App ID

the Application (client) ID from step 1

App tenant ID

the Directory (tenant) ID from step 1

Review + create → Create. Then, on the new bot resource:

  1. Configuration: leave the Messaging endpoint empty. If the portal insists, any <https://> URL works; it is never called.

  2. Channels → Microsoft Teams → accept the terms → Microsoft Teams Commercial (or your government cloud) → Apply.

Without the Teams channel, the token is issued but Teams refuses to open chats (401/403).

Step 4 — Build and install the Teams app

Teams lets a bot message a user first only once the bot's app is installed for that user.

4.1 The package. Create a zip with these three files at its root (no parent folder inside the zip):

  • manifest.json

  • color.png — 192×192, full colour

  • outline.png — 32×32, white on transparent

manifest.json, replacing the two placeholders:

JSON
{
  "$schema": "https://developer.microsoft.com/json-schemas/teams/v1.17/MicrosoftTeams.schema.json",
  "manifestVersion": "1.17",
  "version": "1.0.0",
  "id": "<NEW GUID - the Teams app id, NOT the client id>",
  "developer": {
    "name": "Memority",
    "websiteUrl": "https://www.memority.com",
    "privacyUrl": "https://www.memority.com/privacy",
    "termsOfUseUrl": "https://www.memority.com/terms"
  },
  "name": { "short": "Memority", "full": "Memority Teams notifications" },
  "description": {
    "short": "Notifications from Memority",
    "full": "Sends you notifications from Memority (approvals, account events...)."
  },
  "icons": { "color": "color.png", "outline": "outline.png" },
  "accentColor": "#FFFFFF",
  "bots": [
    {
      "botId": "<APPLICATION (CLIENT) ID from step 1>",
      "scopes": ["personal"],
      "isNotificationOnly": true,
      "supportsFiles": false
    }
  ],
  "permissions": ["identity"],
  "validDomains": []
}
  • id: a new GUID (uuidgen). Keep it: later versions of the package reuse it with a higher version.

  • botId must equal the client id, or messages are rejected.

  • isNotificationOnly: true hides the compose box, so users can't write to a bot that never answers.

  • Users see name.short as the bot's name in Teams.

The Teams Developer Portal → Apps → Import app validates the package.

4.2 Install it — production, in the Teams admin center:

  1. Teams apps → Manage apps → Upload new app → select the zip.

  2. Check the app's status is Allowed and that permission policies don't block custom apps.

  3. Teams apps → Setup policies → Global (Org-wide default), or the policy of the target users → Installed apps → Add apps → add the app → Save.

Policy propagation can take several hours. Until the app is installed for a user, sends to that user are skipped as rejected.

4.2 Install it — development, for yourself only: Teams → Apps → Manage your apps → Upload an app → Upload a custom app. This needs Upload custom apps enabled for your account.

Citadel settings

Set these per tenant in the administration settings. Changes apply to the next notification; no restart is needed.

Setting

Value

ntf.teams.tenantId

Directory (tenant) ID, step 1

ntf.teams.clientId

Application (client) ID, step 1

ntf.teams.clientSecret

the secret Value, step 2 (stored encrypted)

ntf.teams.serviceUrl

keep the default <https://smba.trafficmanager.net/teams/> for the commercial cloud

  • Leave tenant id, client id and secret all empty to disable the channel for the tenant. Filling only some of them is a configuration error.

  • serviceUrl must be https on a known Bot Connector host, because the bot's token is sent there.

  • GCC uses <https://smba.infra.gcc.teams.microsoft.com/teams/.> GCC High and DoD also need the login.microsoftonline.us login host, which the channel does not support yet.

Recipients

Each recipient is addressed by their Entra object id, a GUID. Their email or UPN does not work.

Where Citadel reads it:

  • Identities: the attribute named by the IDM setting idm.attributes.defaultMappings.teamsId (default attribute id: teamsId). Usually fed by an import or sync from Entra's id field.

  • IDM system user: the BUM setting bum.system.user.teamsId.

  • Quick test: a literal object id as a recipient of a notification definition.

An identity with no teamsId value is skipped as ignored; no call is made for it.

How to find an object id:

  • Portal: Microsoft Entra ID → Users → the user → Object ID.

  • One user: az ad user show --id jdoe@acme.com --query id -o tsv

  • Everyone: az ad user list --query "[].{upn:userPrincipalName,id:id}" -o tsv

Notification definitions

Create them in the administration → Notifications → Microsoft Teams, as for the other channels.

Field

What to enter

Identifier, Name, Description

as usual

Event type

the event that triggers the message

Recipients

actors, resolved to their teamsId

Default language

language used when the recipient's has no content

Contents

one markdown body per language; event variables can be used as in the other channels' templates

Keep bodies to the markdown Teams renders: bold, italics, links, lists. Tables and headings may show as raw symbols in some clients.

Teams definitions can then be picked in workflow user-task notifications and in the sync, replication and account-discovery post-processing definitions. They are also available in import/export and in the XML editor.

Each send is audited as Microsoft Teams Notification Distribution, with the per-recipient result: sent, ignored (no teamsId), rejected (unreachable in Teams) or failed (with the HTTP status and Microsoft error code).

Troubleshooting

Symptom

Cause

Fix

Configuration error, AADSTS700016 (application not found)

wrong client id, or the tenant id isn't the app's home tenant

recheck the step 1 values

Configuration error, AADSTS7000215 (invalid client secret)

Secret ID copied instead of Value, or a typo

new secret, copy the Value

Configuration error, AADSTS7000222 (secret expired)

secret past its expiry

rotate the secret (below)

Configuration error, Bot Connector refused the token (401)

Azure Bot not bound to this app registration, or created multi-tenant

recreate the bot as in step 3

Configuration error on serviceUrl

not https, or host not in the allowed hosts

use the default URL, or extend allowed-service-hosts

Recipient rejected, 403 BotNotInConversationRoster

Teams app not installed for this user yet, or blocked by a policy

step 4.2; allow hours for policy propagation

Recipient rejected, 404

teamsId is not an object id in this tenant (typo, email, guest from another tenant)

fix the attribute value

Recipient failed, other 403

Teams channel not enabled on the bot

step 3, Channels

Recipient ignored

the identity has no teamsId value

fill the attribute, or check the teamsId mapping

Recipient failed, 429

Teams kept throttling after the retries

lower the send rate, or raise max-throttling-retries

Markdown symbols shown raw

Teams renders only a markdown subset

simplify the body

Check the credentials by hand

This separates an Azure problem from a Citadel problem. It runs the same three calls as Citadel.

Bash
TENANT=<tenant id>; CLIENT=<client id>; SECRET='<secret value>'; USER=<recipient object id>
SVC=https://smba.trafficmanager.net/teams

TOKEN=$(curl -s "https://login.microsoftonline.com/$TENANT/oauth2/v2.0/token" \
  -d grant_type=client_credentials -d client_id="$CLIENT" \
  --data-urlencode client_secret="$SECRET" \
  --data-urlencode scope=https://api.botframework.com/.default | jq -r .access_token)

CONV=$(curl -s -X POST "$SVC/v3/conversations" -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
  -d "{\"isGroup\":false,\"bot\":{\"id\":\"28:$CLIENT\"},\"members\":[{\"id\":\"$USER\"}],\"tenantId\":\"$TENANT\",\"channelData\":{\"tenant\":{\"id\":\"$TENANT\"}}}" | jq -r .id)

curl -s -X POST "$SVC/v3/conversations/$CONV/activities" -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
  -d '{"type":"message","textFormat":"markdown","text":"**Hello** from Citadel"}'

Rotate the client secret

  1. App registration → Certificates & secrets → add a new client secret. Several can be valid at once.

  2. Update ntf.teams.clientSecret in Citadel. The next send uses it; no restart.

  3. Once notifications still go out, delete the old secret in Entra.