diff --git a/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/SkillRouter.cs b/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/SkillRouter.cs index 2b70f4d7ad..26c428a160 100644 --- a/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/SkillRouter.cs +++ b/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/SkillRouter.cs @@ -17,7 +17,7 @@ public static class SkillRouter /// Whether the intent matches a Skill. public static SkillManifest IsSkill(List skillConfiguration, string dispatchIntent) { - return skillConfiguration.SingleOrDefault(s => s.Id == dispatchIntent.ToString()); + return skillConfiguration.SingleOrDefault(s => s.Actions.Any(a => a.Id == dispatchIntent.ToString())); } } } \ No newline at end of file diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions/Microsoft.Bot.Builder.Solutions.csproj b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions/Microsoft.Bot.Builder.Solutions.csproj index f9f9fcd2cd..30b9f4a2eb 100644 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions/Microsoft.Bot.Builder.Solutions.csproj +++ b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions/Microsoft.Bot.Builder.Solutions.csproj @@ -1,6 +1,4 @@ - - - + 4.0.0-local diff --git a/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Deployment/Scripts/add_remote_skill.ps1 b/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Deployment/Scripts/add_remote_skill.ps1 index 18c6841cfd..f66295082c 100644 --- a/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Deployment/Scripts/add_remote_skill.ps1 +++ b/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Deployment/Scripts/add_remote_skill.ps1 @@ -84,73 +84,74 @@ if (-not $manifest) { } Write-Host "> Getting intents for dispatch ..." -$dictionary = @{ } -foreach ($action in $manifest.actions) { - if ($action.definition.triggers.utteranceSources) { - foreach ($source in $action.definition.triggers.utteranceSources) { - foreach ($luisStr in $source.source) { - $luis = $luisStr -Split '#' - if ($dictionary.ContainsKey($luis[0])) { - $intents = $dictionary[$luis[0]] - $intents += $luis[1] - $dictionary[$luis[0]] = $intents - } - else { - $dictionary.Add($luis[0], @($luis[1])) - } - } - } - } -} - -Write-Host "> Adding skill to dispatch ..." try { - $intentName = $manifest.Id - foreach ($luisApp in $dictionary.Keys) { - $intents = $dictionary[$luisApp] - $luFile = Get-ChildItem -Path $(Join-Path $luisFolder "$($luisApp).lu") ` 2>> $logFile - - if (-not $luFile) { - $luFile = Get-ChildItem -Path $(Join-Path $luisFolder $langCode "$($luisApp).lu") ` 2>> $logFile - - if ($luFile) { - $luisFolder = $(Join-Path $luisFolder $langCode) - } - else { - Write-Host "! Could not find $($manifest.Name) LU file. Please provide the -luisFolder parameter." -ForegroundColor DarkRed - Write-Host "! Checked the following locations:" -ForegroundColor DarkRed - Write-Host " $(Join-Path $luisFolder "$($luisApp).lu")" -ForegroundColor DarkRed - Write-Host " $(Join-Path $luisFolder $langCode "$($luisApp).lu")" -ForegroundColor DarkRed - Throw - } + foreach ($action in $manifest.actions) { + if ($action.definition.triggers.utteranceSources) { + $sources = @{} + foreach ($source in ($action.definition.triggers.utteranceSources | Where-Object {$_.locale -eq $langCode})) { + foreach ($luisStr in $source.source) { + $luis = $luisStr -Split '#' + if ($sources.ContainsKey($luis[0])) { + $intents = $sources[$luis[0]] + $intents += $luis[1] + $sources[$luis[0]] = $intents + } + else { + $sources.Add($luis[0], @($luis[1])) + } + } + } + + Write-Host "> Adding $($action.id) action to dispatch ..." + foreach ($luisApp in $sources.Keys) { + $intents = $sources[$luisApp] + $luFile = Get-ChildItem -Path $(Join-Path $luisFolder "$($luisApp).lu") ` 2>> $logFile + + if (-not $luFile) { + $luFile = Get-ChildItem -Path $(Join-Path $luisFolder $langCode "$($luisApp).lu") ` 2>> $logFile + + if ($luFile) { + $luisFolder = $(Join-Path $luisFolder $langCode) + } + else { + Write-Host "! Could not find $($manifest.Name) LU file. Please provide the -luisFolder parameter." -ForegroundColor DarkRed + Write-Host "! Checked the following locations:" -ForegroundColor DarkRed + Write-Host " $(Join-Path $luisFolder "$($luisApp).lu")" -ForegroundColor DarkRed + Write-Host " $(Join-Path $luisFolder $langCode "$($luisApp).lu")" -ForegroundColor DarkRed + Throw + } + } + + # Parse LU file + ludown parse toluis ` + --in $luFile ` + --luis_culture $language ` + --out_folder $luisFolder ` + --out "$($luisApp).luis" + + $luisFile = Get-ChildItem ` + -Path $luisFolder ` + -Filter "$($luisApp).luis" ` + -Recurse ` + -Force 2>> $logFile + + if ($luisFile) { + (dispatch add ` + --type file ` + --filePath $luisFile ` + --name $action.id ` + --intentName $action.id ` + --includedIntents $intents ` + --dataFolder $dispatchFolder ` + --dispatch $(Join-Path $dispatchFolder "$($dispatchName).dispatch")) 2>> $logFile | Out-Null + } + else { + Write-Host "! Could not find LUIS file: $(Join-Path $luisFolder "$($luisApp).luis")" -ForegroundColor DarkRed + Break + } + } } - - # Parse LU file - ludown parse toluis ` - --in $luFile ` - --luis_culture $language ` - --out_folder $luisFolder ` - --out "$($luisApp).luis" - - $luisFile = Get-ChildItem ` - -Path $luisFolder ` - -Filter "$($luisApp).luis" ` - -Recurse ` - -Force 2>> $logFile - - if ($luisFile) { - (dispatch add ` - --type file ` - --filePath $luisFile ` - --intentName $intentName ` - --dataFolder $dispatchFolder ` - --dispatch $(Join-Path $dispatchFolder "$($dispatchName).dispatch")) 2>> $logFile | Out-Null - } - else { - Write-Host "! Could not find LUIS file: $(Join-Path $luisFolder "$($luisApp).luis")" -ForegroundColor DarkRed - Break - } - } + } } catch { Break @@ -284,10 +285,12 @@ if ($manifest.authenticationConnections) { } } +Write-Host "> Done." + if ($manualScopesRequired) { Write-Host "+ Could not configure scopes automatically. You must configure the following scopes in the Azure Portal to use this skill: $($newScopes -Join ', ')" -ForegroundColor Magenta } if ($manualAuthRequired) { Write-Host "+ Could not configure authentication connection automatically. You must configure one of the following connection types manually in the Azure Portal: $($manifest.authenticationConnections.serviceProviderId -Join ', ')" -ForegroundColor Magenta -} \ No newline at end of file +} diff --git a/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Deployment/Scripts/deploy.ps1 b/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Deployment/Scripts/deploy.ps1 index 76eaa462a0..b4a09ee834 100644 --- a/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Deployment/Scripts/deploy.ps1 +++ b/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Deployment/Scripts/deploy.ps1 @@ -153,4 +153,6 @@ $settings | Add-Member -Type NoteProperty -Force -Name 'contentModerator' -Value $settings | ConvertTo-Json -depth 100 | Out-File $(Join-Path $outFolder appsettings.json) # Deploy cognitive models -Invoke-Expression "$(Join-Path $PSScriptRoot 'deploy_cognitive_models.ps1') -name $($name) -luisAuthoringRegion $($luisAuthoringRegion) -luisAuthoringKey $($luisAuthoringKey) -qnaSubscriptionKey $($outputs.qnaMaker.value.key) -outFolder $($outFolder)" \ No newline at end of file +Invoke-Expression "$(Join-Path $PSScriptRoot 'deploy_cognitive_models.ps1') -name $($name) -luisAuthoringRegion $($luisAuthoringRegion) -luisAuthoringKey $($luisAuthoringKey) -qnaSubscriptionKey $($outputs.qnaMaker.value.key) -outFolder $($outFolder)" + +Write-Host "> Done." \ No newline at end of file diff --git a/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Deployment/Scripts/remove_skill.ps1 b/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Deployment/Scripts/remove_skill.ps1 index 5821931a6f..af1011e6f7 100644 --- a/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Deployment/Scripts/remove_skill.ps1 +++ b/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Deployment/Scripts/remove_skill.ps1 @@ -67,48 +67,17 @@ if (-not $manifest) { Break } -Write-Host "> Getting intents for dispatch ..." -$dictionary = @{ } -foreach ($action in $manifest.actions) { - if ($action.definition.triggers.utteranceSources) { - foreach ($source in $action.definition.triggers.utteranceSources) { - foreach ($luisStr in $source.source) { - $luis = $luisStr -Split '#' - if ($dictionary.ContainsKey($luis[0])) { - $intents = $dictionary[$luis[0]] - $intents += $luis[1] - $dictionary[$luis[0]] = $intents - } - else { - $dictionary.Add($luis[0], @($luis[1])) - } - } - } - } -} - Write-Host "> Removing skill from dispatch ..." -try { - $intentName = $manifest.Id - $dispatch = Get-Content $dispatchPath | ConvertFrom-Json - - if ($dispatch.services) { - foreach ($luisApp in $dictionary.Keys) { - $intents = $dictionary[$luisApp] - $toRemove = $dispatch.services | Where-Object { $_.name -eq $luisApp } - $dispatch.services = $dispatch.services | Where-Object -FilterScript { $_.name -ne $luisApp } - $dispatch.serviceIds = $dispatch.serviceIds | Where-Object -FilterScript { $toRemove.id -notcontains $_ } - } - - $dispatch | ConvertTo-Json -depth 100 | Out-File $dispatchPath - } - else { - Write-Host "! No services found in file: $($dispatchPath)" -ForegroundColor DarkRed - Break - } +$dispatch = Get-Content $dispatchPath | ConvertFrom-Json +if ($dispatch.services) { + $toRemove = $dispatch.services | Where-Object { $manifest.actions.id -contains $_.name } + $dispatch.services = $dispatch.services | Where-Object -FilterScript { $manifest.actions.id -notcontains $_.name } + $dispatch.serviceIds = $dispatch.serviceIds | Where-Object -FilterScript { $toRemove.id -notcontains $_ } + + $dispatch | ConvertTo-Json -depth 100 | Out-File $dispatchPath } -catch { - Break +else { + Write-Host "! No services found in file: $($dispatchPath)" -ForegroundColor DarkRed } Write-Host "> Running dispatch refresh ..." @@ -143,4 +112,6 @@ if (Test-Path $skillsFile) { } else { Write-Host "! Could not find file: $($skillFile)" -ForegroundColor Cyan -} \ No newline at end of file +} + +Write-Host "> Done." \ No newline at end of file diff --git a/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Dialogs/MainDialog.cs b/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Dialogs/MainDialog.cs index 214afa14d2..6510543fb4 100644 --- a/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Dialogs/MainDialog.cs +++ b/templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Dialogs/MainDialog.cs @@ -117,7 +117,7 @@ protected override async Task OnInterruptDialogAsync(DialogC { // We have identiifed a skill so initialize the skill connection with the target skill // the dispatch intent is the Action ID of the Skill enabling us to resolve the specific action and identify slots - await dc.BeginDialogAsync(identifiedSkill.Id, intent); + await dc.BeginDialogAsync(identifiedSkill.Id, intent.ToString()); // Pass the activity we have var result = await dc.ContinueDialogAsync(); diff --git a/templates/Virtual-Assistant-Template/csharp/Template/VA/Deployment/Scripts/add_remote_skill.ps1 b/templates/Virtual-Assistant-Template/csharp/Template/VA/Deployment/Scripts/add_remote_skill.ps1 index 18c6841cfd..f66295082c 100644 --- a/templates/Virtual-Assistant-Template/csharp/Template/VA/Deployment/Scripts/add_remote_skill.ps1 +++ b/templates/Virtual-Assistant-Template/csharp/Template/VA/Deployment/Scripts/add_remote_skill.ps1 @@ -84,73 +84,74 @@ if (-not $manifest) { } Write-Host "> Getting intents for dispatch ..." -$dictionary = @{ } -foreach ($action in $manifest.actions) { - if ($action.definition.triggers.utteranceSources) { - foreach ($source in $action.definition.triggers.utteranceSources) { - foreach ($luisStr in $source.source) { - $luis = $luisStr -Split '#' - if ($dictionary.ContainsKey($luis[0])) { - $intents = $dictionary[$luis[0]] - $intents += $luis[1] - $dictionary[$luis[0]] = $intents - } - else { - $dictionary.Add($luis[0], @($luis[1])) - } - } - } - } -} - -Write-Host "> Adding skill to dispatch ..." try { - $intentName = $manifest.Id - foreach ($luisApp in $dictionary.Keys) { - $intents = $dictionary[$luisApp] - $luFile = Get-ChildItem -Path $(Join-Path $luisFolder "$($luisApp).lu") ` 2>> $logFile - - if (-not $luFile) { - $luFile = Get-ChildItem -Path $(Join-Path $luisFolder $langCode "$($luisApp).lu") ` 2>> $logFile - - if ($luFile) { - $luisFolder = $(Join-Path $luisFolder $langCode) - } - else { - Write-Host "! Could not find $($manifest.Name) LU file. Please provide the -luisFolder parameter." -ForegroundColor DarkRed - Write-Host "! Checked the following locations:" -ForegroundColor DarkRed - Write-Host " $(Join-Path $luisFolder "$($luisApp).lu")" -ForegroundColor DarkRed - Write-Host " $(Join-Path $luisFolder $langCode "$($luisApp).lu")" -ForegroundColor DarkRed - Throw - } + foreach ($action in $manifest.actions) { + if ($action.definition.triggers.utteranceSources) { + $sources = @{} + foreach ($source in ($action.definition.triggers.utteranceSources | Where-Object {$_.locale -eq $langCode})) { + foreach ($luisStr in $source.source) { + $luis = $luisStr -Split '#' + if ($sources.ContainsKey($luis[0])) { + $intents = $sources[$luis[0]] + $intents += $luis[1] + $sources[$luis[0]] = $intents + } + else { + $sources.Add($luis[0], @($luis[1])) + } + } + } + + Write-Host "> Adding $($action.id) action to dispatch ..." + foreach ($luisApp in $sources.Keys) { + $intents = $sources[$luisApp] + $luFile = Get-ChildItem -Path $(Join-Path $luisFolder "$($luisApp).lu") ` 2>> $logFile + + if (-not $luFile) { + $luFile = Get-ChildItem -Path $(Join-Path $luisFolder $langCode "$($luisApp).lu") ` 2>> $logFile + + if ($luFile) { + $luisFolder = $(Join-Path $luisFolder $langCode) + } + else { + Write-Host "! Could not find $($manifest.Name) LU file. Please provide the -luisFolder parameter." -ForegroundColor DarkRed + Write-Host "! Checked the following locations:" -ForegroundColor DarkRed + Write-Host " $(Join-Path $luisFolder "$($luisApp).lu")" -ForegroundColor DarkRed + Write-Host " $(Join-Path $luisFolder $langCode "$($luisApp).lu")" -ForegroundColor DarkRed + Throw + } + } + + # Parse LU file + ludown parse toluis ` + --in $luFile ` + --luis_culture $language ` + --out_folder $luisFolder ` + --out "$($luisApp).luis" + + $luisFile = Get-ChildItem ` + -Path $luisFolder ` + -Filter "$($luisApp).luis" ` + -Recurse ` + -Force 2>> $logFile + + if ($luisFile) { + (dispatch add ` + --type file ` + --filePath $luisFile ` + --name $action.id ` + --intentName $action.id ` + --includedIntents $intents ` + --dataFolder $dispatchFolder ` + --dispatch $(Join-Path $dispatchFolder "$($dispatchName).dispatch")) 2>> $logFile | Out-Null + } + else { + Write-Host "! Could not find LUIS file: $(Join-Path $luisFolder "$($luisApp).luis")" -ForegroundColor DarkRed + Break + } + } } - - # Parse LU file - ludown parse toluis ` - --in $luFile ` - --luis_culture $language ` - --out_folder $luisFolder ` - --out "$($luisApp).luis" - - $luisFile = Get-ChildItem ` - -Path $luisFolder ` - -Filter "$($luisApp).luis" ` - -Recurse ` - -Force 2>> $logFile - - if ($luisFile) { - (dispatch add ` - --type file ` - --filePath $luisFile ` - --intentName $intentName ` - --dataFolder $dispatchFolder ` - --dispatch $(Join-Path $dispatchFolder "$($dispatchName).dispatch")) 2>> $logFile | Out-Null - } - else { - Write-Host "! Could not find LUIS file: $(Join-Path $luisFolder "$($luisApp).luis")" -ForegroundColor DarkRed - Break - } - } + } } catch { Break @@ -284,10 +285,12 @@ if ($manifest.authenticationConnections) { } } +Write-Host "> Done." + if ($manualScopesRequired) { Write-Host "+ Could not configure scopes automatically. You must configure the following scopes in the Azure Portal to use this skill: $($newScopes -Join ', ')" -ForegroundColor Magenta } if ($manualAuthRequired) { Write-Host "+ Could not configure authentication connection automatically. You must configure one of the following connection types manually in the Azure Portal: $($manifest.authenticationConnections.serviceProviderId -Join ', ')" -ForegroundColor Magenta -} \ No newline at end of file +} diff --git a/templates/Virtual-Assistant-Template/csharp/Template/VA/Deployment/Scripts/deploy.ps1 b/templates/Virtual-Assistant-Template/csharp/Template/VA/Deployment/Scripts/deploy.ps1 index 76eaa462a0..b4a09ee834 100644 --- a/templates/Virtual-Assistant-Template/csharp/Template/VA/Deployment/Scripts/deploy.ps1 +++ b/templates/Virtual-Assistant-Template/csharp/Template/VA/Deployment/Scripts/deploy.ps1 @@ -153,4 +153,6 @@ $settings | Add-Member -Type NoteProperty -Force -Name 'contentModerator' -Value $settings | ConvertTo-Json -depth 100 | Out-File $(Join-Path $outFolder appsettings.json) # Deploy cognitive models -Invoke-Expression "$(Join-Path $PSScriptRoot 'deploy_cognitive_models.ps1') -name $($name) -luisAuthoringRegion $($luisAuthoringRegion) -luisAuthoringKey $($luisAuthoringKey) -qnaSubscriptionKey $($outputs.qnaMaker.value.key) -outFolder $($outFolder)" \ No newline at end of file +Invoke-Expression "$(Join-Path $PSScriptRoot 'deploy_cognitive_models.ps1') -name $($name) -luisAuthoringRegion $($luisAuthoringRegion) -luisAuthoringKey $($luisAuthoringKey) -qnaSubscriptionKey $($outputs.qnaMaker.value.key) -outFolder $($outFolder)" + +Write-Host "> Done." \ No newline at end of file diff --git a/templates/Virtual-Assistant-Template/csharp/Template/VA/Deployment/Scripts/remove_skill.ps1 b/templates/Virtual-Assistant-Template/csharp/Template/VA/Deployment/Scripts/remove_skill.ps1 index 5821931a6f..af1011e6f7 100644 --- a/templates/Virtual-Assistant-Template/csharp/Template/VA/Deployment/Scripts/remove_skill.ps1 +++ b/templates/Virtual-Assistant-Template/csharp/Template/VA/Deployment/Scripts/remove_skill.ps1 @@ -67,48 +67,17 @@ if (-not $manifest) { Break } -Write-Host "> Getting intents for dispatch ..." -$dictionary = @{ } -foreach ($action in $manifest.actions) { - if ($action.definition.triggers.utteranceSources) { - foreach ($source in $action.definition.triggers.utteranceSources) { - foreach ($luisStr in $source.source) { - $luis = $luisStr -Split '#' - if ($dictionary.ContainsKey($luis[0])) { - $intents = $dictionary[$luis[0]] - $intents += $luis[1] - $dictionary[$luis[0]] = $intents - } - else { - $dictionary.Add($luis[0], @($luis[1])) - } - } - } - } -} - Write-Host "> Removing skill from dispatch ..." -try { - $intentName = $manifest.Id - $dispatch = Get-Content $dispatchPath | ConvertFrom-Json - - if ($dispatch.services) { - foreach ($luisApp in $dictionary.Keys) { - $intents = $dictionary[$luisApp] - $toRemove = $dispatch.services | Where-Object { $_.name -eq $luisApp } - $dispatch.services = $dispatch.services | Where-Object -FilterScript { $_.name -ne $luisApp } - $dispatch.serviceIds = $dispatch.serviceIds | Where-Object -FilterScript { $toRemove.id -notcontains $_ } - } - - $dispatch | ConvertTo-Json -depth 100 | Out-File $dispatchPath - } - else { - Write-Host "! No services found in file: $($dispatchPath)" -ForegroundColor DarkRed - Break - } +$dispatch = Get-Content $dispatchPath | ConvertFrom-Json +if ($dispatch.services) { + $toRemove = $dispatch.services | Where-Object { $manifest.actions.id -contains $_.name } + $dispatch.services = $dispatch.services | Where-Object -FilterScript { $manifest.actions.id -notcontains $_.name } + $dispatch.serviceIds = $dispatch.serviceIds | Where-Object -FilterScript { $toRemove.id -notcontains $_ } + + $dispatch | ConvertTo-Json -depth 100 | Out-File $dispatchPath } -catch { - Break +else { + Write-Host "! No services found in file: $($dispatchPath)" -ForegroundColor DarkRed } Write-Host "> Running dispatch refresh ..." @@ -143,4 +112,6 @@ if (Test-Path $skillsFile) { } else { Write-Host "! Could not find file: $($skillFile)" -ForegroundColor Cyan -} \ No newline at end of file +} + +Write-Host "> Done." \ No newline at end of file diff --git a/templates/Virtual-Assistant-Template/csharp/Template/VA/Dialogs/MainDialog.cs b/templates/Virtual-Assistant-Template/csharp/Template/VA/Dialogs/MainDialog.cs index 7f83d58e2a..8445d83881 100644 --- a/templates/Virtual-Assistant-Template/csharp/Template/VA/Dialogs/MainDialog.cs +++ b/templates/Virtual-Assistant-Template/csharp/Template/VA/Dialogs/MainDialog.cs @@ -105,7 +105,7 @@ protected override async Task OnInterruptDialogAsync(DialogC { // We have identiifed a skill so initialize the skill connection with the target skill // the dispatch intent is the Action ID of the Skill enabling us to resolve the specific action and identify slots - await dc.BeginDialogAsync(identifiedSkill.Id, intent); + await dc.BeginDialogAsync(identifiedSkill.Id, intent.ToString()); // Pass the activity we have var result = await dc.ContinueDialogAsync();