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

[Skills& VA] Fallback rule support #1971

Merged
merged 8 commits into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/csharp/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<PropertyGroup>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
DingmaomaoBJTU marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>

<ItemGroup>
Expand Down
20 changes: 20 additions & 0 deletions skills/src/csharp/Skills.sln
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeatherSkill", "experimenta
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BingSearchSkill", "experimental\bingsearchskill\bingsearchskill\BingSearchSkill.csproj", "{8CB101FA-B496-4507-80A2-151FAB7E8ED1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Bot.Builder.Skills", "..\..\..\lib\csharp\microsoft.bot.builder.skills\Microsoft.Bot.Builder.Skills\Microsoft.Bot.Builder.Skills.csproj", "{B25E0652-3BCE-4EEE-86CB-F38660CC9736}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Bot.Builder.Solutions", "..\..\..\lib\csharp\microsoft.bot.builder.solutions\microsoft.bot.builder.solutions\Microsoft.Bot.Builder.Solutions.csproj", "{2BBFC7CC-34F2-4D05-9DDE-99380E2E592E}"
DingmaomaoBJTU marked this conversation as resolved.
Show resolved Hide resolved
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug - NuGet Packages|Any CPU = Debug - NuGet Packages|Any CPU
Expand Down Expand Up @@ -157,6 +161,22 @@ Global
{8CB101FA-B496-4507-80A2-151FAB7E8ED1}.Documentation|Any CPU.Build.0 = Debug|Any CPU
{8CB101FA-B496-4507-80A2-151FAB7E8ED1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8CB101FA-B496-4507-80A2-151FAB7E8ED1}.Release|Any CPU.Build.0 = Release|Any CPU
{B25E0652-3BCE-4EEE-86CB-F38660CC9736}.Debug - NuGet Packages|Any CPU.ActiveCfg = Debug - NuGet Packages|Any CPU
{B25E0652-3BCE-4EEE-86CB-F38660CC9736}.Debug - NuGet Packages|Any CPU.Build.0 = Debug - NuGet Packages|Any CPU
{B25E0652-3BCE-4EEE-86CB-F38660CC9736}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B25E0652-3BCE-4EEE-86CB-F38660CC9736}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B25E0652-3BCE-4EEE-86CB-F38660CC9736}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
{B25E0652-3BCE-4EEE-86CB-F38660CC9736}.Documentation|Any CPU.Build.0 = Documentation|Any CPU
{B25E0652-3BCE-4EEE-86CB-F38660CC9736}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B25E0652-3BCE-4EEE-86CB-F38660CC9736}.Release|Any CPU.Build.0 = Release|Any CPU
{2BBFC7CC-34F2-4D05-9DDE-99380E2E592E}.Debug - NuGet Packages|Any CPU.ActiveCfg = Debug - NuGet Packages|Any CPU
{2BBFC7CC-34F2-4D05-9DDE-99380E2E592E}.Debug - NuGet Packages|Any CPU.Build.0 = Debug - NuGet Packages|Any CPU
{2BBFC7CC-34F2-4D05-9DDE-99380E2E592E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2BBFC7CC-34F2-4D05-9DDE-99380E2E592E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2BBFC7CC-34F2-4D05-9DDE-99380E2E592E}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
{2BBFC7CC-34F2-4D05-9DDE-99380E2E592E}.Documentation|Any CPU.Build.0 = Documentation|Any CPU
{2BBFC7CC-34F2-4D05-9DDE-99380E2E592E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2BBFC7CC-34F2-4D05-9DDE-99380E2E592E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@
<EmbeddedResource Include="Utilities\WindowsIanaMapping" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\..\lib\csharp\microsoft.bot.builder.skills\Microsoft.Bot.Builder.Skills\Microsoft.Bot.Builder.Skills.csproj" />
<ProjectReference Include="..\..\..\..\..\lib\csharp\microsoft.bot.builder.solutions\microsoft.bot.builder.solutions\Microsoft.Bot.Builder.Solutions.csproj" />
DingmaomaoBJTU marked this conversation as resolved.
Show resolved Hide resolved
</ItemGroup>

<ItemGroup>
<Compile Update="Dialogs\DeleteEvent\Resources\ChangeEventStatusResponses.cs">
<DesignTime>True</DesignTime>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ private async Task PopulateStateFromSemanticAction(ITurnContext context)
switch (dc.Context.Activity.Name)
{
case TokenEvents.TokenResponseEventName:
case SkillEvents.FallbackHandledEventName:
{
// Auth dialog completion
var result = await dc.ContinueDialogAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CalendarSkill.Adapters;
using CalendarSkill.Models;
using CalendarSkill.Responses.Shared;
using CalendarSkill.Responses.Summary;
Expand All @@ -13,6 +14,8 @@
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Builder.Skills;
using Microsoft.Bot.Builder.Skills.Models;
using Microsoft.Bot.Builder.Solutions;
using Microsoft.Bot.Builder.Solutions.Resources;
using Microsoft.Bot.Builder.Solutions.Responses;
using Microsoft.Bot.Builder.Solutions.Util;
Expand Down Expand Up @@ -69,13 +72,22 @@ public SummaryDialog(
AfterReadOutEvent,
};

var retryUnknown = new WaterfallStep[]
{
SendFallback,
RetryInput,
HandleActions,
};

// Define the conversation flow using a waterfall model.
AddDialog(new WaterfallDialog(Actions.GetEventsInit, initStep) { TelemetryClient = telemetryClient });
AddDialog(new WaterfallDialog(Actions.ShowNextEvent, showNext) { TelemetryClient = telemetryClient });
AddDialog(new WaterfallDialog(Actions.ShowEventsSummary, showSummary) { TelemetryClient = telemetryClient });
AddDialog(new WaterfallDialog(Actions.Read, readEvent) { TelemetryClient = telemetryClient });
AddDialog(updateEventDialog ?? throw new ArgumentNullException(nameof(updateEventDialog)));
AddDialog(changeEventStatusDialog ?? throw new ArgumentNullException(nameof(changeEventStatusDialog)));
AddDialog(new WaterfallDialog(Actions.RetryUnknown, retryUnknown) { TelemetryClient = telemetryClient });
AddDialog(new EventPrompt(Actions.FallbackEventPrompt, SkillEvents.FallbackHandledEventName, ResponseValidatorAsync));

// Set starting dialog for component
InitialDialogId = Actions.GetEventsInit;
Expand Down Expand Up @@ -641,7 +653,7 @@ await sc.Context.SendActivityAsync(await GetOverviewMeetingListResponseAsync(
return await sc.BeginDialogAsync(Actions.Read, sc.Options);
}

return await sc.NextAsync();
return await sc.ReplaceDialogAsync(Actions.RetryUnknown, sc.Options);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -831,5 +843,57 @@ private bool SearchesTodayMeeting(CalendarSkillState state)
!state.EndTime.Any() &&
EventModel.IsSameDate(searchDate, userNow);
}

protected Task<bool> ResponseValidatorAsync(PromptValidatorContext<Activity> pc, CancellationToken cancellationToken)
{
var activity = pc.Recognized.Value;
if (activity != null && activity.Type == ActivityTypes.Event && activity.Name == SkillEvents.FallbackHandledEventName)
{
return Task.FromResult(true);
}

return Task.FromResult(false);
}

protected async Task<DialogTurnResult> SendFallback(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
var state = await Accessor.GetAsync(sc.Context);

// Send Fallback Event
if (sc.Context.Adapter is CalendarSkillWebSocketBotAdapter remoteInvocationAdapter)
{
await remoteInvocationAdapter.SendRemoteFallbackEventAsync(sc.Context, cancellationToken).ConfigureAwait(false);

// Wait for the FallbackHandle event
return await sc.PromptAsync(Actions.FallbackEventPrompt, new PromptOptions()).ConfigureAwait(false);
}

return await sc.NextAsync();
}
catch (Exception ex)
{
await HandleDialogExceptions(sc, ex);

return new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs);
}
}

protected async Task<DialogTurnResult> RetryInput(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
var state = await Accessor.GetAsync(sc.Context);

return await sc.PromptAsync(Actions.Prompt, new PromptOptions { Prompt = ResponseManager.GetResponse(CalendarSharedResponses.RetryInput) });
}
catch (Exception ex)
{
await HandleDialogExceptions(sc, ex);

return new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ public class CalendarSharedResponses : IResponseIdCollection
public const string ActionEnded = "ActionEnded";
public const string CalendarErrorMessage = "CalendarErrorMessage";
public const string CalendarErrorMessageBotProblem = "CalendarErrorMessageBotProblem";
public const string RetryInput = "RetryInput";
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,90 +1,99 @@
{
"DidntUnderstandMessage": {
"replies": [
{
"text": "Sorry, I didn't understand what you meant.",
"speak": "Sorry, I didn't understand what you meant."
},
{
"text": "I didn't understand, perhaps try again in a different way.",
"speak": "I didn't understand, perhaps try again in a different way."
},
{
"text": "Can you try to ask in a different way?",
"speak": "Can you try to ask in a different way?"
},
{
"text": "I didn't get what you mean, can you try in a different way?",
"speak": "I didn't get what you mean, can you try in a different way?"
},
{
"text": "Could you elaborate?",
"speak": "Could you elaborate?"
},
{
"text": "Please say that again in a different way.",
"speak": "Please say that again in a different way."
},
{
"text": "I didn't quite get that.",
"speak": "I didn't quite get that."
},
{
"text": "Can you say that in a different way?",
"speak": "Can you say that in a different way?"
},
{
"text": "Can you try to ask me again? I didn't get what you mean.",
"speak": "Can you try to ask me again? I didn't get what you mean."
}
],
"inputHint": "expectingInput"
},
"ActionEnded": {
"replies": [
{
"text": "Let me know if you need my help with something else.",
"speak": "Let me know if you need my help with something else."
},
{
"text": "I'm here if you need me.",
"speak": "I'm here if you need me."
}
],
"inputHint": "acceptingInput"
},
"CalendarErrorMessage": {
"replies": [
{
"text": "Sorry, it looks like something went wrong!",
"speak": "Sorry, it looks like something went wrong!"
},
{
"text": "An error occurred, please try again later.",
"speak": "An error occurred, please try again later."
},
{
"text": "Something went wrong, sorry!",
"speak": "Something went wrong, sorry!"
},
{
"text": "It seems like something went wrong. Can you try again later?",
"speak": "It seems like something went wrong. Can you try again later?"
},
{
"text": "Sorry I can't help right now. Please try again later.",
"speak": "Sorry I can't help right now. Please try again later."
}
],
"inputHint": "acceptingInput"
},
"CalendarErrorMessageBotProblem": {
"replies": [
{
"text": "Sorry, there is something wrong with the bot at the moment. The developer has been notified about it so you'll be able to perform the action again very soon.",
"speak": "Sorry, there is something wrong with the bot at the moment. The developer has been notified about it so you'll be able to perform the action again very soon."
}
],
"inputHint": "acceptingInput"
}
"DidntUnderstandMessage": {
"replies": [
{
"text": "Sorry, I didn't understand what you meant.",
"speak": "Sorry, I didn't understand what you meant."
},
{
"text": "I didn't understand, perhaps try again in a different way.",
"speak": "I didn't understand, perhaps try again in a different way."
},
{
"text": "Can you try to ask in a different way?",
"speak": "Can you try to ask in a different way?"
},
{
"text": "I didn't get what you mean, can you try in a different way?",
"speak": "I didn't get what you mean, can you try in a different way?"
},
{
"text": "Could you elaborate?",
"speak": "Could you elaborate?"
},
{
"text": "Please say that again in a different way.",
"speak": "Please say that again in a different way."
},
{
"text": "I didn't quite get that.",
"speak": "I didn't quite get that."
},
{
"text": "Can you say that in a different way?",
"speak": "Can you say that in a different way?"
},
{
"text": "Can you try to ask me again? I didn't get what you mean.",
"speak": "Can you try to ask me again? I didn't get what you mean."
}
],
"inputHint": "expectingInput"
},
"ActionEnded": {
"replies": [
{
"text": "Let me know if you need my help with something else.",
"speak": "Let me know if you need my help with something else."
},
{
"text": "I'm here if you need me.",
"speak": "I'm here if you need me."
}
],
"inputHint": "acceptingInput"
},
"CalendarErrorMessage": {
"replies": [
{
"text": "Sorry, it looks like something went wrong!",
"speak": "Sorry, it looks like something went wrong!"
},
{
"text": "An error occurred, please try again later.",
"speak": "An error occurred, please try again later."
},
{
"text": "Something went wrong, sorry!",
"speak": "Something went wrong, sorry!"
},
{
"text": "It seems like something went wrong. Can you try again later?",
"speak": "It seems like something went wrong. Can you try again later?"
},
{
"text": "Sorry I can't help right now. Please try again later.",
"speak": "Sorry I can't help right now. Please try again later."
}
],
"inputHint": "acceptingInput"
},
"CalendarErrorMessageBotProblem": {
"replies": [
{
"text": "Sorry, there is something wrong with the bot at the moment. The developer has been notified about it so you'll be able to perform the action again very soon.",
"speak": "Sorry, there is something wrong with the bot at the moment. The developer has been notified about it so you'll be able to perform the action again very soon."
}
],
"inputHint": "acceptingInput"
},
"RetryInput": {
"replies": [
{
"text": "Sorry, I don't understand what you mean. Could you please try again?",
"speak": "Sorry, I don't understand what you mean. Could you please try again?"
}
],
"inputHint": "expectingInput"
}
}
Loading