Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions samples/bot-targeted-messages/M365Agent/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# TeamsFx files
build
appPackage/build
env/.env.*.user
env/.env.local
appsettings.Development.json
.deployment

# User-specific files
*.user
12 changes: 12 additions & 0 deletions samples/bot-targeted-messages/M365Agent/M365Agent.atkproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.TeamsFx.Sdk">
<PropertyGroup Label="Globals">
<ProjectGuid>b069b3bd-f6bc-cc40-82ab-3fcc2ea50fdf</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<None Include="README.md" />
</ItemGroup>
<ItemGroup>
<ProjectCapability Include="ProjectConfigurationsDeclaredDimensions" />
</ItemGroup>
</Project>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 101 additions & 0 deletions samples/bot-targeted-messages/M365Agent/appPackage/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/teams/v1.20/MicrosoftTeams.schema.json",
"version": "1.0.7",
"manifestVersion": "1.20",
"id": "${{TEAMS_APP_ID}}",
"name": {
"short": "targeted-msg-${{APP_NAME_SUFFIX}}",
"full": "Targeted Message Bot"
},
"developer": {
"name": "Microsoft",
"mpnId": "",
"websiteUrl": "https://microsoft.com",
"privacyUrl": "https://privacy.microsoft.com/privacystatement",
"termsOfUseUrl": "https://www.microsoft.com/legal/terms-of-use"
},
"description": {
"short": "Bot for testing targeted messaging in Teams",
"full": "A testing bot to demonstrate and validate targeted messaging capabilities using Teams SDK methods for sending messages to specific users"
},
"icons": {
"outline": "outline.png",
"color": "color.png"
},
"accentColor": "#FFFFFF",
"staticTabs": [
{
"entityId": "conversations",
"scopes": [ "personal" ]
},
{
"entityId": "about",
"scopes": [ "personal" ]
}
],
"bots": [
{
"botId": "${{BOT_ID}}",
"scopes": [ "personal", "team", "groupChat" ],
"supportsFiles": false,
"isNotificationOnly": false,
"supportsVideo": true,
"supportsCalling": true,
"commandLists": [
{
"scopes": [ "team", "groupChat", "personal" ],
"commands": [
{
"title": "help",
"description": "Shows commands list"
},
{
"title": "send-l1",
"description": "Send l1 targeted message"
},
{
"title": "send-l2",
"description": "Send l2 targeted message"
},
{
"title": "send-l1-attachment",
"description": "Send l1 message with attachment"
},
{
"title": "send-l2-attachment",
"description": "Send l2 message with attachment"
},
{
"title": "send-l1-ai-generated-message",
"description": "Send l1 AI-generated message"
},
{
"title": "send-l2-ai-generated-message",
"description": "Send l2 AI-generated message"
},
{
"title": "send-l1-self-mention",
"description": "Send l1 message mentioning yourself"
},
{
"title": "send-l2-self-mention",
"description": "Send l2 message mentioning yourself"
},
{
"title": "send-l1-edit-delete",
"description": "Send message with edit and delete options"
}
]
}
]
}
],
"validDomains": [
"${{BOT_DOMAIN}}",
"*.botframework.com"
],
"webApplicationInfo": {
"id": "${{BOT_ID}}",
"resource": "api://botid-${{BOT_ID}}"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions samples/bot-targeted-messages/M365Agent/env/.env.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file includes environment variables that will be committed to git by default.

# Built-in environment variables
TEAMSFX_ENV=dev
APP_NAME_SUFFIX=dev

# Updating AZURE_SUBSCRIPTION_ID or AZURE_RESOURCE_GROUP_NAME after provision may also require an update to RESOURCE_SUFFIX, because some services require a globally unique name across subscriptions/resource groups.
AZURE_SUBSCRIPTION_ID=
AZURE_RESOURCE_GROUP_NAME=
RESOURCE_SUFFIX=

# Generated during provision, you can also add your own variables.
BOT_ID=
TEAMS_APP_ID=
BOT_AZURE_APP_SERVICE_RESOURCE_ID=
86 changes: 86 additions & 0 deletions samples/bot-targeted-messages/M365Agent/infra/azure.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
@maxLength(20)
@minLength(4)
@description('Used to generate names for all resources in this file')
param resourceBaseName string

param webAppSKU string

@maxLength(42)
param botDisplayName string

param serverfarmsName string = resourceBaseName
param webAppName string = resourceBaseName
param identityName string = resourceBaseName
param location string = resourceGroup().location

resource identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
location: location
name: identityName
}

// Compute resources for your Web App
resource serverfarm 'Microsoft.Web/serverfarms@2021-02-01' = {
kind: 'app'
location: location
name: serverfarmsName
sku: {
name: webAppSKU
}
}

// Web App that hosts your bot
resource webApp 'Microsoft.Web/sites@2021-02-01' = {
kind: 'app'
location: location
name: webAppName
properties: {
serverFarmId: serverfarm.id
httpsOnly: true
siteConfig: {
appSettings: [
{
name: 'WEBSITE_RUN_FROM_PACKAGE'
value: '1'
}
{
name: 'Teams__ClientId'
value: identity.properties.clientId
}
{
name: 'Teams__TenantId'
value: identity.properties.tenantId
}
{
name: 'Teams__BotType'
value: 'UserAssignedMsi'
}
]
ftpsState: 'FtpsOnly'
}
}
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${identity.id}': {}
}
}
}

// Register your web service as a bot with the Bot Framework
module azureBotRegistration './botRegistration/azurebot.bicep' = {
name: 'Azure-Bot-registration'
params: {
resourceBaseName: resourceBaseName
identityClientId: identity.properties.clientId
identityResourceId: identity.id
identityTenantId: identity.properties.tenantId
botAppDomain: webApp.properties.defaultHostName
botDisplayName: botDisplayName
}
}

// The output will be persisted in .env.{envName}. Visit https://aka.ms/teamsfx-actions/arm-deploy for more details.
output BOT_AZURE_APP_SERVICE_RESOURCE_ID string = webApp.id
output BOT_DOMAIN string = webApp.properties.defaultHostName
output BOT_ID string = identity.properties.clientId
output BOT_TENANT_ID string = identity.properties.tenantId
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourceBaseName": {
"value": "bot${{RESOURCE_SUFFIX}}"
},
"webAppSKU": {
"value": "B1"
},
"botDisplayName": {
"value": "TargetedMessage"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@maxLength(20)
@minLength(4)
@description('Used to generate names for all resources in this file')
param resourceBaseName string

@maxLength(42)
param botDisplayName string

param botServiceName string = resourceBaseName
param botServiceSku string = 'F0'
param identityResourceId string
param identityClientId string
param identityTenantId string
param botAppDomain string

// Register your web service as a bot with the Bot Framework
resource botService 'Microsoft.BotService/botServices@2021-03-01' = {
kind: 'azurebot'
location: 'global'
name: botServiceName
properties: {
displayName: botDisplayName
endpoint: 'https://${botAppDomain}/api/messages'
msaAppId: identityClientId
msaAppMSIResourceId: identityResourceId
msaAppTenantId:identityTenantId
msaAppType:'UserAssignedMSI'
}
sku: {
name: botServiceSku
}
}

// Connect the bot service to Microsoft Teams
resource botServiceMsTeamsChannel 'Microsoft.BotService/botServices/channels@2021-03-01' = {
parent: botService
location: 'global'
name: 'MsTeamsChannel'
properties: {
channelName: 'MsTeamsChannel'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The `azurebot.bicep` module is provided to help you create Azure Bot service when you don't use Azure to host your app. If you use Azure as infrastrcture for your app, `azure.bicep` under infra folder already leverages this module to create Azure Bot service for you. You don't need to deploy `azurebot.bicep` again.
25 changes: 25 additions & 0 deletions samples/bot-targeted-messages/M365Agent/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"profiles": {
// Launch project within Microsoft 365 Agents Playground
"Microsoft 365 Agents Playground (browser)": {
"commandName": "Project",
"environmentVariables": {
"UPDATE_TEAMS_APP": "false",
"M365_AGENTS_PLAYGROUND_TARGET_SDK": "teams-ai-v2-dotnet"
},
"launchTestTool": true,
"launchUrl": "http://localhost:56150",
},
// Launch project within Teams
"Microsoft Teams (browser)": {
"commandName": "Project",
"launchUrl": "https://teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&appTenantId=${{TEAMS_APP_TENANT_ID}}&login_hint=${{TEAMSFX_M365_USER_NAME}}",
},
// Launch project within Teams without prepare app dependencies
"Microsoft Teams (browser) (skip update app)": {
"commandName": "Project",
"environmentVariables": { "UPDATE_TEAMS_APP": "false" },
"launchUrl": "https://teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&appTenantId=${{TEAMS_APP_TENANT_ID}}&login_hint=${{TEAMSFX_M365_USER_NAME}}"
},
}
}
77 changes: 77 additions & 0 deletions samples/bot-targeted-messages/M365Agent/m365agents.local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# yaml-language-server: $schema=https://aka.ms/m365-agents-toolkits/v1.11/yaml.schema.json
# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file
# Visit https://aka.ms/teamsfx-actions for details on actions
version: v1.11

provision:
# Creates a Teams app
- uses: teamsApp/create
with:
# Teams app name
name: TargetedMessage${{APP_NAME_SUFFIX}}
# Write the information of created resources into environment file for
# the specified environment variable(s).
writeToEnvironmentFile:
teamsAppId: TEAMS_APP_ID

# Create or reuse an existing Microsoft Entra application for bot.
- uses: aadApp/create
with:
# The Microsoft Entra application's display name
name: TargetedMessage${{APP_NAME_SUFFIX}}
generateClientSecret: true
generateServicePrincipal: true
signInAudience: AzureADMultipleOrgs
writeToEnvironmentFile:
# The Microsoft Entra application's client id created for bot.
clientId: BOT_ID
# The Microsoft Entra application's client secret created for bot.
clientSecret: SECRET_BOT_PASSWORD
# The Microsoft Entra application's object id created for bot.
objectId: BOT_OBJECT_ID

# Generate runtime appsettings to JSON file
- uses: file/createOrUpdateJsonFile
with:
target: ../TargetedMessage/appsettings.Development.json
content:
Teams:
ClientId: ${{BOT_ID}}
ClientSecret: ${{SECRET_BOT_PASSWORD}}
TenantId: ${{TEAMS_APP_TENANT_ID}}

# Create or update the bot registration on dev.botframework.com
- uses: botFramework/create
with:
botId: ${{BOT_ID}}
name: TargetedMessage
messagingEndpoint: ${{BOT_ENDPOINT}}/api/messages
description: ""
channels:
- name: msteams

# Validate using manifest schema
- uses: teamsApp/validateManifest
with:
# Path to manifest template
manifestPath: ./appPackage/manifest.json
# Build Teams app package with latest env value
- uses: teamsApp/zipAppPackage
with:
# Path to manifest template
manifestPath: ./appPackage/manifest.json
outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
outputFolder: ./appPackage/build
# Validate app package using validation rules
- uses: teamsApp/validateAppPackage
with:
# Relative path to this file. This is the path for built zip file.
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip

# Apply the Teams app manifest to an existing Teams app in
# Developer Portal.
# Will use the app id in manifest file to determine which Teams app to update.
- uses: teamsApp/update
with:
# Relative path to this file. This is the path for built zip file.
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
Loading