From c24b0e4046d258f421c2c3aa96ec4c90fed9f1ce Mon Sep 17 00:00:00 2001 From: Lee Parrish <30470292+LeeParrishMSFT@users.noreply.github.com> Date: Thu, 18 Mar 2021 09:46:23 -0500 Subject: [PATCH] Completed adaptive card sample 07.using-adaptive-cards (#1064) * Completed adaptive card sample * Remove commented code line. --- samples/07.using-adaptive-cards/LICENSE | 21 + samples/07.using-adaptive-cards/README.md | 59 +++ .../template-with-new-rg.json | 291 ++++++++++++ .../template-with-preexisting-rg.json | 259 +++++++++++ samples/07.using-adaptive-cards/pom.xml | 249 +++++++++++ .../usingadaptivecards/Application.java | 67 +++ .../bots/AdaptiveCardsBot.java | 97 ++++ .../main/resources/FlightItineraryCard.json | 204 +++++++++ .../src/main/resources/ImageGalleryCard.json | 60 +++ .../src/main/resources/LargeWeatherCard.json | 205 +++++++++ .../src/main/resources/RestaurantCard.json | 60 +++ .../src/main/resources/SolitaireCard.json | 39 ++ .../src/main/resources/application.properties | 3 + .../src/main/resources/log4j2.json | 18 + .../src/main/webapp/META-INF/MANIFEST.MF | 3 + .../src/main/webapp/WEB-INF/web.xml | 12 + .../src/main/webapp/index.html | 418 ++++++++++++++++++ .../usingadaptivecards/ApplicationTest.java | 19 + 18 files changed, 2084 insertions(+) create mode 100644 samples/07.using-adaptive-cards/LICENSE create mode 100644 samples/07.using-adaptive-cards/README.md create mode 100644 samples/07.using-adaptive-cards/deploymentTemplates/template-with-new-rg.json create mode 100644 samples/07.using-adaptive-cards/deploymentTemplates/template-with-preexisting-rg.json create mode 100644 samples/07.using-adaptive-cards/pom.xml create mode 100644 samples/07.using-adaptive-cards/src/main/java/com/microsoft/bot/sample/usingadaptivecards/Application.java create mode 100644 samples/07.using-adaptive-cards/src/main/java/com/microsoft/bot/sample/usingadaptivecards/bots/AdaptiveCardsBot.java create mode 100644 samples/07.using-adaptive-cards/src/main/resources/FlightItineraryCard.json create mode 100644 samples/07.using-adaptive-cards/src/main/resources/ImageGalleryCard.json create mode 100644 samples/07.using-adaptive-cards/src/main/resources/LargeWeatherCard.json create mode 100644 samples/07.using-adaptive-cards/src/main/resources/RestaurantCard.json create mode 100644 samples/07.using-adaptive-cards/src/main/resources/SolitaireCard.json create mode 100644 samples/07.using-adaptive-cards/src/main/resources/application.properties create mode 100644 samples/07.using-adaptive-cards/src/main/resources/log4j2.json create mode 100644 samples/07.using-adaptive-cards/src/main/webapp/META-INF/MANIFEST.MF create mode 100644 samples/07.using-adaptive-cards/src/main/webapp/WEB-INF/web.xml create mode 100644 samples/07.using-adaptive-cards/src/main/webapp/index.html create mode 100644 samples/07.using-adaptive-cards/src/test/java/com/microsoft/bot/sample/usingadaptivecards/ApplicationTest.java diff --git a/samples/07.using-adaptive-cards/LICENSE b/samples/07.using-adaptive-cards/LICENSE new file mode 100644 index 00000000..21071075 --- /dev/null +++ b/samples/07.using-adaptive-cards/LICENSE @@ -0,0 +1,21 @@ + MIT License + + Copyright (c) Microsoft Corporation. All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE diff --git a/samples/07.using-adaptive-cards/README.md b/samples/07.using-adaptive-cards/README.md new file mode 100644 index 00000000..3212a04a --- /dev/null +++ b/samples/07.using-adaptive-cards/README.md @@ -0,0 +1,59 @@ +# Using Adaptive Cards + +Bot Framework v4 using adaptive cards bot sample + +This bot has been created using [Bot Framework](https://dev.botframework.com), is shows how to send an Adaptive Card from the bot to the user. + +## Prerequisites + +- Java 1.8+ +- Install [Maven](https://maven.apache.org/) +- An account on [Azure](https://azure.microsoft.com) if you want to deploy to Azure. + +## To try this sample locally +- From the root of this project folder: + - Build the sample using `mvn package` + - Run it by using `java -jar .\target\adaptive-cards-sample.jar` + +## Testing the bot using Bot Framework Emulator + +[Bot Framework Emulator](https://github.com/microsoft/botframework-emulator) is a desktop application that allows bot developers to test and debug their bots on localhost or running remotely through a tunnel. + +- Install the latest Bot Framework Emulator from [here](https://github.com/Microsoft/BotFramework-Emulator/releases) + +### Connect to the bot using Bot Framework Emulator + +- Launch Bot Framework Emulator +- File -> Open Bot +- Enter a Bot URL of `http://localhost:3978/api/messages` + +## Interacting with the bot + +Card authors describe their content as a simple JSON object. That content can then be rendered natively inside a host application, automatically adapting to the look and feel of the host. For example, Contoso Bot can author an Adaptive Card through the Bot Framework, and when delivered to Cortana, it will look and feel like a Cortana card. When that same payload is sent to Microsoft Teams, it will look and feel like Microsoft Teams. As more host apps start to support Adaptive Cards, that same payload will automatically light up inside these applications, yet still feel entirely native to the app. Users win because everything feels familiar. Host apps win because they control the user experience. Card authors win because their content gets broader reach without any additional work. + +The Bot Framework provides support for Adaptive Cards. See the following to learn more about Adaptive Cards. + +- [Adaptive card](http://adaptivecards.io) +- [Send an Adaptive card](https://docs.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-send-rich-cards?view=azure-bot-service-3.0&viewFallbackFrom=azure-bot-service-4.0#send-an-adaptive-card) + +### Adding media to messages + +A message exchange between user and bot can contain media attachments, such as cards, images, video, audio, and files. + +## Deploy the bot to Azure + +To learn more about deploying a bot to Azure, see [Deploy your bot to Azure](https://aka.ms/azuredeployment) for a complete list of deployment instructions. + +## Further reading + +- [Bot Framework Documentation](https://docs.botframework.com) +- [Bot Basics](https://docs.microsoft.com/azure/bot-service/bot-builder-basics?view=azure-bot-service-4.0) +- [Adaptive Cards](https://adaptivecards.io/) +- [Send an Adaptive card](https://docs.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-send-rich-cards?view=azure-bot-service-3.0&viewFallbackFrom=azure-bot-service-4.0#send-an-adaptive-card) +- [Activity processing](https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-concept-activity-processing?view=azure-bot-service-4.0) +- [Azure Bot Service Introduction](https://docs.microsoft.com/azure/bot-service/bot-service-overview-introduction?view=azure-bot-service-4.0) +- [Azure Bot Service Documentation](https://docs.microsoft.com/azure/bot-service/?view=azure-bot-service-4.0) +- [.NET Core CLI tools](https://docs.microsoft.com/en-us/dotnet/core/tools/?tabs=netcore2x) +- [Azure CLI](https://docs.microsoft.com/cli/azure/?view=azure-cli-latest) +- [Azure Portal](https://portal.azure.com) +- [Channels and Bot Connector Service](https://docs.microsoft.com/en-us/azure/bot-service/bot-concepts?view=azure-bot-service-4.0) diff --git a/samples/07.using-adaptive-cards/deploymentTemplates/template-with-new-rg.json b/samples/07.using-adaptive-cards/deploymentTemplates/template-with-new-rg.json new file mode 100644 index 00000000..ec2460d3 --- /dev/null +++ b/samples/07.using-adaptive-cards/deploymentTemplates/template-with-new-rg.json @@ -0,0 +1,291 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "groupLocation": { + "defaultValue": "", + "type": "string", + "metadata": { + "description": "Specifies the location of the Resource Group." + } + }, + "groupName": { + "type": "string", + "metadata": { + "description": "Specifies the name of the Resource Group." + } + }, + "appId": { + "type": "string", + "metadata": { + "description": "Active Directory App ID, set as MicrosoftAppId in the Web App's Application Settings." + } + }, + "appSecret": { + "type": "string", + "metadata": { + "description": "Active Directory App Password, set as MicrosoftAppPassword in the Web App's Application Settings." + } + }, + "botId": { + "type": "string", + "metadata": { + "description": "The globally unique and immutable bot ID. Also used to configure the displayName of the bot, which is mutable." + } + }, + "botSku": { + "defaultValue": "S1", + "type": "string", + "metadata": { + "description": "The pricing tier of the Bot Service Registration. Acceptable values are F0 and S1." + } + }, + "newAppServicePlanName": { + "defaultValue": "", + "type": "string", + "metadata": { + "description": "The name of the App Service Plan." + } + }, + "newAppServicePlanSku": { + "type": "object", + "defaultValue": { + "name": "P1v2", + "tier": "PremiumV2", + "size": "P1v2", + "family": "Pv2", + "capacity": 1 + }, + "metadata": { + "description": "The SKU of the App Service Plan. Defaults to Standard values." + } + }, + "newAppServicePlanLocation": { + "defaultValue": "", + "type": "string", + "metadata": { + "description": "The location of the App Service Plan. Defaults to \"westus\"." + } + }, + "newWebAppName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The globally unique name of the Web App. Defaults to the value passed in for \"botId\"." + } + } + }, + "variables": { + "appServicePlanName": "[parameters('newAppServicePlanName')]", + "resourcesLocation": "[parameters('newAppServicePlanLocation')]", + "webAppName": "[if(empty(parameters('newWebAppName')), parameters('botId'), parameters('newWebAppName'))]", + "siteHost": "[concat(variables('webAppName'), '.azurewebsites.net')]", + "botEndpoint": "[concat('https://', variables('siteHost'), '/api/messages')]", + "publishingUsername": "[concat('$', parameters('newWebAppName'))]", + "resourceGroupId": "[concat(subscription().id, '/resourceGroups/', parameters('groupName'))]" + }, + "resources": [ + { + "name": "[parameters('groupName')]", + "type": "Microsoft.Resources/resourceGroups", + "apiVersion": "2018-05-01", + "location": "[parameters('groupLocation')]", + "properties": {} + }, + { + "type": "Microsoft.Resources/deployments", + "apiVersion": "2018-05-01", + "name": "storageDeployment", + "resourceGroup": "[parameters('groupName')]", + "dependsOn": [ + "[resourceId('Microsoft.Resources/resourceGroups/', parameters('groupName'))]" + ], + "properties": { + "mode": "Incremental", + "template": { + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": {}, + "variables": {}, + "resources": [ + { + "comments": "Create a new Linux App Service Plan if no existing App Service Plan name was passed in.", + "type": "Microsoft.Web/serverfarms", + "name": "[variables('appServicePlanName')]", + "apiVersion": "2018-02-01", + "location": "[variables('resourcesLocation')]", + "sku": "[parameters('newAppServicePlanSku')]", + "kind": "linux", + "properties": { + "perSiteScaling": false, + "maximumElasticWorkerCount": 1, + "isSpot": false, + "reserved": true, + "isXenon": false, + "hyperV": false, + "targetWorkerCount": 0, + "targetWorkerSizeId": 0 + } + }, + { + "comments": "Create a Web App using a Linux App Service Plan", + "type": "Microsoft.Web/sites", + "apiVersion": "2018-11-01", + "location": "[variables('resourcesLocation')]", + "kind": "app,linux", + "dependsOn": [ + "[concat(variables('resourceGroupId'), '/providers/Microsoft.Web/serverfarms/', variables('appServicePlanName'))]" + ], + "name": "[variables('webAppName')]", + "properties": { + "name": "[variables('webAppName')]", + "hostNameSslStates": [ + { + "name": "[concat(parameters('newWebAppName'), '.azurewebsites.net')]", + "sslState": "Disabled", + "hostType": "Standard" + }, + { + "name": "[concat(parameters('newWebAppName'), '.scm.azurewebsites.net')]", + "sslState": "Disabled", + "hostType": "Repository" + } + ], + "serverFarmId": "[variables('appServicePlanName')]", + "reserved": true, + "isXenon": false, + "hyperV": false, + "scmSiteAlsoStopped": false, + "clientAffinityEnabled": true, + "clientCertEnabled": false, + "hostNamesDisabled": false, + "containerSize": 0, + "dailyMemoryTimeQuota": 0, + "httpsOnly": false, + "redundancyMode": "None", + "siteConfig": { + "appSettings": [ + { + "name": "JAVA_OPTS", + "value": "-Dserver.port=80" + }, + { + "name": "MicrosoftAppId", + "value": "[parameters('appId')]" + }, + { + "name": "MicrosoftAppPassword", + "value": "[parameters('appSecret')]" + } + ], + "cors": { + "allowedOrigins": [ + "https://botservice.hosting.portal.azure.net", + "https://hosting.onecloud.azure-test.net/" + ] + } + } + } + }, + { + "type": "Microsoft.Web/sites/config", + "apiVersion": "2018-11-01", + "name": "[concat(variables('webAppName'), '/web')]", + "location": "[variables('resourcesLocation')]", + "dependsOn": [ + "[concat(variables('resourceGroupId'), '/providers/Microsoft.Web/sites/', variables('webAppName'))]" + ], + "properties": { + "numberOfWorkers": 1, + "defaultDocuments": [ + "Default.htm", + "Default.html", + "Default.asp", + "index.htm", + "index.html", + "iisstart.htm", + "default.aspx", + "index.php", + "hostingstart.html" + ], + "netFrameworkVersion": "v4.0", + "linuxFxVersion": "JAVA|8-jre8", + "requestTracingEnabled": false, + "remoteDebuggingEnabled": false, + "httpLoggingEnabled": false, + "logsDirectorySizeLimit": 35, + "detailedErrorLoggingEnabled": false, + "publishingUsername": "[variables('publishingUsername')]", + "scmType": "None", + "use32BitWorkerProcess": true, + "webSocketsEnabled": false, + "alwaysOn": true, + "managedPipelineMode": "Integrated", + "virtualApplications": [ + { + "virtualPath": "/", + "physicalPath": "site\\wwwroot", + "preloadEnabled": true + } + ], + "loadBalancing": "LeastRequests", + "experiments": { + "rampUpRules": [] + }, + "autoHealEnabled": false, + "localMySqlEnabled": false, + "ipSecurityRestrictions": [ + { + "ipAddress": "Any", + "action": "Allow", + "priority": 1, + "name": "Allow all", + "description": "Allow all access" + } + ], + "scmIpSecurityRestrictions": [ + { + "ipAddress": "Any", + "action": "Allow", + "priority": 1, + "name": "Allow all", + "description": "Allow all access" + } + ], + "scmIpSecurityRestrictionsUseMain": false, + "http20Enabled": false, + "minTlsVersion": "1.2", + "ftpsState": "AllAllowed", + "reservedInstanceCount": 0 + } + }, + { + "apiVersion": "2017-12-01", + "type": "Microsoft.BotService/botServices", + "name": "[parameters('botId')]", + "location": "global", + "kind": "bot", + "sku": { + "name": "[parameters('botSku')]" + }, + "properties": { + "name": "[parameters('botId')]", + "displayName": "[parameters('botId')]", + "endpoint": "[variables('botEndpoint')]", + "msaAppId": "[parameters('appId')]", + "developerAppInsightsApplicationId": null, + "developerAppInsightKey": null, + "publishingCredentials": null, + "storageResourceId": null + }, + "dependsOn": [ + "[concat(variables('resourceGroupId'), '/providers/Microsoft.Web/sites/', variables('webAppName'))]" + ] + } + ], + "outputs": {} + } + } + } + ] +} diff --git a/samples/07.using-adaptive-cards/deploymentTemplates/template-with-preexisting-rg.json b/samples/07.using-adaptive-cards/deploymentTemplates/template-with-preexisting-rg.json new file mode 100644 index 00000000..024dcf08 --- /dev/null +++ b/samples/07.using-adaptive-cards/deploymentTemplates/template-with-preexisting-rg.json @@ -0,0 +1,259 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "appId": { + "type": "string", + "metadata": { + "description": "Active Directory App ID, set as MicrosoftAppId in the Web App's Application Settings." + } + }, + "appSecret": { + "type": "string", + "metadata": { + "description": "Active Directory App Password, set as MicrosoftAppPassword in the Web App's Application Settings. Defaults to \"\"." + } + }, + "botId": { + "type": "string", + "metadata": { + "description": "The globally unique and immutable bot ID. Also used to configure the displayName of the bot, which is mutable." + } + }, + "botSku": { + "defaultValue": "S1", + "type": "string", + "metadata": { + "description": "The pricing tier of the Bot Service Registration. Acceptable values are F0 and S1." + } + }, + "newAppServicePlanName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The name of the new App Service Plan." + } + }, + "newAppServicePlanSku": { + "type": "object", + "defaultValue": { + "name": "P1v2", + "tier": "PremiumV2", + "size": "P1v2", + "family": "Pv2", + "capacity": 1 + }, + "metadata": { + "description": "The SKU of the App Service Plan. Defaults to Standard values." + } + }, + "appServicePlanLocation": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The location of the App Service Plan." + } + }, + "existingAppServicePlan": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "Name of the existing App Service Plan used to create the Web App for the bot." + } + }, + "newWebAppName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The globally unique name of the Web App. Defaults to the value passed in for \"botId\"." + } + } + }, + "variables": { + "defaultAppServicePlanName": "[if(empty(parameters('existingAppServicePlan')), 'createNewAppServicePlan', parameters('existingAppServicePlan'))]", + "useExistingAppServicePlan": "[not(equals(variables('defaultAppServicePlanName'), 'createNewAppServicePlan'))]", + "servicePlanName": "[if(variables('useExistingAppServicePlan'), parameters('existingAppServicePlan'), parameters('newAppServicePlanName'))]", + "publishingUsername": "[concat('$', parameters('newWebAppName'))]", + "resourcesLocation": "[parameters('appServicePlanLocation')]", + "webAppName": "[if(empty(parameters('newWebAppName')), parameters('botId'), parameters('newWebAppName'))]", + "siteHost": "[concat(variables('webAppName'), '.azurewebsites.net')]", + "botEndpoint": "[concat('https://', variables('siteHost'), '/api/messages')]" + }, + "resources": [ + { + "comments": "Create a new Linux App Service Plan if no existing App Service Plan name was passed in.", + "type": "Microsoft.Web/serverfarms", + "condition": "[not(variables('useExistingAppServicePlan'))]", + "name": "[variables('servicePlanName')]", + "apiVersion": "2018-02-01", + "location": "[variables('resourcesLocation')]", + "sku": "[parameters('newAppServicePlanSku')]", + "kind": "linux", + "properties": { + "perSiteScaling": false, + "maximumElasticWorkerCount": 1, + "isSpot": false, + "reserved": true, + "isXenon": false, + "hyperV": false, + "targetWorkerCount": 0, + "targetWorkerSizeId": 0 + } + }, + { + "comments": "Create a Web App using a Linux App Service Plan", + "type": "Microsoft.Web/sites", + "apiVersion": "2018-11-01", + "location": "[variables('resourcesLocation')]", + "kind": "app,linux", + "dependsOn": [ + "[resourceId('Microsoft.Web/serverfarms', variables('servicePlanName'))]" + ], + "name": "[variables('webAppName')]", + "properties": { + "name": "[variables('webAppName')]", + "hostNameSslStates": [ + { + "name": "[concat(parameters('newWebAppName'), '.azurewebsites.net')]", + "sslState": "Disabled", + "hostType": "Standard" + }, + { + "name": "[concat(parameters('newWebAppName'), '.scm.azurewebsites.net')]", + "sslState": "Disabled", + "hostType": "Repository" + } + ], + "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('servicePlanName'))]", + "reserved": true, + "isXenon": false, + "hyperV": false, + "scmSiteAlsoStopped": false, + "clientAffinityEnabled": true, + "clientCertEnabled": false, + "hostNamesDisabled": false, + "containerSize": 0, + "dailyMemoryTimeQuota": 0, + "httpsOnly": false, + "redundancyMode": "None", + "siteConfig": { + "appSettings": [ + { + "name": "JAVA_OPTS", + "value": "-Dserver.port=80" + }, + { + "name": "MicrosoftAppId", + "value": "[parameters('appId')]" + }, + { + "name": "MicrosoftAppPassword", + "value": "[parameters('appSecret')]" + } + ], + "cors": { + "allowedOrigins": [ + "https://botservice.hosting.portal.azure.net", + "https://hosting.onecloud.azure-test.net/" + ] + } + } + } + }, + { + "type": "Microsoft.Web/sites/config", + "apiVersion": "2018-11-01", + "name": "[concat(variables('webAppName'), '/web')]", + "location": "[variables('resourcesLocation')]", + "dependsOn": [ + "[resourceId('Microsoft.Web/sites/', variables('webAppName'))]" + ], + "properties": { + "numberOfWorkers": 1, + "defaultDocuments": [ + "Default.htm", + "Default.html", + "Default.asp", + "index.htm", + "index.html", + "iisstart.htm", + "default.aspx", + "index.php", + "hostingstart.html" + ], + "netFrameworkVersion": "v4.0", + "linuxFxVersion": "JAVA|8-jre8", + "requestTracingEnabled": false, + "remoteDebuggingEnabled": false, + "httpLoggingEnabled": false, + "logsDirectorySizeLimit": 35, + "detailedErrorLoggingEnabled": false, + "publishingUsername": "[variables('publishingUsername')]", + "scmType": "None", + "use32BitWorkerProcess": true, + "webSocketsEnabled": false, + "alwaysOn": true, + "managedPipelineMode": "Integrated", + "virtualApplications": [ + { + "virtualPath": "/", + "physicalPath": "site\\wwwroot", + "preloadEnabled": true + } + ], + "loadBalancing": "LeastRequests", + "experiments": { + "rampUpRules": [] + }, + "autoHealEnabled": false, + "localMySqlEnabled": false, + "ipSecurityRestrictions": [ + { + "ipAddress": "Any", + "action": "Allow", + "priority": 1, + "name": "Allow all", + "description": "Allow all access" + } + ], + "scmIpSecurityRestrictions": [ + { + "ipAddress": "Any", + "action": "Allow", + "priority": 1, + "name": "Allow all", + "description": "Allow all access" + } + ], + "scmIpSecurityRestrictionsUseMain": false, + "http20Enabled": false, + "minTlsVersion": "1.2", + "ftpsState": "AllAllowed", + "reservedInstanceCount": 0 + } + }, + { + "apiVersion": "2017-12-01", + "type": "Microsoft.BotService/botServices", + "name": "[parameters('botId')]", + "location": "global", + "kind": "bot", + "sku": { + "name": "[parameters('botSku')]" + }, + "properties": { + "name": "[parameters('botId')]", + "displayName": "[parameters('botId')]", + "endpoint": "[variables('botEndpoint')]", + "msaAppId": "[parameters('appId')]", + "developerAppInsightsApplicationId": null, + "developerAppInsightKey": null, + "publishingCredentials": null, + "storageResourceId": null + }, + "dependsOn": [ + "[resourceId('Microsoft.Web/sites/', variables('webAppName'))]" + ] + } + ] +} diff --git a/samples/07.using-adaptive-cards/pom.xml b/samples/07.using-adaptive-cards/pom.xml new file mode 100644 index 00000000..ece6a390 --- /dev/null +++ b/samples/07.using-adaptive-cards/pom.xml @@ -0,0 +1,249 @@ + + + + 4.0.0 + + com.microsoft.bot.sample + adaptive-cards + sample + jar + + ${project.groupId}:${project.artifactId} + This package contains a Java Adaptive Cards bot sample using Spring Boot. + http://maven.apache.org + + + org.springframework.boot + spring-boot-starter-parent + 2.4.0 + + + + + + MIT License + http://www.opensource.org/licenses/mit-license.php + + + + + + Bot Framework Development + + Microsoft + https://dev.botframework.com/ + + + + + 1.8 + 1.8 + 1.8 + com.microsoft.bot.sample.usingadaptivecards.Application + + + + + junit + junit + 4.13.1 + test + + + org.springframework.boot + spring-boot-starter-test + 2.4.0 + test + + + org.junit.vintage + junit-vintage-engine + test + + + + org.slf4j + slf4j-api + + + org.apache.logging.log4j + log4j-api + 2.11.0 + + + org.apache.logging.log4j + log4j-core + 2.13.2 + + + + com.microsoft.bot + bot-integration-spring + 4.6.0-preview9 + compile + + + com.microsoft.bot + bot-dialogs + 4.6.0-preview9 + compile + + + com.microsoft.bot + bot-builder + 4.6.0-preview9 + compile + + + + + build + + true + + + + + src/main/resources + false + + + + + maven-compiler-plugin + 3.8.1 + + + maven-war-plugin + 3.2.3 + + src/main/webapp + + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + com.microsoft.bot.sample.usingadaptivecards.Application + + + + + + com.microsoft.azure + azure-webapp-maven-plugin + 1.12.0 + + V2 + ${groupname} + ${botname} + + + JAVA_OPTS + -Dserver.port=80 + + + + linux + Java 8 + Java SE + + + + + ${project.basedir}/target + + *.jar + + + + + + + + + + + + publish + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + maven-war-plugin + 3.2.3 + + src/main/webapp + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.8 + true + + true + ossrh + https://oss.sonatype.org/ + true + + + + + org.apache.maven.plugins + maven-gpg-plugin + + + sign-artifacts + verify + + sign + + + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + 8 + false + + + + attach-javadocs + + jar + + + + + + + + + diff --git a/samples/07.using-adaptive-cards/src/main/java/com/microsoft/bot/sample/usingadaptivecards/Application.java b/samples/07.using-adaptive-cards/src/main/java/com/microsoft/bot/sample/usingadaptivecards/Application.java new file mode 100644 index 00000000..93bb1388 --- /dev/null +++ b/samples/07.using-adaptive-cards/src/main/java/com/microsoft/bot/sample/usingadaptivecards/Application.java @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.microsoft.bot.sample.usingadaptivecards; + +import com.microsoft.bot.builder.Bot; +import com.microsoft.bot.integration.AdapterWithErrorHandler; +import com.microsoft.bot.integration.BotFrameworkHttpAdapter; +import com.microsoft.bot.integration.Configuration; +import com.microsoft.bot.integration.spring.BotController; +import com.microsoft.bot.integration.spring.BotDependencyConfiguration; +import com.microsoft.bot.sample.usingadaptivecards.bots.AdaptiveCardsBot; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Import; + +// +// This is the starting point of the Sprint Boot Bot application. +// +@SpringBootApplication + +// Use the default BotController to receive incoming Channel messages. A custom +// controller could be used by eliminating this import and creating a new +// org.springframework.web.bind.annotation.RestController. +// The default controller is created by the Spring Boot container using +// dependency injection. The default route is /api/messages. +@Import({BotController.class}) + +/** + * This class extends the BotDependencyConfiguration which provides the default + * implementations for a Bot application. The Application class should + * override methods in order to provide custom implementations. + */ +public class Application extends BotDependencyConfiguration { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + + /** + * Returns the Bot for this application. + * + *

+ * The @Component annotation could be used on the Bot class instead of this method + * with the @Bean annotation. + *

+ * + * @return The Bot implementation for this application. + */ + @Bean + public Bot getBot() { + return new AdaptiveCardsBot(); + } + + /** + * Returns a custom Adapter that provides error handling. + * + * @param configuration The Configuration object to use. + * @return An error handling BotFrameworkHttpAdapter. + */ + @Override + public BotFrameworkHttpAdapter getBotFrameworkHttpAdaptor(Configuration configuration) { + return new AdapterWithErrorHandler(configuration); + } +} diff --git a/samples/07.using-adaptive-cards/src/main/java/com/microsoft/bot/sample/usingadaptivecards/bots/AdaptiveCardsBot.java b/samples/07.using-adaptive-cards/src/main/java/com/microsoft/bot/sample/usingadaptivecards/bots/AdaptiveCardsBot.java new file mode 100644 index 00000000..a64e090e --- /dev/null +++ b/samples/07.using-adaptive-cards/src/main/java/com/microsoft/bot/sample/usingadaptivecards/bots/AdaptiveCardsBot.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MT License. + +package com.microsoft.bot.sample.usingadaptivecards.bots; + +import java.io.InputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Random; +import java.util.concurrent.CompletableFuture; + + +import com.microsoft.bot.builder.ActivityHandler; +import com.microsoft.bot.builder.MessageFactory; +import com.microsoft.bot.builder.TurnContext; +import com.microsoft.bot.schema.Attachment; +import com.microsoft.bot.schema.ChannelAccount; +import com.microsoft.bot.schema.Serialization; + +import org.apache.commons.io.IOUtils; + +// This bot will respond to the user's input with an Adaptive Card. +// Adaptive Cards are a way for developers to exchange card content +// in a common and consistent way. A simple open card format enables +// an ecosystem of shared tooling, seamless integration between apps, +// and native cross-platform performance on any device. +// For each user interaction, an instance of this class instanceof created and the OnTurnAsync method instanceof called. +// This instanceof a Transient lifetime service. Transient lifetime services are created +// each time they're requested. For each Activity received, a new instance of this +// class instanceof created. Objects that are expensive to construct, or have a lifetime +// beyond the single turn, should be carefully managed. + +public class AdaptiveCardsBot extends ActivityHandler { + + private static final String welcomeText = "This bot will introduce you to AdaptiveCards. " + + "Type anything to see an AdaptiveCard."; + + // This array contains the file names of our adaptive cards + private final String[] cards = { + "FlightItineraryCard.json", + "ImageGalleryCard.json", + "LargeWeatherCard.json", + "RestaurantCard.json", + "SolitaireCard.json" + }; + + @Override + protected CompletableFuture onMembersAdded( + List membersAdded, + TurnContext turnContext + ) { + return sendWelcomeMessage(turnContext); + } + + @Override + protected CompletableFuture onMessageActivity(TurnContext turnContext) { + Random r = new Random(); + Attachment cardAttachment = createAdaptiveCardAttachment(cards[r.nextInt(cards.length)]); + + return turnContext.sendActivity(MessageFactory.attachment(cardAttachment)).thenCompose(result ->{ + return turnContext.sendActivity(MessageFactory.text("Please enter any text to see another card.")) + .thenApply(sendResult -> null); + }); + } + + private static CompletableFuture sendWelcomeMessage(TurnContext turnContext) { + for (ChannelAccount member : turnContext.getActivity().getMembersAdded()) { + if (!member.getId().equals(turnContext.getActivity().getRecipient().getId())) { + turnContext.sendActivity( + String.format("Welcome to Adaptive Cards Bot %s. %s", member.getName(), welcomeText) + ).join(); + } + } + return CompletableFuture.completedFuture(null); + } + + private static Attachment createAdaptiveCardAttachment(String filePath) { + try ( + InputStream inputStream = Thread.currentThread(). + getContextClassLoader().getResourceAsStream(filePath) + ) { + String adaptiveCardJson = IOUtils + .toString(inputStream, StandardCharsets.UTF_8.toString()); + + return new Attachment() {{ + setContentType("application/vnd.microsoft.card.adaptive"); + setContent(Serialization.jsonToTree(adaptiveCardJson)); + }}; + + } catch (IOException e) { + e.printStackTrace(); + return new Attachment(); + } + } +} + diff --git a/samples/07.using-adaptive-cards/src/main/resources/FlightItineraryCard.json b/samples/07.using-adaptive-cards/src/main/resources/FlightItineraryCard.json new file mode 100644 index 00000000..1c97e8a7 --- /dev/null +++ b/samples/07.using-adaptive-cards/src/main/resources/FlightItineraryCard.json @@ -0,0 +1,204 @@ +{ + "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", + "version": "1.0", + "type": "AdaptiveCard", + "speak": "Your flight is confirmed for you and 3 other passengers from San Francisco to Amsterdam on Friday, October 10 8:30 AM", + "body": [ + { + "type": "TextBlock", + "text": "Passengers", + "weight": "bolder", + "isSubtle": false + }, + { + "type": "TextBlock", + "text": "Sarah Hum", + "separator": true + }, + { + "type": "TextBlock", + "text": "Jeremy Goldberg", + "spacing": "none" + }, + { + "type": "TextBlock", + "text": "Evan Litvak", + "spacing": "none" + }, + { + "type": "TextBlock", + "text": "2 Stops", + "weight": "bolder", + "spacing": "medium" + }, + { + "type": "TextBlock", + "text": "Fri, October 10 8:30 AM", + "weight": "bolder", + "spacing": "none" + }, + { + "type": "ColumnSet", + "separator": true, + "columns": [ + { + "type": "Column", + "width": 1, + "items": [ + { + "type": "TextBlock", + "text": "San Francisco", + "isSubtle": true + }, + { + "type": "TextBlock", + "size": "extraLarge", + "color": "accent", + "text": "SFO", + "spacing": "none" + } + ] + }, + { + "type": "Column", + "width": "auto", + "items": [ + { + "type": "TextBlock", + "text": " " + }, + { + "type": "Image", + "url": "https://adaptivecards.io/content/airplane.png", + "size": "small", + "spacing": "none" + } + ] + }, + { + "type": "Column", + "width": 1, + "items": [ + { + "type": "TextBlock", + "horizontalAlignment": "right", + "text": "Amsterdam", + "isSubtle": true + }, + { + "type": "TextBlock", + "horizontalAlignment": "right", + "size": "extraLarge", + "color": "accent", + "text": "AMS", + "spacing": "none" + } + ] + } + ] + }, + { + "type": "TextBlock", + "text": "Non-Stop", + "weight": "bolder", + "spacing": "medium" + }, + { + "type": "TextBlock", + "text": "Fri, October 18 9:50 PM", + "weight": "bolder", + "spacing": "none" + }, + { + "type": "ColumnSet", + "separator": true, + "columns": [ + { + "type": "Column", + "width": 1, + "items": [ + { + "type": "TextBlock", + "text": "Amsterdam", + "isSubtle": true + }, + { + "type": "TextBlock", + "size": "extraLarge", + "color": "accent", + "text": "AMS", + "spacing": "none" + } + ] + }, + { + "type": "Column", + "width": "auto", + "items": [ + { + "type": "TextBlock", + "text": " " + }, + { + "type": "Image", + "url": "https://adaptivecards.io/content/airplane.png", + "size": "small", + "spacing": "none" + } + ] + }, + { + "type": "Column", + "width": 1, + "items": [ + { + "type": "TextBlock", + "horizontalAlignment": "right", + "text": "San Francisco", + "isSubtle": true + }, + { + "type": "TextBlock", + "horizontalAlignment": "right", + "size": "extraLarge", + "color": "accent", + "text": "SFO", + "spacing": "none" + } + ] + } + ] + }, + { + "type": "ColumnSet", + "spacing": "medium", + "columns": [ + { + "type": "Column", + "width": "1", + "items": [ + { + "type": "TextBlock", + "text": "Total", + "size": "medium", + "isSubtle": true + } + ] + }, + { + "type": "Column", + "width": 1, + "items": [ + { + "type": "TextBlock", + "horizontalAlignment": "right", + "text": "$4,032.54", + "size": "medium", + "weight": "bolder" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/samples/07.using-adaptive-cards/src/main/resources/ImageGalleryCard.json b/samples/07.using-adaptive-cards/src/main/resources/ImageGalleryCard.json new file mode 100644 index 00000000..b2558d5f --- /dev/null +++ b/samples/07.using-adaptive-cards/src/main/resources/ImageGalleryCard.json @@ -0,0 +1,60 @@ +{ + "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", + "type": "AdaptiveCard", + "version": "1.0", + "body": [ + { + "type": "TextBlock", + "text": "Here are some cool photos", + "size": "large" + }, + { + "type": "TextBlock", + "text": "Sorry some of them are repeats", + "size": "medium", + "weight": "lighter" + }, + { + "type": "ImageSet", + "imageSize": "medium", + "images": [ + { + "type": "Image", + "url": "https://picsum.photos/200/200?image=100" + }, + { + "type": "Image", + "url": "https://picsum.photos/300/200?image=200" + }, + { + "type": "Image", + "url": "https://picsum.photos/300/200?image=301" + }, + { + "type": "Image", + "url": "https://picsum.photos/200/200?image=400" + }, + { + "type": "Image", + "url": "https://picsum.photos/300/200?image=500" + }, + { + "type": "Image", + "url": "https://picsum.photos/200/200?image=600" + }, + { + "type": "Image", + "url": "https://picsum.photos/300/200?image=700" + }, + { + "type": "Image", + "url": "https://picsum.photos/300/200?image=800" + }, + { + "type": "Image", + "url": "https://picsum.photos/300/200?image=900" + } + ] + } + ] + } \ No newline at end of file diff --git a/samples/07.using-adaptive-cards/src/main/resources/LargeWeatherCard.json b/samples/07.using-adaptive-cards/src/main/resources/LargeWeatherCard.json new file mode 100644 index 00000000..938fc5db --- /dev/null +++ b/samples/07.using-adaptive-cards/src/main/resources/LargeWeatherCard.json @@ -0,0 +1,205 @@ +{ + "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", + "type": "AdaptiveCard", + "version": "1.0", + "speak": "Weather forecast for Monday is high of 62 and low of 42 degrees with a 20% chance of rain. Winds will be 5 mph from the northeast.", + "backgroundImage": "https://adaptivecards.io/content/Mostly%20Cloudy-Background-Dark.jpg", + "body": [ + { + "type": "ColumnSet", + "columns": [ + { + "type": "Column", + "width": "35", + "items": [ + { + "type": "Image", + "url": "https://adaptivecards.io/content/Mostly%20Cloudy-Square.png", + "size": "stretch" + } + ] + }, + { + "type": "Column", + "width": "65", + "items": [ + { + "type": "TextBlock", + "text": "Monday April 1", + "weight": "bolder", + "size": "large", + "color": "light" + }, + { + "type": "TextBlock", + "text": "63 / 42", + "size": "medium", + "spacing": "none" + }, + { + "type": "TextBlock", + "isSubtle": true, + "text": "20% chance of rain", + "spacing": "none" + }, + { + "type": "TextBlock", + "isSubtle": true, + "text": "Winds 5 mph NE", + "spacing": "none" + } + ] + } + ] + }, + { + "type": "ColumnSet", + "columns": [ + { + "type": "Column", + "width": "20", + "items": [ + { + "type": "TextBlock", + "horizontalAlignment": "center", + "wrap": false, + "text": "Fri" + }, + { + "type": "Image", + "size": "auto", + "url": "https://adaptivecards.io/content/Mostly%20Cloudy-Square.png" + }, + { + "type": "TextBlock", + "horizontalAlignment": "center", + "wrap": false, + "text": "62" + }, + { + "type": "TextBlock", + "horizontalAlignment": "center", + "isSubtle": true, + "wrap": false, + "text": "52", + "spacing": "none" + } + ], + "selectAction": { + "type": "Action.OpenUrl", + "title": "View Friday", + "url": "https://www.microsoft.com" + } + }, + { + "type": "Column", + "width": "20", + "items": [ + { + "type": "TextBlock", + "horizontalAlignment": "center", + "wrap": false, + "text": "Sat" + }, + { + "type": "Image", + "size": "auto", + "url": "https://adaptivecards.io/content/Drizzle-Square.png" + }, + { + "type": "TextBlock", + "horizontalAlignment": "center", + "wrap": false, + "text": "60" + }, + { + "type": "TextBlock", + "horizontalAlignment": "center", + "isSubtle": true, + "wrap": false, + "text": "48", + "spacing": "none" + } + ], + "selectAction": { + "type": "Action.OpenUrl", + "title": "View Saturday", + "url": "https://www.microsoft.com" + } + }, + { + "type": "Column", + "width": "20", + "items": [ + { + "type": "TextBlock", + "horizontalAlignment": "center", + "wrap": false, + "text": "Sun" + }, + { + "type": "Image", + "size": "auto", + "url": "https://adaptivecards.io/content/Mostly%20Cloudy-Square.png" + }, + { + "type": "TextBlock", + "horizontalAlignment": "center", + "wrap": false, + "text": "59" + }, + { + "type": "TextBlock", + "horizontalAlignment": "center", + "isSubtle": true, + "wrap": false, + "text": "49", + "spacing": "none" + } + ], + "selectAction": { + "type": "Action.OpenUrl", + "title": "View Sunday", + "url": "https://www.microsoft.com" + } + }, + { + "type": "Column", + "width": "20", + "items": [ + { + "type": "TextBlock", + "horizontalAlignment": "center", + "wrap": false, + "text": "Mon" + }, + { + "type": "Image", + "size": "auto", + "url": "https://adaptivecards.io/content/Mostly%20Cloudy-Square.png" + }, + { + "type": "TextBlock", + "horizontalAlignment": "center", + "wrap": false, + "text": "64" + }, + { + "type": "TextBlock", + "horizontalAlignment": "center", + "isSubtle": true, + "wrap": false, + "text": "51", + "spacing": "none" + } + ], + "selectAction": { + "type": "Action.OpenUrl", + "title": "View Monday", + "url": "https://www.microsoft.com" + } + } + ] + } + ] + } \ No newline at end of file diff --git a/samples/07.using-adaptive-cards/src/main/resources/RestaurantCard.json b/samples/07.using-adaptive-cards/src/main/resources/RestaurantCard.json new file mode 100644 index 00000000..20acdc3e --- /dev/null +++ b/samples/07.using-adaptive-cards/src/main/resources/RestaurantCard.json @@ -0,0 +1,60 @@ +{ + "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", + "type": "AdaptiveCard", + "version": "1.0", + "body": [ + { + "speak": "Tom's Pie is a pizza restaurant which is rated 9.3 by customers.", + "type": "ColumnSet", + "columns": [ + { + "type": "Column", + "width": 2, + "items": [ + { + "type": "TextBlock", + "text": "PIZZA" + }, + { + "type": "TextBlock", + "text": "Tom's Pie", + "weight": "bolder", + "size": "extraLarge", + "spacing": "none" + }, + { + "type": "TextBlock", + "text": "4.2 ★★★☆ (93) · $$", + "isSubtle": true, + "spacing": "none" + }, + { + "type": "TextBlock", + "text": "**Matt H. said** \"I'm compelled to give this place 5 stars due to the number of times I've chosen to eat here this past year!\"", + "size": "small", + "wrap": true + } + ] + }, + { + "type": "Column", + "width": 1, + "items": [ + { + "type": "Image", + "url": "https://picsum.photos/300?image=882", + "size": "auto" + } + ] + } + ] + } + ], + "actions": [ + { + "type": "Action.OpenUrl", + "title": "More Info", + "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" + } + ] + } \ No newline at end of file diff --git a/samples/07.using-adaptive-cards/src/main/resources/SolitaireCard.json b/samples/07.using-adaptive-cards/src/main/resources/SolitaireCard.json new file mode 100644 index 00000000..5d68664b --- /dev/null +++ b/samples/07.using-adaptive-cards/src/main/resources/SolitaireCard.json @@ -0,0 +1,39 @@ +{ + "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", + "type": "AdaptiveCard", + "version": "1.0", + "backgroundImage": "https://download-ssl.msgamestudios.com/content/mgs/ce/production/SolitaireWin10/dev/adapative_card_assets/v1/card_background.png", + "body": [ + { + "type": "ColumnSet", + "columns": [ + { + "type": "Column", + "width": 1, + "items": [ + { + "type": "Image", + "url": "https://download-ssl.msgamestudios.com/content/mgs/ce/production/SolitaireWin10/dev/adapative_card_assets/v1/tile_spider.png", + "size": "stretch" + } + ] + }, + { + "type": "Column", + "width": 1, + "items": [ + { + "type": "TextBlock", + "text": "Click here to play another game of Spider in Microsoft Solitaire Collection!", + "color": "light", + "weight": "bolder", + "wrap": true, + "size": "default", + "horizontalAlignment": "center" + } + ] + } + ] + } + ] + } \ No newline at end of file diff --git a/samples/07.using-adaptive-cards/src/main/resources/application.properties b/samples/07.using-adaptive-cards/src/main/resources/application.properties new file mode 100644 index 00000000..d7d0ee86 --- /dev/null +++ b/samples/07.using-adaptive-cards/src/main/resources/application.properties @@ -0,0 +1,3 @@ +MicrosoftAppId= +MicrosoftAppPassword= +server.port=3978 diff --git a/samples/07.using-adaptive-cards/src/main/resources/log4j2.json b/samples/07.using-adaptive-cards/src/main/resources/log4j2.json new file mode 100644 index 00000000..67c0ad53 --- /dev/null +++ b/samples/07.using-adaptive-cards/src/main/resources/log4j2.json @@ -0,0 +1,18 @@ +{ + "configuration": { + "name": "Default", + "appenders": { + "Console": { + "name": "Console-Appender", + "target": "SYSTEM_OUT", + "PatternLayout": {"pattern": "[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n"} + } + }, + "loggers": { + "root": { + "level": "debug", + "appender-ref": {"ref": "Console-Appender","level": "debug"} + } + } + } +} diff --git a/samples/07.using-adaptive-cards/src/main/webapp/META-INF/MANIFEST.MF b/samples/07.using-adaptive-cards/src/main/webapp/META-INF/MANIFEST.MF new file mode 100644 index 00000000..254272e1 --- /dev/null +++ b/samples/07.using-adaptive-cards/src/main/webapp/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/samples/07.using-adaptive-cards/src/main/webapp/WEB-INF/web.xml b/samples/07.using-adaptive-cards/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000..383c1900 --- /dev/null +++ b/samples/07.using-adaptive-cards/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,12 @@ + + + dispatcher + + org.springframework.web.servlet.DispatcherServlet + + + contextConfigLocation + /WEB-INF/spring/dispatcher-config.xml + + 1 + \ No newline at end of file diff --git a/samples/07.using-adaptive-cards/src/main/webapp/index.html b/samples/07.using-adaptive-cards/src/main/webapp/index.html new file mode 100644 index 00000000..d5ba5158 --- /dev/null +++ b/samples/07.using-adaptive-cards/src/main/webapp/index.html @@ -0,0 +1,418 @@ + + + + + + + EchoBot + + + + + +
+
+
+
Spring Boot Bot
+
+
+
+
+
Your bot is ready!
+
You can test your bot in the Bot Framework Emulator
+ by connecting to http://localhost:3978/api/messages.
+ +
Visit Azure + Bot Service to register your bot and add it to
+ various channels. The bot's endpoint URL typically looks + like this:
+
https://your_bots_hostname/api/messages
+
+
+
+
+ +
+ + + diff --git a/samples/07.using-adaptive-cards/src/test/java/com/microsoft/bot/sample/usingadaptivecards/ApplicationTest.java b/samples/07.using-adaptive-cards/src/test/java/com/microsoft/bot/sample/usingadaptivecards/ApplicationTest.java new file mode 100644 index 00000000..c2cc1d1e --- /dev/null +++ b/samples/07.using-adaptive-cards/src/test/java/com/microsoft/bot/sample/usingadaptivecards/ApplicationTest.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.microsoft.bot.sample.usingadaptivecards; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class ApplicationTest { + + @Test + public void contextLoads() { + } + +}