Skip to content

Microsoft Teams bot

AVACOM’s Teams bot posts an incident’s root cause to a Teams channel as an Adaptive Card. Its buttons act in AVACOM:

  • Acknowledge marks the incident acknowledged and assigns it to the presser, as the incident page does.
  • Ask a question opens a box. The incident’s assistant answers in the card’s thread, from the incident and its masked RCA.
  • Review the fix posts the fix an operator prepared, step by step, into the thread. That card has Approve (with an optional comment and change ticket) and Reject (with a reason).

The bot differs from the Microsoft Teams provider, which posts the same card through an incoming webhook with no buttons. Both can run side by side.

A Teams user acts as the AVACOM user with the same email address, with that user’s role. The rules are the same as in the app and the API:

Button Needs Admin NOC
Acknowledge write:incident yes no
Ask a question write:incident, as the AI on the incident page yes no
Review the fix read:incident yes yes
Approve, Reject execute:fixes yes, but never a fix they prepared or changed no

What is approved is what was shown:

  • The fix card offers Approve only when it shows every step as it would run: the action, host and command whole (a command of up to 1,000 characters), with nothing masked and no links, and at most 10 steps. Otherwise the card says so, and the fix is approved in AVACOM.
  • The button names the revision of the steps and carries a digest of what the card showed. If someone changed a step since then, the approval is refused and the presser reviews the fix again.
  • Four eyes always hold in Teams: whoever prepared the fix or changed a step cannot approve it, even on a server where AVACOM_FIX_FOUR_EYES=false.

When an approval goes through, the commands run as described in Approving a fix.

A refusal is shown only to the person who pressed the button. What changed (an acknowledged incident, a decided fix) is shown to the whole channel.

  • Every request is checked. The bot answers only requests that carry a Bot Connector token for this bot. The token must name issuer https://api.botframework.com and the bot’s App ID as audience, and be valid now (5 minutes of clock skew). It must be signed with an RSA key that login.botframework.com publishes and endorses for Teams, and its serviceUrl must be the activity’s. There is no switch that turns this off. The activity must come from Teams and from the bank’s own Entra tenant.
  • People come from Teams’ own roster. An activity names only its sender’s Teams id and Entra object id. The bot reads their email, user principal name, tenant and role in Teams from the Bot Connector’s roster with its own token. It requires the same object id, the bank’s tenant and the member role. Guests, anonymous users and a roster entry that does not say never act. The email (or else the user principal name) must match exactly one AVACOM user, ignoring case.
  • Only AVACOM’s buttons. A button’s data (what it acts on) is sealed with a key derived from the bot’s client secret. A card AVACOM did not make, or changed data, acts on nothing. A new client secret makes the buttons of older cards stop working: post the RCA again.
  • Only set-up channels. A button press counts only in a channel that an administrator added as a Microsoft Teams bot provider (below). A card copied into another chat does nothing.
  • Once. A press is acted on once: a replayed or repeated Teams activity is refused.
  • Recorded before it acts. Every button press is written to the bot’s audit trail before anything happens. If it cannot be written, nothing happens. The approval, the status change and the fix’s steps also go to the incident’s own activity, as from the app.
  • Limited. Requests with a valid token are limited per API process, button presses per Teams user a minute, and questions per Teams user an hour (below). A request without a valid token costs a size check and a signature check, and cannot use up what Microsoft’s requests need. Limit callers by address at the edge, where their own address is known: the single sign-on proxy does (10 a second, bursts of 50), and the bank’s own proxy or WAF should for other installs.
  • Masked. Everything the bot posts goes through AVACOM’s masking: passwords, keys, tokens, card numbers, IBANs and email addresses, plus the tenant’s own masks from Settings › AI. The only exception is the names of the AVACOM users who prepared, decided or were assigned. The assistant sees the incident and its RCA (causes, hypotheses, timeline, findings, steps), masked. It never sees evidence records or what a drill-down fetched or queried. Its answer is masked again, and it has no tools, so it cannot act.
  • Sign-in with a user list. The bot finds people in AVACOM’s user list, which database sign-in (AUTH_TYPE=DB) and OAuth2 Proxy sign-in (AUTH_TYPE=OAUTH2PROXY, for example with Entra ID) maintain. With other sign-ins, or without sign-in, the bot acts for no one.
  • With OAuth2 Proxy, roles come from groups at sign-in. AVACOM stores the role a person’s groups gave at their last browser sign-in, and someone removed from every group is refused at sign-in without that changing. So the bot trusts a role only if that sign-in is recent: within AVACOM_TEAMS_BOT_SIGN_IN_MAX_AGE_DAYS (14 days) for most buttons, and within AVACOM_TEAMS_BOT_APPROVER_SIGN_IN_MAX_AGE_HOURS (24 hours) to approve or reject a fix. Someone removed from the admin group loses the approval buttons within a day. Anyone whose sign-in is older is asked to sign in once in the browser.
  • An address Microsoft can reach. Microsoft’s Bot Connector sends each button press to AVACOM over HTTPS from the internet. Allow only POST to the bot’s path below. Azure’s AzureBotService service tag names the senders if the firewall filters by address.

The address to give Microsoft:

Install Messaging endpoint
Production (docker-compose.prod.yml) https://<your domain>/backend/teams/messages
Single sign-on (docker-compose-with-sso.yml) https://<your domain>/v2/teams/messages

With single sign-on, /v2/teams/messages skips the sign-in page, as alert ingestion and the MCP server do (oauth2proxy/nginx.conf.template): the Bot Connector token takes its place.

The bank’s Microsoft 365 administrator does steps 1 to 4, in the bank’s own tenant. AVACOM’s administrator does steps 5 to 8.

  1. Register the app in Entra ID. In the Entra admin center, open App registrations › New registration. Name it AVACOM, choose Accounts in this organizational directory only (single tenant) and register. Note the Application (client) ID and the Directory (tenant) ID. Under Certificates & secrets, create a client secret and copy its value once. The bot needs no API permissions.
  2. Create the Azure Bot. In the Azure portal, create an Azure Bot resource. Choose Single Tenant and Use existing app registration with the IDs from step 1. Under Configuration, set the Messaging endpoint to the address above. Under Channels, add Microsoft Teams.
  3. Make the Teams app. Write a manifest.json (below) with the App ID. Zip it with a 192×192 color.png and a 32×32 white-on-transparent outline.png.
  4. Publish it to the bank’s Teams. In the Teams admin center, open Teams apps › Manage apps › Upload new app and upload the zip. Allow it for the operations staff in the app’s permission policy. Then add it to the team whose channel gets the RCAs (Apps › Manage your apps › Upload an app, or from the team’s Apps tab).
  5. Give AVACOM the registration. Set the three variables below on the API’s server, from the bank’s secret store, and restart the API. Never paste the secret into a chat or a ticket.
  6. Add the channel. In AVACOM, open Providers, choose Microsoft Teams bot and fill in:
    • The Teams channel’s id: in Teams, open the channel’s … › Get link to channel. The id is the part that starts with 19: and ends in @thread.tacv2. You can paste it as the link shows it (19%3a…%40thread.tacv2).
    • The Bot Connector address: https://smba.trafficmanager.net/teams/ unless Microsoft names another for the bank’s region (…/emea/, …/amer/, …/apac/).
  7. Route RCAs to it. On an incident’s Root cause tab, add a route through the Microsoft Teams bot provider, sent by hand or automatically from a severity, as for any RCA channel. A workflow can also post an incident’s root cause through the provider with incident_id.
  8. Check it. Send an incident’s RCA along the route, then press Review the fix as a NOC user and Acknowledge as an administrator. Both presses show up in the audit trail (below).

A minimal manifest.json; replace <APP ID> (twice) and the domain:

{
"$schema": "https://developer.microsoft.com/json-schemas/teams/v1.17/MicrosoftTeams.schema.json",
"manifestVersion": "1.17",
"version": "1.0.0",
"id": "<APP ID>",
"developer": {
"name": "The bank's IT operations",
"websiteUrl": "https://<your domain>",
"privacyUrl": "https://<your domain>",
"termsOfUseUrl": "https://<your domain>"
},
"name": { "short": "AVACOM", "full": "AVACOM incident root causes" },
"description": {
"short": "Root causes of incidents, with buttons that act in AVACOM.",
"full": "Posts an incident's root cause; acknowledge it, ask its assistant and approve or reject its fix."
},
"icons": { "color": "color.png", "outline": "outline.png" },
"accentColor": "#1F4FD8",
"bots": [
{ "botId": "<APP ID>", "scopes": ["team"], "isNotificationOnly": false, "supportsFiles": false }
],
"permissions": ["identity", "messageTeamMembers"],
"validDomains": ["<your domain>"]
}
Variable Default What
AVACOM_TEAMS_BOT_APP_ID (none) The bot’s Microsoft App ID: the app registration’s client ID
AVACOM_TEAMS_BOT_APP_PASSWORD (none) The app registration’s client secret. A secret: set it from the secret store
AVACOM_TEAMS_BOT_TENANT_ID (none) The bank’s Entra tenant ID. Activities from any other tenant are refused
AVACOM_TEAMS_BOT_REQUESTS_PER_MINUTE 300 Requests with a valid Bot Connector token a minute, per API process
AVACOM_TEAMS_BOT_ACTIONS_PER_MINUTE 10 Button presses per Teams user a minute, counted in the audit trail across processes
AVACOM_TEAMS_BOT_QUESTIONS_PER_HOUR 20 Questions to the assistant per Teams user an hour; 0 turns asking off
AVACOM_TEAMS_BOT_SIGN_IN_MAX_AGE_DAYS 14 With OAuth2 Proxy, how old a role may be; 0: any age
AVACOM_TEAMS_BOT_APPROVER_SIGN_IN_MAX_AGE_HOURS 24 The same for approving and rejecting fixes; 0: any age
AVACOM_TEAMS_BOT_SERVICE_HOSTS (none) More Bot Connector hosts the bot may call, besides smba.trafficmanager.net

Without the first three, /teams/messages answers 404 and the provider refuses to post. When the client secret expires, Entra refuses the bot’s sign-in: posts fail, and the provider’s error says so. Rotate the secret before it expires and restart the API; the buttons of cards posted before then stop working, so post the RCAs that are still open again.

Each press is a row in the teamsbotaction table, written before the bot acts:

Column What
pressed_at When (UTC)
teams_user, teams_name The presser’s Entra object ID and Teams display name
avacom_user, role The AVACOM user and role it acted as, once found
action acknowledge, ask, fix, approve, reject, (not an action), or (rate limited)
incident_id, fix_id What it acted on
conversation_id, activity_id The Teams channel and the press
outcome ok, refused, error, rate_limited, or started while it runs. A started row that stays means the API stopped mid-press
detail Why it was refused, or what came of it, masked. A question’s text is recorded masked

Presses refused by the per-minute limit share one (rate limited) row per person a minute, which counts them. There is no retention yet: the rows stay until a database administrator removes old ones.

  • The Bot Framework Emulator is not supported. Its tokens come from another issuer, and the bot accepts the Bot Connector’s only. Tests replay recorded Teams activities signed with a test key instead.
  • Government clouds (GCC High, DoD) and Teams operated by 21Vianet use other token issuers and are not supported.
  • The bot authenticates with a client secret. Certificates and managed identities are not supported yet.
  • The assistant does not remember earlier questions: each question stands alone.
  • Personal chats and group chats with the bot get no RCAs and act on nothing.
What you see Why
Teams says the bot did not answer The messaging endpoint is not reachable from the internet, or the API answers 401/403. The API log says which check refused it (another tenant, audience or service URL)
“This chat is not set up for AVACOM” The channel’s id in the provider is not this channel’s. A new provider takes up to a minute to count
“No AVACOM user has your address” Add the person in AVACOM with their Entra email address, or the address Teams knows them by
“This button was not made by AVACOM, or what it acts on was changed” The card is older than the bot’s current client secret: post the RCA again
“Approve this fix in AVACOM” on the fix card A step is longer than the card shows, has masked parts or a link, or there are more than 10 steps
“Your AVACOM role was last checked more than 14 days ago” OAuth2 Proxy sign-in: the person signs in once in the browser
The provider says “Entra ID refused the bot’s sign-in (401)” The App ID, secret or tenant ID is wrong, or the secret expired
“Teams refused the call (403)” when posting The bot was not added to the team, or the channel’s id is wrong