Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
support dispatch with skill intents (#1187)
Browse files Browse the repository at this point in the history
  • Loading branch information
lauren-mills authored Apr 29, 2019
1 parent 667cbbd commit 58d0029
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public override async Task EndDialogAsync(ITurnContext turnContext, DialogInstan
/// <param name="options">options.</param>
/// <param name="cancellationToken">cancellation token.</param>
/// <returns>dialog turn result.</returns>
protected override async Task<DialogTurnResult> OnBeginDialogAsync(DialogContext innerDc, object options, CancellationToken cancellationToken = default(CancellationToken))
protected override async Task<DialogTurnResult> OnBeginDialogAsync(DialogContext innerDc, object options = null, CancellationToken cancellationToken = default(CancellationToken))
{
SkillContext slots = new SkillContext();

Expand All @@ -95,7 +95,7 @@ public override async Task EndDialogAsync(ITurnContext turnContext, DialogInstan
In other scenarios (aggregated skill dispatch) we evaluate all possible slots against context and pass across
enabling the Skill to perform it's own action identification. */

var actionName = options as string;
var actionName = options != null ? options as string : null;
if (actionName != null)
{
// Find the specified within the selected Skill for slot filling evaluation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ public static class SkillRouter
/// <returns>Whether the intent matches a Skill.</returns>
public static SkillManifest IsSkill(List<SkillManifest> skillConfiguration, string dispatchIntent)
{
return skillConfiguration.SingleOrDefault(s => s.Actions.Any(a => a.Id == dispatchIntent.ToString()));
var manifest = skillConfiguration.SingleOrDefault(s => s.Actions.Any(a => a.Id == dispatchIntent.ToString()));

if (manifest == null)
{
manifest = skillConfiguration.SingleOrDefault(s => s.Id == dispatchIntent.ToString());
}

return manifest;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,62 @@ catch {
Break
}



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
}
}

# 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 `
--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
}
}
}
catch {
Break
}

Write-Host "> Running dispatch refresh ..."
(dispatch refresh `
--dispatch $(Join-Path $dispatchFolder "$($dispatchName).dispatch") `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected override async Task<InterruptionAction> 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.ToString());
await dc.BeginDialogAsync(identifiedSkill.Id);

// Pass the activity we have
var result = await dc.ContinueDialogAsync();
Expand Down

0 comments on commit 58d0029

Please sign in to comment.