This repository has been archived by the owner on Dec 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 115
[Samples] Add 11.qnamaker bot sample #1023
Merged
tracyboehrer
merged 13 commits into
microsoft:main
from
southworks:feature/southworks/samples/11qnamaker
Feb 26, 2021
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
43d7c45
Add project structure
matiasroldan6 25f2667
Add deploymentTemplates folder
FedericoBernal 7b18eb3
Add webapp folder
FedericoBernal b3fd94a
Add application.properties
FedericoBernal 71a4d3a
Add qnabot class
matiasroldan6 35b6a02
Add Application class
FedericoBernal d3d4c04
Add smartLightFAQ file to project
matiasroldan6 67de0a1
Add README
Batta32 80c4d97
Fix Application class
FedericoBernal 0357089
Add qna-ai version to pom + empty class for test
matiasroldan6 d23550d
Changes to QnABot
matiasroldan6 a4f6b9d
Add requested changes
matiasroldan6 454e6b4
Merge branch 'main' into feature/southworks/samples/11qnamaker
Batta32 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# QnA Maker | ||
|
||
Bot Framework v4 QnA Maker bot sample | ||
|
||
This bot has been created using [Bot Framework](https://dev.botframework.com), it shows how to create a bot that uses the [QnA Maker Cognitive AI](https://www.qnamaker.ai) service. | ||
|
||
The [QnA Maker Service](https://www.qnamaker.ai) enables you to build, train and publish a simple question and answer bot based on FAQ URLs, structured documents or editorial content in minutes. In this sample, we demonstrate how to use the QnA Maker service to answer questions based on a FAQ text file used as input. | ||
|
||
## Prerequisites | ||
|
||
This samples **requires** prerequisites in order to run. | ||
|
||
### Overview | ||
|
||
- This bot uses [QnA Maker Service](https://www.qnamaker.ai), an AI based cognitive service, to implement simple Question and Answer conversational patterns. | ||
- Java 1.8+ | ||
- Install [Maven](https://maven.apache.org/) | ||
- An account on [Azure](https://azure.microsoft.com) if you want to deploy to Azure. | ||
|
||
### Create a QnAMaker Application to enable QnA Knowledge Bases | ||
|
||
QnA knowledge base setup and application configuration steps can be found [here](https://aka.ms/qna-instructions). | ||
|
||
## To try this sample | ||
|
||
- From the root of this project folder: | ||
- Build the sample using `mvn package` | ||
- Run it by using `java -jar .\target\bot-qna-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 | ||
|
||
QnA Maker enables you to power a question and answer service from your semi-structured content. | ||
|
||
One of the basic requirements in writing your own bot is to seed it with questions and answers. In many cases, the questions and answers already exist in content like FAQ URLs/documents, product manuals, etc. With QnA Maker, users can query your application in a natural, conversational manner. QnA Maker uses machine learning to extract relevant question-answer pairs from your content. It also uses powerful matching and ranking algorithms to provide the best possible match between the user query and the questions. | ||
|
||
## 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) | ||
- [QnA Maker Documentation](https://docs.microsoft.com/en-us/azure/cognitive-services/qnamaker/overview/overview) | ||
- [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) | ||
- [Azure CLI](https://docs.microsoft.com/cli/azure/?view=azure-cli-latest) | ||
- [QnA Maker CLI](https://github.com/microsoft/botframework-cli/tree/main/packages/qnamaker) | ||
- [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) | ||
- [Spring Boot](https://spring.io/projects/spring-boot) |
42 changes: 42 additions & 0 deletions
42
samples/11.qnamaker/deploymentTemplates/new-rg-parameters.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"groupLocation": { | ||
"value": "" | ||
}, | ||
"groupName": { | ||
"value": "" | ||
}, | ||
"appId": { | ||
"value": "" | ||
}, | ||
"appSecret": { | ||
"value": "" | ||
}, | ||
"botId": { | ||
"value": "" | ||
}, | ||
"botSku": { | ||
"value": "" | ||
}, | ||
"newAppServicePlanName": { | ||
"value": "" | ||
}, | ||
"newAppServicePlanSku": { | ||
"value": { | ||
"name": "S1", | ||
"tier": "Standard", | ||
"size": "S1", | ||
"family": "S", | ||
"capacity": 1 | ||
} | ||
}, | ||
"newAppServicePlanLocation": { | ||
"value": "" | ||
}, | ||
"newWebAppName": { | ||
"value": "" | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
samples/11.qnamaker/deploymentTemplates/preexisting-rg-parameters.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. preexisting-rg-parameters.json can be removed. |
||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"appId": { | ||
"value": "" | ||
}, | ||
"appSecret": { | ||
"value": "" | ||
}, | ||
"botId": { | ||
"value": "" | ||
}, | ||
"botSku": { | ||
"value": "" | ||
}, | ||
"newAppServicePlanName": { | ||
"value": "" | ||
}, | ||
"newAppServicePlanSku": { | ||
"value": { | ||
"name": "S1", | ||
"tier": "Standard", | ||
"size": "S1", | ||
"family": "S", | ||
"capacity": 1 | ||
} | ||
}, | ||
"appServicePlanLocation": { | ||
"value": "" | ||
}, | ||
"existingAppServicePlan": { | ||
"value": "" | ||
}, | ||
"newWebAppName": { | ||
"value": "" | ||
} | ||
} | ||
} |
183 changes: 183 additions & 0 deletions
183
samples/11.qnamaker/deploymentTemplates/template-with-new-rg.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update template-with-new-rg.json with version from 02.echo-bot |
||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"groupLocation": { | ||
"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": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "The pricing tier of the Bot Service Registration. Acceptable values are F0 and S1." | ||
} | ||
}, | ||
"newAppServicePlanName": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "The name of the App Service Plan." | ||
} | ||
}, | ||
"newAppServicePlanSku": { | ||
"type": "object", | ||
"defaultValue": { | ||
"name": "S1", | ||
"tier": "Standard", | ||
"size": "S1", | ||
"family": "S", | ||
"capacity": 1 | ||
}, | ||
"metadata": { | ||
"description": "The SKU of the App Service Plan. Defaults to Standard values." | ||
} | ||
}, | ||
"newAppServicePlanLocation": { | ||
"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')]", | ||
"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 App Service Plan", | ||
"type": "Microsoft.Web/serverfarms", | ||
"name": "[variables('appServicePlanName')]", | ||
"apiVersion": "2018-02-01", | ||
"location": "[variables('resourcesLocation')]", | ||
"sku": "[parameters('newAppServicePlanSku')]", | ||
"properties": { | ||
"name": "[variables('appServicePlanName')]" | ||
} | ||
}, | ||
{ | ||
"comments": "Create a Web App using the new App Service Plan", | ||
"type": "Microsoft.Web/sites", | ||
"apiVersion": "2015-08-01", | ||
"location": "[variables('resourcesLocation')]", | ||
"kind": "app", | ||
"dependsOn": [ | ||
"[concat(variables('resourceGroupId'), '/providers/Microsoft.Web/serverfarms/', variables('appServicePlanName'))]" | ||
], | ||
"name": "[variables('webAppName')]", | ||
"properties": { | ||
"name": "[variables('webAppName')]", | ||
"serverFarmId": "[variables('appServicePlanName')]", | ||
"siteConfig": { | ||
"appSettings": [ | ||
{ | ||
"name": "WEBSITE_NODE_DEFAULT_VERSION", | ||
"value": "10.14.1" | ||
}, | ||
{ | ||
"name": "MicrosoftAppId", | ||
"value": "[parameters('appId')]" | ||
}, | ||
{ | ||
"name": "MicrosoftAppPassword", | ||
"value": "[parameters('appSecret')]" | ||
} | ||
], | ||
"cors": { | ||
"allowedOrigins": [ | ||
"https://botservice.hosting.portal.azure.net", | ||
"https://hosting.onecloud.azure-test.net/" | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"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": {} | ||
} | ||
} | ||
} | ||
] | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new-rg-parameters.json can be removed.