Skip to content

Teams Agent

Where: The Teams agent installation package and its setup script, the Azure portal (your App Service), and Settings › Agents in the Tursio portal
Who can use it: The person installing the Teams agent, with access to its Azure subscription and Microsoft 365 tenant. Turning on Teams access control in Tursio needs an Admin or Owner.

Preflight

preflight.sh (Linux/macOS) and preflight.ps1 (Windows) check your machine and accounts before you run setup. Find your failed check below, apply the fix, and run preflight again.

How preflight works

Preflight only reads. It installs nothing and creates nothing in Azure or Microsoft 365. Run it, fix every FAIL, and run it again. Then run setup.sh / setup.ps1. Setup does not run preflight for you.

Checks run in stages. A failed stage stops the run, so later checks stay hidden until you fix it. WARN never blocks.

Stage Check Passes when If not
Prerequisites python3, node, npm, az, atk Command found. Version printed, no minimum enforced FAIL, stop. Tools not installed
Prerequisites PowerShell policy (Windows) Not Restricted FAIL. PowerShell policy
Auth Azure login az account show works FAIL, stop. Azure login
Auth Teams/M365 login atk auth list shows an account FAIL, stop. M365 login
Auth Azure tenant Active subscription tenant = tenant of the first subscription in az account list FAIL, stop. Azure tenant mismatch
Permissions Azure RBAC Owner or Contributor on the subscription (direct assignment) FAIL, or WARN. Azure RBAC
Permissions Entra ID app registration Application Administrator or Global Administrator FAIL. Entra ID app registration
Permissions Teams publish Teams Administrator or Global Administrator FAIL. Teams publish role
Environment npm global bin Folder is on PATH WARN. Warnings
Environment Proxy env vars HTTP_PROXY / HTTPS_PROXY / NO_PROXY not set WARN. Warnings

On Windows the last stage is called Windows QA, and there is no separate npm row. A tool that is installed but missing from the saved PATH, or hidden behind the Windows Store python alias, shows WARN instead of OK. Same checks otherwise.

The run ends with PASS (no FAIL, WARN allowed) or FAIL, plus OK / FAIL / WARN counts. The exit code is 0 either way, so read the summary line.

Not checked: MCP URL reachable, Tursio API key valid, OpenAI key or model valid, Azure name or quota limits.

Reading the output

All pass (Windows) Missing tools stop the run (Linux)
Preflight passing on Windows Preflight stopping on missing tools on Linux
Every row is OK. The summary reads PASS, ready to run setup.ps1. npm and atk are missing. Preflight prints STOP and skips Auth and Permissions. Install them and run again.

Fixes

Tools not installed

Tool Install
python3 / python Python 3.11+. Linux/macOS: python.org/downloads. Windows: python-3.12.10-amd64.exe, tick Add Python to PATH and Install for all users
node, npm Node.js 18+ from nodejs.org/en/download. npm comes with it
az Azure CLI: aka.ms/installazurecli. Check with az --version
atk npm install -g @microsoft/m365agentstoolkit-cli@1.1.17

On Windows, if python is still not found, go to Settings › Apps › Advanced app settings › App execution aliases and turn off the python.exe store alias.

Old teamsapp CLI installed? Remove it before you install atk. Both packages install a command named teamsapp:

npm uninstall -g @microsoft/teamsapp-cli
setup.sh and setup.ps1 remove it for you if found.

PowerShell policy (Windows)

The execution policy is Restricted, which blocks scripts. Run:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Run preflight again.

Azure login

az login --use-device-code
Follow the device-code prompt.

M365 login

atk auth login m365
A browser opens. Sign in with your Microsoft 365 account.

Azure tenant mismatch

The tenant of your active subscription differs from the tenant of the first subscription in az account list. Preflight treats the first one as expected.

  1. List your subscriptions: az account list --output table
  2. Set the right one: az account set --subscription <subscription-id>
  3. Run preflight again.

Azure RBAC

Your account lacks Contributor or Owner on the subscription. Preflight checks the subscription in AZURE_SUBSCRIPTION_ID in env/.env.dev, or your active one if that isn't set. It sees roles assigned directly to you. A role granted only through a group may not show.

  • Contributor: enough for most installs.
  • Owner: needed only if you also manage role assignments.

Ask your Azure admin to assign it in Azure Portal › Subscriptions › [subscription] › Access control (IAM) › Add role assignment.

WARN, not FAIL: could not query role assignments (run az login --use-device-code, then run preflight again) or no subscription found (run az account set --subscription <id>, then run preflight again).

Entra ID app registration

Your account lacks Application Administrator (or Global Administrator) in Entra ID. Ask your Entra admin to assign it in Azure Portal › Microsoft Entra ID › Roles and administrators › Application Administrator › Add assignments.

Teams publish role

Publishing to the org catalog needs Teams Administrator (or Global Administrator). Ask your Microsoft 365 admin to assign it in Microsoft 365 admin center › Roles › Role assignments › Teams Administrator.

If only one person may upload apps, run setup with --skip-publish (-SkipPublish on Windows) and give the package zip to that person.

Role check fails but you hold the role

Preflight reads your directory roles from Microsoft Graph. If that call fails, the role list is empty and both role checks report FAIL. Common causes:

  • You're not signed in to Azure CLI. Run az login --use-device-code.
  • A conditional-access policy blocks the Graph call.
  • A transient network or token problem.

Test the call yourself:

az rest --method GET --url "https://graph.microsoft.com/v1.0/me/transitiveMemberOf/microsoft.graph.directoryRole?\$select=displayName" --query "value[].displayName" -o tsv
If it lists your roles, you have them. If it shows an error, fix that and run preflight again.

Warnings

Warnings don't stop the install.

  • npm global bin: npm's global folder may not be on PATH. Add it and open a new terminal. If atk isn't found after you install it, this is the cause.
  • Proxy env vars: HTTP_PROXY, HTTPS_PROXY or NO_PROXY is set. This may break az, npm, and atk. If installs time out, unset them for the run or allow the Microsoft endpoints.

After preflight

Preflight doesn't check or create any of this. Later, setup.sh / setup.ps1 builds four things in one Azure resource group. All names start with bot + your resource suffix (for example, acme gives botacme). The suffix uses lowercase letters and digits, and the whole name is 4 to 20 chars. Pick it once: changing it later makes a second deployment, not a rename. The region is westus2.

# Azure resource Name What it is for
1 Managed identity (user-assigned) bot<suffix> Bot identity. Its client ID is the bot app ID. No password to store or rotate
2 App Service plan (Linux) bot<suffix> Compute. Size B2. Run one instance only: the agent keeps schedules and chat history itself
3 Web App bot<suffix> Runs the agent (python app.py, Python 3.12, always on). Listens on /api/messages. Holds all settings
4 Azure Bot bot<suffix> Front door for Teams. Plan F0, user-assigned identity, Teams channel on. Points to the Web App

In Microsoft 365, setup creates one Teams app, packages it, and publishes it to the org catalog.

You bring these (preflight does not check them):

  • Tursio MCP server: a public https URL ending in /mcp, reachable from Azure.
  • Tursio API key: a token from an API agent in the Tursio portal, under Settings › Agents › API Agent. See Add an API agent and token.
  • OpenAI model: Azure OpenAI (endpoint, key, deployment name) or standard OpenAI (key, model id). Use gpt-5 or later. Don't use -chat models: they fail while SHOW_REASONING is on (the setup default).

Setup creates no database, storage account, Key Vault or App Insights.

Various components

Resources, identity and settings
Teams user
   |  message
Teams (Microsoft 365)  <-- Teams app (manifest, bot ID = identity client ID)
   |
Azure Bot  (Teams channel)
   |  HTTPS POST  https://bot<suffix>.azurewebsites.net/api/messages
Web App  bot<suffix>  <-- runs under managed identity bot<suffix>
   |-- OpenAI / Azure OpenAI   (OPENAI_API_KEY or AZURE_OPENAI_API_KEY + ENDPOINT, OPENAI_MODEL_NAME)
   |-- Tursio MCP server       (MCP_SERVER_URL, Authorization: Bearer TURSIO_API_KEY, X-Tursio-User)
        |
     Tursio data
  • Azure Bot and Web App share one identity. Bot app ID = identity client ID. The Web App gets the same client ID and tenant ID in CONNECTIONS__SERVICE_CONNECTION__SETTINGS__*, auth type UserManagedIdentity, empty secret. That is how the Web App proves it is the bot.
  • Azure Bot endpoint = Web App host + /api/messages. Setup checks it after deploy and fixes it with az bot update if wrong.
  • Web App settings carry the rest: model, MCP URL, Tursio API key, agent name (BRAND_NAME), SCHEDULE_TIMEZONE, SHOW_REASONING, REASONING_EFFORT.
  • Every MCP call uses one shared API key as bearer. The Teams user's name and Entra object ID go in the request metadata and in the X-Tursio-User header.
  • Keys are plain App Service settings. Limit who can access the resource group.

Setup steps

Setup only checks that python3, node, and az are on PATH, and asks you to run preflight if they aren't.

  1. Answer the questions: agent name, Teams app suffix, resource suffix, MCP URL, Tursio API key, OpenAI provider, key, model, schedule timezone.
  2. Sign in: az login, pick a subscription, then atk auth login m365.
  3. Provision: atk provision creates the Teams app, the resource group, and the four resources. It's skipped on Redeploy to existing resource group.
  4. Deploy: atk deploy pushes the zip, then setup checks the bot endpoint.
  5. Package and publish: atk package, then atk publish. --skip-publish (-SkipPublish on Windows) stops after package.

setup.ps1 banner, questions and configuration summary The start of setup.ps1. The banner says to run preflight first. Saved answers show in brackets, and Enter keeps them. Setup prints a summary and waits for y before it changes anything.

Configure

The Tursio agent for Microsoft Teams runs in your own Azure subscription, with your model and your Tursio server, and works with its default settings as soon as it is installed. Afterwards you can change what it is called, which prompts it suggests, how long it waits, and how it answers. With Teams access control on, a person in Teams sees only the data they can see in the Tursio portal.

Installing for the first time?

The architecture, security model, prerequisites, and deployment steps are in MCP server. If the setup script's preflight check fails, see Preflight. To use the agent, see Use Tursio in Teams.

Overview

What Where you change it When it applies
MCP server, API keys, model, agent name, Teams app name, schedule timezone The setup script after you re-run the script and redeploy
Who can use the agent, and which data they see Settings › Agents › Authorization Agent and the Access Control tab in Tursio on the user's next question
Icon, suggested prompts appPackage/manifest.json in your installation package after republishing and admin approval
Display detail, timeouts, queue and scheduling limits Azure portal → your App Service → Environment variables after a short restart
The agent's instructions instructions.txt in your installation package after redeploying

Most deployments only touch the setup script and Tursio access.

Install settings

The setup script asks for these settings and remembers your answers. Press Enter at a prompt to keep the current value.

  1. Run the setup script from your installation package.
  2. Choose "Redeploy to existing resource group" when it asks. This updates your deployment in place without recreating Azure resources.
  3. Change the answers you need, and press Enter for the rest.
  4. Check the configuration summary and confirm it.
Setup script prompts
Setting Notes
Agent name The name the agent goes by in Teams: its greeting, its progress messages, the Show Tursio's work panel, the tool labels in that panel, and its Teams app description. Defaults to "Tursio".
Teams app name The name Teams shows in the admin center and app store. Leave blank to use the agent name. Set it only when you run more than one agent and each needs its own Teams app, for example a pilot app alongside a production one. Teams allows at most 30 characters.
Azure resource suffix Names your Azure resources (acme produces botacme). Lower-case letters and digits only. Choose this once. Changing it later and reinstalling creates a second, separate deployment rather than renaming the first.
MCP server URL Your Tursio MCP server address, for example https://mcp.yourcompany.com/mcp.
Tursio API key A token from an API agent in the Tursio portal, under Settings › Agents › API Agent. See Add an API agent and token.
OpenAI provider and key Standard OpenAI or Azure OpenAI. Azure also asks for your endpoint URL.
Model Your Azure OpenAI deployment name, or a standard OpenAI model id. Defaults to gpt-5.2. Use a reasoning model (gpt-5 or later). Chat variants such as gpt-4o fail while SHOW_REASONING is true.
Schedule timezone Sets SCHEDULE_TIMEZONE (see Runtime settings). The script suggests the value already set, or this machine's timezone, and asks you to confirm. Enter a standard zone name such as Europe/London to change it.

The setup script also sets SHOW_REASONING to true and REASONING_EFFORT to medium without asking (see Runtime settings).

Hosting size. The Azure App Service plan defaults to B2, which suits most deployments. If you expect heavy use, raise the plan size before installing. Run a single instance. The agent tracks schedule timing and conversation history itself, so scaling out to multiple instances is not supported.

Permissions

With Teams access control on, the Teams agent answers only for people who have Tursio access, and only from the databases they've been granted. See Access Control for what changes for Teams users.

  1. Update the Teams agent and your MCP server to the current release. Re-run the setup script and choose to redeploy. An older agent or MCP server doesn't send the Teams user's Microsoft Entra identity, and Teams users then get a message that the agent is out of date.
  2. Set up the Authorization agent in Settings › Agents, if you haven't. See Authorization Agent.
  3. Add the application permissions User.Read.All and GroupMember.Read.All to that Entra app, and grant admin consent. Tursio uses them to look up each Teams user and their groups.
  4. Turn on Teams access control on the Authorization agent and save. See Teams access control.
  5. Add the people who use Teams in All Users with the email of their Microsoft account, or add an Entra group they belong to.
  6. Grant each user or group their databases on the Access Control tab.

App listing

  1. Edit appPackage/manifest.json in your installation package. The fields are listed below.
  2. Increase version (for example 1.0.8 → 1.0.9). Teams rejects an update that reuses a version number.
  3. Re-run the setup script and choose to redeploy. It publishes the update.
  4. Approve the update in the Teams admin center, under Manage apps. Users receive the new listing without reinstalling.
Manifest fields
Field Notes
name.short, name.full What users see and search for in Teams. Filled in from the Teams app name setup answer (or the agent name). Change it by re-running the setup script, not by editing the manifest.
description.short, description.full The listing text in the Teams app store. Templated with the Agent name setup answer. Change the name by re-running the setup script.
icons.color, icons.outline Replace the two image files in the same folder to use your own branding: a 192×192 color icon and a 32×32 transparent outline icon.
developer The publisher name and the privacy and terms URLs shown in the listing.
bots[0].commandLists[].commands The suggested prompts offered to users in a new chat. Replacing the generic examples with questions about your data, such as "Top 10 customers by revenue this quarter", tells new users what the agent can answer. Up to 10 prompts.
bots[0].scopes Where the agent may be used: personal (one-to-one chat), team, groupChat, and copilot for Microsoft 365 Copilot. Remove any you do not want to offer.
version Increase this every time you republish.

Runtime settings

These live in Azure as application settings and all have working defaults, so a new deployment needs none of them. Set one only when you want to change what it controls.

  1. Open your App Service in the Azure portal.
  2. Go to Settings › Environment variables › App settings.
  3. Select + Add, enter the setting name and value, and select Save.

Saving restarts the app, so expect a few seconds of unavailability. If a value is invalid, the app doesn't restart. See Troubleshooting.

Detail shown while the agent works
Setting Default Effect
SHOW_TOOL_PROGRESS true Shows live progress as the agent works, and attaches a collapsed Show Tursio's work panel under each answer listing the steps taken and how long each took. The panel uses your agent name. Set to false for a plainer experience.
SHOW_REASONING true (set by the setup script) Also includes a summary of the model's reasoning in that panel. Adds noticeable delay and cost, and needs a model that supports reasoning. Set to false to use a chat model such as gpt-4o.
REASONING_EFFORT medium (set by the setup script) none, low, medium, high, or xhigh. Only has an effect when SHOW_REASONING is true. Left unset, current models often produce no summary at all, so keep medium if you want reasoning shown consistently.
Timeouts, queue, and long conversations
Setting Default Effect
MCP_REQUEST_TIMEOUT_SECONDS 180 How long the agent waits for one request to your Tursio server. Raise this if your database has slow queries and users see timeouts on questions that legitimately take longer.
BACKGROUND_RUN_TIMEOUT_SECONDS 900 (15 min) Overall limit for one question. Past this the agent stops and asks the user to narrow the question. Multiples of 60 read best, because the message quotes the limit in whole minutes.
QUESTION_QUEUE_MAX 3 How many questions can wait while the agent is still answering one in the same chat. 0 turns the queue off: a busy chat then gets a status message only.
COMPACT_THRESHOLD_TOKENS 100000 Size past which the agent condenses the earlier part of a long conversation into a summary. 0 turns this off.
Scheduled questions

Users can ask the agent to run a question on a schedule, such as "every weekday at 8am". See Schedule a question.

Setting Default Effect
SCHEDULE_TIMEZONE Your answer at install time (America/Los_Angeles if unset) Timezone used when a user gives a time without naming one ("every day at 9am"). Use a standard zone name such as America/New_York, Europe/London, or Asia/Kolkata. A user who names a zone ("9am ET") always gets that zone.
SCHEDULE_MAX_CONCURRENT_RUNS 4 How many scheduled questions may run at the same moment. Round times like "9am daily" make simultaneous runs common, and each one costs an AI call plus a database query, so this keeps the deployment inside your AI provider's rate limit. Lower it if you see rate-limit errors. Raise it only if your quota is generous.
MAX_SCHEDULES_PER_CONVERSATION 10 Active schedules one chat can hold.
MAX_SCHEDULES_TOTAL 100 Active schedules across all chats.
SCHEDULE_MAX_CONSECUTIVE_FAILURES 3 Failed runs in a row after which a recurring schedule is paused, so it stops posting errors.

Schedules are stored durably and survive restarts and updates.

Change the connection or model without reinstalling

MCP_SERVER_URL, TURSIO_API_KEY, OPENAI_MODEL_NAME, AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_KEY, and OPENAI_API_KEY can also be updated in the App Service settings, for example after rotating a key. Make the same change in the setup script next time you run it, or your older answer is restored.

The same applies to SCHEDULE_TIMEZONE, SHOW_REASONING, and REASONING_EFFORT: re-running the setup script re-applies its saved values. Change the timezone through the setup prompt, and the two reasoning settings in env/.env.dev in your installation package, so a later redeploy keeps them.

Rename individual tool labels

The agent name already renames the tool labels in the Show Tursio's work panel. To give a tool a different label, add TOOL_DISPLAY_NAMES to env/.env.dev as comma-separated real_name=Shown Name pairs, then re-run the setup script:

TOOL_DISPLAY_NAMES=semantic_context=schema_lookup,generate_card=chart

This changes only what users see. A malformed entry stops the app from starting.

Modifying agent instructions

instructions.txt in your installation package is the agent's brief: its persona, its formatting rules, and how it uses your Tursio data. It is plain text and you may edit it. The persona uses your agent name.

Edits here affect answer quality directly and are easy to get wrong. Change one thing at a time.

  1. Keep a copy of the original file.
  2. Edit instructions.txt.
  3. Re-run the setup script and choose to redeploy.
  4. Test with real questions in Teams.

Good candidates for editing:

  • Tone and persona: the opening sentence.
  • Your vocabulary: a short glossary of your own terms, for example "active accounts" means accounts with a balance greater than zero.
  • Formatting preferences: how strongly the agent prefers tables over charts, and how detailed its written summary should be.
  • House rules: for example, always state the date range an answer covers.

Leave these parts alone unless Tursio advises otherwise. They are wiring, not style:

  • The order in which the agent uses its tools. It stops working correctly without this.
  • The list of chart types. The agent can only draw horizontal bar, vertical bar, line, and pie charts, plus tables. Naming any other type causes failures.
  • The instruction not to show SQL in answers, if you want queries kept out of view.
  • The scheduling paragraph, which makes the agent describe a schedule and wait for confirmation instead of creating one silently.

Troubleshooting

Symptom Cause What to do
The app does not restart after a settings change An invalid value is rejected at startup by design Open Log stream on the App Service to see which setting is at fault, then correct it. Usual causes: text in a numeric setting, an unrecognized REASONING_EFFORT value, a malformed TOOL_DISPLAY_NAMES entry, or an empty Tursio API key.
Every question fails, but the app is running The Tursio server URL is wrong or unreachable Confirm the URL ends in /mcp and is reachable from Azure.
Timeouts on questions that are slow but valid The query exceeds the request timeout Raise MCP_REQUEST_TIMEOUT_SECONDS.
SHOW_REASONING is on but no reasoning appears The model returned no summary. Reasoning summaries need a capable model, and standard OpenAI also needs a verified organization Check that REASONING_EFFORT is medium (the setup default) rather than none, and confirm your model and account support reasoning summaries.
Rate-limit errors when several schedules run together More concurrent runs than your AI quota allows Lower SCHEDULE_MAX_CONCURRENT_RUNS.
Suggested prompts unchanged after editing the manifest The version number was not increased, or the update is not approved yet Increase version, republish, and have an administrator approve it.
No messages reach the agent right after installing Normal Teams propagation delay Wait 5–10 minutes. Do not reinstall or delete the bot registration.
Teams users are told the agent is out of date Teams access control is on, but the Teams agent or MCP server is from an earlier release Update both. See Permissions.
Teams users are told Tursio can't verify their access until its setup is fixed The Authorization agent can't look users up in Microsoft Entra Check the Entra app, its client secret, and admin consent for User.Read.All and GroupMember.Read.All.
A Teams user is told they don't have access yet No Tursio user or Entra group matches them Add them in All Users.

Failures during installation, before the agent is deployed, are covered in Preflight.

Tips and limits

  • Run the setup script again for any install-time change. It keeps your earlier answers.
  • Pick the Azure resource suffix once. A new suffix creates a second deployment.
  • Keep the agent name and the Teams app name to 30 characters or fewer.
  • Run one App Service instance. Scaling out isn't supported.
  • Increase the manifest version every time you republish.
  • Teams doesn't let a reply keep updating indefinitely. A question still running after about 90 seconds gets a "⏳ Still working on this — I'll post the result here when it's ready." notice, and the finished answer arrives as a follow-up message in the same chat. This is normal, and it lets long questions complete instead of fail.
  • Teams access control needs a current Teams agent and MCP server, the Authorization agent, and the User.Read.All and GroupMember.Read.All application permissions.