Microsoft Teams
Configure your Microsoft Teams application to use your workflow within your workspace.
You can deploy your Microsoft Teams bot to Azure using one of two methods:
Automated Deployment (PowerShell)
Deploy a Microsoft Teams bot to Azure using the automated PowerShell deployment script.
Overview
The deploy_teams_bot.ps1 script automates the entire deployment process:
Azure AD App Registration (Single Tenant)
Azure Bot Service resource
Teams app manifest package generation
Optional upload to your organization's Teams app catalog
The script includes pre-flight validation, rollback capabilities, idempotency (safe to re-run), dry-run mode, and comprehensive logging.
Prerequisites
1. Deployment Script
Download deploy_teams_bot.ps1.
2. Required Software
Option A: Azure Cloud Shell (Recommended - No Installation Required)
Navigate to https://shell.azure.com
Select PowerShell environment
Upload the deployment script and icon files
Run the script directly in the cloud shell
Option B: Local Installation
Azure CLI - Install from https://aka.ms/installazurecli
Az PowerShell Module - Install with:
3. Required Permissions
Azure AD: Application Developer or Global Admin
Create app registrations
Azure Subscription: Contributor
Create bot resources
Teams Admin (optional)
Required only for -uploadToOrgCatalog
4. Required Files
Color Icon (color.png)
192x192 pixels, PNG format, max 1000KB
Outline Icon (outline.png)
32x32 pixels, PNG format, white with transparency
Quick Start
Basic Deployment
Using a Configuration File
Create a bot-config.json file:
Run the script:
Script Parameters
Required Parameters
-botName
Azure resource name (3-63 chars, alphanumeric and hyphens, must start with letter)
-resourceGroup
Azure resource group name
-subscriptionId
Azure subscription ID (GUID format)
-messagingEndpoint
HTTPS endpoint for Teams messages (your Stack AI endpoint)
Optional Parameters
-teamsDisplayName
Same as botName
Display name shown in Teams (can include spaces)
-botDescription
"[teamsDisplayName] Teams bot"
Description shown in Teams app listing
-location
westus
Azure region ( westus, or westeurope)
-colorIconPath
color.png
Path to 192x192 color icon
-outlineIconPath
outline.png
Path to 32x32 outline icon
-configFile
-
JSON config file path (CLI params override file values)
-outputFile
-
Save credentials to JSON file
-logFile
-
Save detailed logs for troubleshooting
-uploadToOrgCatalog
$false
Upload to organization's Teams app catalog
-noRollback
$false
Disable automatic rollback on failure
-dryRun
$false
Validate without creating resources
Deployment Steps
1. Prepare Your Environment
Ensure all prerequisites are installed
Prepare your icon files (
color.pngandoutline.png)Gather your Azure subscription details
Copy your messaging endpoint URL from the Stack AI deployment interface
2. Validate Configuration (Dry Run)
Before creating resources, validate your configuration:
The dry run will:
Validate all input parameters
Check prerequisites and permissions
Verify icon files meet requirements
Confirm Azure resource access
3. Run the Deployment
Once validation passes:
4. Save the Credentials
The script displays credentials at completion:
IMPORTANT: Save the Client Secret immediately - you won't be able to see it again!
5. Configure Stack AI
Navigate to your Stack AI bot configuration
Enter the App ID, Tenant ID, and Client Secret
Verify the messaging endpoint matches
6. Upload to Teams
Option A: Organization Catalog (with -uploadToOrgCatalog)
The app is already available:
Open Microsoft Teams
Go to Apps > Built for your org
Find and install your bot
Option B: Manual Upload
Open Microsoft Teams
Go to Apps > Manage your apps > Upload a custom app
Select Upload for [your organization] or Upload for me or my teams
Choose the
[BotName].zipfile
7. Test the Bot
In Teams, start a new chat with your bot
Send a test message
Verify the bot responds correctly
Advanced Usage
Full Deployment with All Options
Updating an Existing Bot
The script is idempotent and can safely update existing resources:
When existing resources are detected:
Type Y to update the existing bot configuration.
Secure Credential Export
Export credentials to a JSON file for programmatic access:
Security Note: Keep this file secure and never commit it to source control!
Rollback Behavior
If deployment fails at any step, the script prompts for rollback:
Type
Yto delete all resources created during this runType
Nto leave resources for manual inspectionUse
-noRollbackflag to disable rollback prompts entirely
Note: The script only rolls back resources it created. Pre-existing resources (like an existing app registration or bot) are never deleted during rollback.
Troubleshooting
View Script Help
View Examples
Manual Deployment
1. Navigate to Azure Portal
Navigate to Azure Portal to create your application.
2. New Registration
Select App registrations and Click on "New Registration" to create a new app.
3. Register Application
Enter the name of your app and select "Accounts in any organizational directory" and click on "Register".
4. Application ID
Your app is registered in Microsoft Entra ID. The app overview page appears.
Copy the Application (client) ID from Microsoft Entra ID, and paste it in your configuration.
5. Add Web Authentication
In the left pane, under Manage, select Authentication. Under Web, select Add URI.
Enter https://token.botframework.com/.auth/web/redirect and Select Save.
6. Configure Redirect URI
Enter the redirect URI and enable Access tokens and ID tokens.
The redirect URI should be: {BASE_INFERENCE_URL}/auth-end
7. Create a client secret
In the left pane, under Manage, select Certificates & secrets.
Under Client secrets, select + New client secret.
The Add a client secret window appears, enter the description and select Add.
Select Copy to clipboard to save the client secret value for further use.
8. Add API permissions
In the left pane, select API permissions.
Select "+ Add a permission", then select Microsoft Graph.
Under "What type of permissions does your application need?", select Application permissions.
Under "Select permissions", expand User and select User.Read.All.
Click "Add permissions" to save the changes.
9. Add Application ID URI
In the left pane, under Manage, select Expose an API.
Update the Application ID URI to
api://api.stack-ai.com/<APP_ID>and select Save.
10. Add a scope
In the left pane, under Manage, select Expose an API.
Select + Add a scope.
Enter access_as_user as the Scope name.
Under Who can consent?, select Admins and users.
Update the values for the rest of the fields as follows:
Enter "Teams can access the user's profile" as Admin consent display name.
Enter "Allows Teams to call the app's web APIs as the current user" as Admin consent description.
Enter "Teams can access the user profile and make requests on the user's behalf" as User consent display name.
Enter "Enable Teams to call this app's APIs with the same rights as the user" as User consent description.
Ensure that State is set to Enabled.
Select Add scope.
11. Add client application
In the left pane, under Manage, select Expose an API.
Under Authorized client applications, select + Add a client application.
Add Teams mobile or desktop and Teams web application:
For Teams mobile or desktop: Enter Client ID as
1fec8e78-bce4-4aaf-ab1b-5451cc387264For Teams web: Enter Client ID as
5e3ce6c0-2b1f-4285-8d4b-75ee78787346
Select the Authorized scopes checkbox.
Select Add application.
12. Create Azure Bot Resource
Go to Home and select + Create a resource
In the search box, enter "Azure Bot" and select Enter
Select Azure Bot, then select Create
For the bot configuration:
Enter a name for your bot in Bot handle
Select your Subscription from the dropdown
Select or create a Resource group
Under Pricing, select "FO Free" plan
For Microsoft App ID, select Type of App as "Single Tenant"
In Creation type, select "Use existing app registration"
Enter the App ID from your previous registration
13. Add a Teams channel
In the left pane, select Channels.
Under Available Channels, select Microsoft Teams.
Select the checkbox to accept the Terms of Service and Apply.
14. Add Messaging Endpoint
In the left pane, under Settings, select Configuration.
Update the Messaging endpoint with the following URL: https://api.stack-ai.com/msft-teams/<YOUR_PROJECT_ID>/messages?api_key=<YOUR_API_KEY>
Replace
<YOUR_PROJECT_ID>with the workflow id in your URL.
Click Apply to save the configuration.
15. Save StackAI Interface
Go back to StackAI's website and save the StackAI interface in the top right corner.

16. Upload App to Teams
Now, go to Microsoft Teams. On the left sidebar, click Apps.

Now, go to 'Manage Your Apps'.

Click, 'Upload an App.' Then, choose an option.
Here, you will be prompted to upload your app's manifest. The manifest file should contain a JSON file, and two .PNG files, named color.png and outline.png. These two images will serve as the icons of your app. The JSON file must be named manifest.json. Feel free to use the following template, replace "botId" with the Microsoft App ID from step 4. "id" can be a randomly generated UUID, but must be unique to each bot you upload to Microsoft Teams.
17. Add App to a Channel
Open a channel where you'd like to use your chatbot. Click on apps.

Select your app and add it to the channel. Now you can reference your bot as if it's a member of your channel by typing @ and the name of your bot.
Don't forget the publish if you make changes to your agent's workflow so that your bot is updated!
Last updated
Was this helpful?

