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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Integration.AspNet.Core;
using Microsoft.Bot.Builder.TraceExtensions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AdaptiveCards" Version="3.0.0" />
<PackageReference Include="AdaptiveCards.Templating" Version="1.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.7" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.19.0" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.19.0" />
<PackageReference Include="AdaptiveCards" Version="3.1.0" />
<PackageReference Include="AdaptiveCards.Templating" Version="2.0.6" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="10.0.5" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.23.1" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.23.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
// Licensed under the MIT License.

using System.Collections.Generic;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Cors.Infrastructure;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Schema;
using Microsoft.Extensions.Logging;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -11,8 +10,6 @@
using Microsoft.Bot.Builder.Dialogs.Choices;
using Microsoft.Bot.Schema;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;

namespace Microsoft.BotBuilderSamples
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
// Licensed under the MIT License.

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Integration.AspNet.Core;
using Microsoft.Bot.Connector.Authentication;
using Microsoft.BotBuilderSamples;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

var builder = WebApplication.CreateBuilder(args);

Expand Down Expand Up @@ -37,23 +35,9 @@

var app = builder.Build();

// Configure the HTTP request pipeline.l
if (!app.Environment.IsDevelopment())
{
app.UseHsts();
}
else
{
app.UseDeveloperExceptionPage();
}

app.UseDefaultFiles()
.UseStaticFiles()
.UseRouting()
.UseAuthorization()
.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
.UseStaticFiles();

app.MapControllers();

app.Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"MicrosoftAppId": "",
"MicrosoftAppPassword": "",
"MicrosoftAppTenantId": "",
"ConnectionName": "",
"MicrosoftAppType": ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ additionalMetadata:
sampleTag: Microsoft-Teams-Samples:bot-all-cards-csharp

environmentFolderPath: ./env

5 changes: 5 additions & 0 deletions samples/TeamsSDK/Archived/bot-all-cards/nodejs/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MicrosoftAppId=
MicrosoftAppPassword=
ConnectionName=
MicrosoftAppType=
MicrosoftAppTenantId=
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"This sample demonstrates using a bot to send multiple card types in Microsoft Teams, including Adaptive, Hero, Thumbnail, and OAuth cards. It covers setup, deployment, and app installation instructions."
],
"creationDateTime": "2023-01-13",
"updateDateTime": "2023-10-10",
"updateDateTime": "2026-04-07",
"products": [
"Teams"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

const { ActivityHandler, MessageFactory, CardFactory } = require('botbuilder');
const { ActionTypes } = require('botframework-schema');
const { ActivityHandler, MessageFactory, CardFactory, ActionTypes } = require('botbuilder');
const AdaptiveCard = require('../resources/adaptiveCard.json');
const Office365ConnectorCard = require('../resources/o365ConnectorCard.json');
const ThumbnailCard = require('../resources/thumbnailCard.json');
const ListCard = require('../resources/listCard.json');
const CollectionCard = require('../resources/collectionsCard.json');
const path = require('path');
const ENV_FILE = path.join(__dirname, '.env');
require('dotenv').config({ path: ENV_FILE });

class BotTypeOfCards extends ActivityHandler {
constructor() {
Expand Down Expand Up @@ -157,13 +153,6 @@ class BotTypeOfCards extends ActivityHandler {
return CardFactory.adaptiveCard(CollectionCard);
}

/**
* Sends a Thumbnail Card.
*/
sendThumbnailCard() {
return CardFactory.thumbnailCard(ThumbnailCard);
}

/**
* Send suggested Cards to the user.
* @param {TurnContext} turnContext A TurnContext instance containing all the data needed for processing this conversation turn.
Expand Down Expand Up @@ -211,9 +200,6 @@ class BotTypeOfCards extends ActivityHandler {
}

async sendWelcomeCard(context, cardActions) {
const initialValue = {
count: 0
};
const card = CardFactory.heroCard(
'Please select a card from given options. ',
'',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ MICROSOFT_APP_TYPE=
MICROSOFT_APP_TENANT_ID=
RESOURCE_SUFFIX=
AZURE_SUBSCRIPTION_ID=
AZURE_RESOURCE_GROUP_NAME=
AZURE_RESOURCE_GROUP_NAME=
APP_NAME_SUFFIX=
Original file line number Diff line number Diff line change
@@ -1,48 +1,34 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// index.js is used to setup and configure your bot

// Import required packages
const path = require('path');
const express = require('express');

// Import required bot services.
// See https://aka.ms/bot-services to learn more about the different parts of a bot.
const {
CloudAdapter,
ConfigurationBotFrameworkAuthentication
} = require('botbuilder');

// Import bot definitions
const { BotTypeOfCards } = require('./bots/botTypeOfCards');

// Read botFilePath and botFileSecret from .env file.
// Read environment variables from .env file.
const ENV_FILE = path.join(__dirname, '.env');
require('dotenv').config({ path: ENV_FILE });
require('dotenv').config({ path: ENV_FILE, quiet: true });

// Create adapter.
// See https://aka.ms/about-bot-adapter to learn more about adapters.
const botFrameworkAuthentication = new ConfigurationBotFrameworkAuthentication(process.env);

const adapter = new CloudAdapter(botFrameworkAuthentication);

adapter.onTurnError = async (context, error) => {
// This check writes out errors to console log .vs. app insights.
// NOTE: In production environment, you should consider logging this to Azure
// application insights.
console.error(`\n [onTurnError] unhandled error: ${ error }`);

// Send a trace activity, which will be displayed in Bot Framework Emulator
await context.sendTraceActivity(
'OnTurnError Trace',
`${ error }`,
'https://www.botframework.com/schemas/error',
'TurnError'
);

// Uncomment below commented line for local debugging.
// await context.sendActivity(`Sorry, it looks like something went wrong. Exception Caught: ${error}`);
// Uncomment below line for local debugging.
// await context.sendActivity(`Sorry, it looks like something went wrong. Exception Caught: ${error}`);
};

// Create bot handlers
Expand All @@ -53,17 +39,12 @@ const server = express();
server.use(express.json());
const port = process.env.port || process.env.PORT || 3978;

server.listen(port, () =>
console.log(`\Bot/ME service listening at http://localhost:${port}`)
server.listen(port, () =>
console.log(`Bot/ME service listening at http://localhost:${port}`)
);
server.use("/Images", express.static(path.resolve(__dirname, 'Images')));

server.get('*', (req, res) => {
res.json({ error: 'Route not found' });
});
server.use('/Images', express.static(path.resolve(__dirname, 'Images')));

// Listen for incoming requests.
server.post('/api/messages', async (req, res) => {
// Route received a request to adapter for processing
await adapter.process(req, res, (context) => botActivityHandler.run(context));
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ param microsoftAppType string
param microsoftAppTenantId string

// Register your web service as a bot with the Bot Framework
resource botService 'Microsoft.BotService/botServices@2021-03-01' = {
resource botService 'Microsoft.BotService/botServices@2023-09-15-preview' = {
kind: 'azurebot'
location: 'global'
name: botServiceName
Expand All @@ -35,7 +35,7 @@ resource botService 'Microsoft.BotService/botServices@2021-03-01' = {
}

// Connect the bot service to Microsoft Teams
resource botServiceMsTeamsChannel 'Microsoft.BotService/botServices/channels@2021-03-01' = {
resource botServiceMsTeamsChannel 'Microsoft.BotService/botServices/channels@2023-09-15-preview' = {
parent: botService
location: 'global'
name: 'MsTeamsChannel'
Expand All @@ -44,7 +44,7 @@ resource botServiceMsTeamsChannel 'Microsoft.BotService/botServices/channels@202
}
}

resource botServiceConnection 'Microsoft.BotService/botServices/connections@2021-03-01' = {
resource botServiceConnection 'Microsoft.BotService/botServices/connections@2023-09-15-preview' = {
parent: botService
name: 'oauthbotsetting'
location: 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourceBaseName": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# yaml-language-server: $schema=https://aka.ms/teams-toolkit/v1.2/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.2

additionalMetadata:
sampleTag: Microsoft-Teams-Samples:bot-all-cards-nodejs

provision:
- uses: aadApp/create
with:
name: bot-all-cards-aad
generateClientSecret: true
signInAudience: "AzureADMyOrg"
writeToEnvironmentFile:
clientId: AAD_APP_CLIENT_ID
clientSecret: SECRET_AAD_APP_CLIENT_SECRET
objectId: AAD_APP_OBJECT_ID
tenantId: AAD_APP_TENANT_ID
authority: AAD_APP_OAUTH_AUTHORITY
authorityHost: AAD_APP_OAUTH_AUTHORITY_HOST

- uses: teamsApp/create
with:
name: bot-all-cards${{APP_NAME_SUFFIX}}
writeToEnvironmentFile:
teamsAppId: TEAMS_APP_ID

- uses: script
with:
run:
echo "::set-teamsfx-env MICROSOFT_APP_TYPE=SingleTenant";
echo "::set-teamsfx-env MICROSOFT_APP_TENANT_ID=${{AAD_APP_TENANT_ID}}";

- uses: arm/deploy
with:
subscriptionId: ${{AZURE_SUBSCRIPTION_ID}}
resourceGroupName: ${{AZURE_RESOURCE_GROUP_NAME}}
templates:
- path: ./infra/azure.bicep
parameters: ./infra/azure.parameters.json
deploymentName: Create-resources-for-bot
bicepCliVersion: v0.9.1 # Teams Toolkit will download this bicep CLI version from github for you, will use bicep CLI in PATH if you remove this config.

# Skip AAD app update for now
# - uses: aadApp/update
# with:
# manifestPath: ./aad.manifest.json
# outputFilePath: ./build/aad.manifest.${{TEAMSFX_ENV}}.json

- uses: teamsApp/validateManifest
with:
manifestPath: ./appManifest/manifest.json

- uses: teamsApp/zipAppPackage
with:
manifestPath: ./appManifest/manifest.json
outputZipPath: ./appManifest/build/appManifest.${{TEAMSFX_ENV}}.zip
outputJsonPath: ./appManifest/build/manifest.${{TEAMSFX_ENV}}.json

- uses: teamsApp/validateAppPackage
with:
appPackagePath: ./appManifest/build/appManifest.${{TEAMSFX_ENV}}.zip

- uses: teamsApp/update
with:
appPackagePath: ./appManifest/build/appManifest.${{TEAMSFX_ENV}}.zip

deploy:
- uses: cli/runNpmCommand
with:
args: install --no-audit

- uses: file/createOrUpdateEnvironmentFile
with:
target: ./.env
envs:
MicrosoftAppId: ${{AAD_APP_CLIENT_ID}}
MicrosoftAppPassword: ${{SECRET_AAD_APP_CLIENT_SECRET}}
MicrosoftAppType: SingleTenant
MicrosoftAppTenantId: ${{AAD_APP_TENANT_ID}}
ConnectionName: ${{CONNECTION_NAME}}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ additionalMetadata:
sampleTag: Microsoft-Teams-Samples:bot-all-cards-nodejs

environmentFolderPath: ./env
projectId:

Loading