var queryResult = await LuisActionResolver.QueryValueFromLuisAsync(luisService, intentAction, paramName, input, CancellationToken.None);
if (!queryResult.Succeed && !string.IsNullOrWhiteSpace(queryResult.NewIntent) && queryResult.NewAction != null)
{
var newActionDefinition = LuisActionResolver.GetActionDefinition(queryResult.NewAction);
var currentActionDefinition = LuisActionResolver.GetActionDefinition(intentAction);
var isContextual = false;
if (LuisActionResolver.IsValidContextualAction(queryResult.NewAction, intentAction, out isContextual))
{
var executionContextChain = new List<ActionExecutionContext> { new ActionExecutionContext(queryResult.NewIntent, queryResult.NewAction) };
var executionContext = await RunActions(luisService, executionContextChain);
if (executionContext.ChangeRootSignaling)
{
if (LuisActionResolver.IsContextualAction(intentAction))
{
return executionContext;
}
else
{
intentAction = executionContext.Action;
}
}
}
else if (isContextual && !LuisActionResolver.IsContextualAction(intentAction))
{
Console.WriteLine($"Cannot execute action '{newActionDefinition.FriendlyName}' in the context of '{currentActionDefinition.FriendlyName}' - continuing with current action");
}
else
{
var valid = LuisActionResolver.UpdateIfValidContextualAction(queryResult.NewAction, intentAction, out isContextual);
if (!valid && isContextual)
{
Console.WriteLine($"Cannot switch to action '{newActionDefinition.FriendlyName}' from '{currentActionDefinition.FriendlyName}' due to invalid context - continuing with current action");
}
else if (currentActionDefinition.ConfirmOnSwitchingContext)
{
Console.Write($"You are about to discard the current action '{currentActionDefinition.FriendlyName}' and start executing '{newActionDefinition.FriendlyName}'\nContinue? ");
var response = Console.ReadLine();
if (response.ToUpperInvariant().StartsWith("Y"))
{
if (LuisActionResolver.IsContextualAction(intentAction) && !LuisActionResolver.IsContextualAction(queryResult.NewAction))
{
return new ActionExecutionContext(queryResult.NewIntent, queryResult.NewAction) { ChangeRootSignaling = true };
// We just show the ToString() of the result - not care about the result type here
Console.WriteLine(result != null ? result.ToString() : "Cannot resolve your query");
return actionExecutionContext;
}
private static async Task RunQuery(string query)
{
// Process message
var luisService = new LuisService(new LuisModelAttribute(ConfigurationManager.AppSettings["LUIS_ModelId"], ConfigurationManager.AppSettings["LUIS_SubscriptionKey"]));
var luisResult = await luisService.QueryAsync(query, CancellationToken.None);
// Try to resolve intent to action
var intentName = default(string);
var intentEntities = default(IList<EntityRecommendation>);
var intentAction = new LuisActionResolver(typeof(GetTimeInPlaceAction).Assembly)
.ResolveActionFromLuisIntent(luisResult, out intentName, out intentEntities);
if (intentAction != null)
{
var executionContextChain = new List<ActionExecutionContext> { new ActionExecutionContext(intentName, intentAction) };
while (LuisActionResolver.IsContextualAction(intentAction))
{
var luisActionDefinition = default(LuisActionBindingAttribute);
if (!LuisActionResolver.CanStartWithNoContextAction(intentAction, out luisActionDefinition))
{
Console.WriteLine($"Cannot start contextual action '{luisActionDefinition.FriendlyName}' without a valid context.");
return;
}
intentAction = LuisActionResolver.BuildContextForContextualAction(intentAction, out intentName);
if (intentAction != null)
{
executionContextChain.Insert(0, new ActionExecutionContext(intentName, intentAction));
Press p or to see the previous file or,
n or to see the next file
Comments
Integrate AWS S3
Use S3 remote
Select bucket
Access key
Finish
Use AWS S3 as storage!
Browsing data directories saved to S3 is possible with DAGsHub. Let's configure
your repository to easily display your data in the context of any commit!
Specify your S3 bucket
Select Region
af-south-1 - Africa (Cape Town)
ap-northeast-1 - Asia Pacific (Tokyo)
ap-northeast-2 - Asia Pacific (Seoul)
ap-south-1 - Asia Pacific (Mumbai)
ap-southeast-1 - Asia Pacific (Singapore)
ap-southeast-2 - Asia Pacific (Sydney)
ca-central-1 - Canada (Central)
eu-central-1 - EU (Frankfurt)
eu-north-1 - EU (Stockholm)
eu-west-1 - EU (Ireland)
eu-west-2 - EU (London)
eu-west-3 - EU (Paris)
sa-east-1 - South America (São Paulo)
us-east-1 - US East (N. Virginia)
us-east-2 - US East (Ohio)
us-gov-east-1 - US Gov East 1
us-gov-west-1 - US Gov West 1
us-west-1 - US West (N. California)
us-west-2 - US West (Oregon)
Congratulations!
BotBuilder-Samples is now integrated with AWS S3!
Delete Storage Key
Are you sure you want to delete this access key?
No
Yes
Integrate Google Cloud Storage
Use Google Storage
Select bucket
Upload key
Finish
Use Google Cloud Storage!
Browsing data directories saved to Google Cloud Storage is possible with DAGsHub. Let's configure
your repository to easily display your data in the context of any commit!
Specify your Google Storage bucket
Congratulations!
BotBuilder-Samples is now integrated with Google Cloud Storage!
Delete Storage Key
Are you sure you want to delete this access key?
No
Yes
Integrate Azure Cloud Storage
Use Azure Storage
Select bucket
Set key
Finish
Use Azure Cloud Storage!
Browsing data directories saved to Azure Cloud Storage is possible with DAGsHub. Let's configure
your repository to easily display your data in the context of any commit!
Specify your Azure Storage bucket
Congratulations!
BotBuilder-Samples is now integrated with Azure Cloud Storage!
Delete Storage Key
Are you sure you want to delete this access key?
No
Yes
Integrate S3 compatible storage
Use S3 like remote
Select bucket
Access key
Finish
Use any S3 compatible storage!
Browsing data directories saved to S3 compatible storage is possible with DAGsHub. Let's configure
your repository to easily display your data in the context of any commit!
Specify your S3 bucket
Bucket name cannot be the same as the repository name. Please change one of them.
Check this box only if you trust this domain, otherwise your data and credentials might be
stolen by man in the middle or spoofing attacks.
Congratulations!
BotBuilder-Samples is now integrated with your S3 compatible storage!