Skip to content

Commit

Permalink
Lamil/bugfixes (microsoft#272)
Browse files Browse the repository at this point in the history
* fixed auth bug for skills without auth

* changed skill configuration to use TelemetryLuisRecognizer

* added handler for trace activities sent from skills

* updated cancel message if no active dialog is found

* updated "nothing to cancel" message for all languages
  • Loading branch information
lauren-mills authored Nov 10, 2018
1 parent 6f3232f commit ae873ca
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,8 @@ public MainDialog(BotServices services, BotConfiguration botConfig, Conversation

case General.Intent.Cancel:
{
// send cancelled response
await _responder.ReplyWith(dc.Context, MainResponses.Cancelled);

// Cancel any active dialogs on the stack
await dc.CancelAllDialogsAsync();
// if this was triggered, then there is no active dialog
await _responder.ReplyWith(dc.Context, MainResponses.NoActiveDialog);
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ public class MainResponses : TemplateManager
public const string Greeting = "greeting";
public const string Help = "help";
public const string Intro = "intro";
public const string NoActiveDialog = "noActiveDialog";

private static LanguageTemplateDictionary _responseTemplates = new LanguageTemplateDictionary
{
["default"] = new TemplateIdMap
{
{ Cancelled, (context, data) => SendAcceptingInputReply(context, MainStrings.CANCELLED) },
{ NoActiveDialog, (context, data) => SendAcceptingInputReply(context, MainStrings.NO_ACTIVE_DIALOG) },
{ Completed, (context, data) => SendAcceptingInputReply(context, MainStrings.COMPLETED) },
{ Confused, (context, data) => SendAcceptingInputReply(context, MainStrings.CONFUSED) },
{ Greeting, (context, data) => SendAcceptingInputReply(context, MainStrings.GREETING) },
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@
<data name="MEETING_SUGGESTEDACTION" xml:space="preserve">
<value>Ein Treffen planen</value>
</data>
<data name="NO_ACTIVE_DIALOG" xml:space="preserve">
<value>Es sieht so aus, als gäbe es nichts zu kündigen. Was kann ich Ihnen helfen?</value>
</data>
<data name="POI_SUGGESTEDACTION" xml:space="preserve">
<value>Ein Café in der Nähe finden</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@
<data name="MEETING_SUGGESTEDACTION" xml:space="preserve">
<value>Programar una reunión</value>
</data>
<data name="NO_ACTIVE_DIALOG" xml:space="preserve">
<value>Parece que no hay nada que cancelar. ¿En qué puedo ayudarle?</value>
</data>
<data name="POI_SUGGESTEDACTION" xml:space="preserve">
<value>Encuentre una cafetería cerca</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@
<data name="MEETING_SUGGESTEDACTION" xml:space="preserve">
<value>Planifier une réunion</value>
</data>
<data name="NO_ACTIVE_DIALOG" xml:space="preserve">
<value>On dirait qu'il n'y a rien à annuler. Que puis-je pour vous?</value>
</data>
<data name="POI_SUGGESTEDACTION" xml:space="preserve">
<value>Trouver un Coffee Shop à proximité</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@
<data name="MEETING_SUGGESTEDACTION" xml:space="preserve">
<value>Pianificare una riunione</value>
</data>
<data name="NO_ACTIVE_DIALOG" xml:space="preserve">
<value>Sembra che non c'è nulla da cancellare. Cosa posso aiutarvi?</value>
</data>
<data name="POI_SUGGESTEDACTION" xml:space="preserve">
<value>Trova un coffee shop nelle vicinanze</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@
<data name="MEETING_SUGGESTEDACTION" xml:space="preserve">
<value>Schedule a meeting</value>
</data>
<data name="NO_ACTIVE_DIALOG" xml:space="preserve">
<value>It looks like there is nothing to cancel. What can I help you with?</value>
</data>
<data name="POI_SUGGESTEDACTION" xml:space="preserve">
<value>Find a coffee shop nearby</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@
<data name="MEETING_SUGGESTEDACTION" xml:space="preserve">
<value>安排会议</value>
</data>
<data name="NO_ACTIVE_DIALOG" xml:space="preserve">
<value>看来没有什么可以取消的。有什么需要我帮忙的吗?</value>
</data>
<data name="POI_SUGGESTEDACTION" xml:space="preserve">
<value>查找附近的咖啡店</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public MultiProviderAuthDialog(ISkillConfiguration skillConfiguration)
{
_skillConfiguration = skillConfiguration;

if (!_skillConfiguration.AuthenticationConnections.Any())
if (_skillConfiguration.IsAuthenticatedSkill && !_skillConfiguration.AuthenticationConnections.Any())
{
throw new Exception("You must configure an authentication connection in your bot file before using this component.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace Microsoft.Bot.Solutions.Skills
{
public abstract class ISkillConfiguration
{
public bool IsAuthenticatedSkill { get; set; }

public abstract Dictionary<string, string> AuthenticationConnections { get; set; }

public abstract TelemetryClient TelemetryClient { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.Bot.Builder;
Expand All @@ -16,6 +17,11 @@ public SkillConfiguration()

public SkillConfiguration(BotConfiguration botConfiguration, string[] supportedProviders, string[] parameters, Dictionary<string, object> configuration)
{
if (supportedProviders != null && supportedProviders.Count() > 0)
{
IsAuthenticatedSkill = true;
}

foreach (var service in botConfiguration.Services)
{
switch (service.Type)
Expand All @@ -32,7 +38,7 @@ public SkillConfiguration(BotConfiguration botConfiguration, string[] supportedP
{
var luis = service as LuisService;
var luisApp = new LuisApplication(luis.AppId, luis.SubscriptionKey, luis.GetEndpoint());
LuisServices.Add(service.Id, new LuisRecognizer(luisApp));
LuisServices.Add(service.Id, new TelemetryLuisRecognizer(luisApp));
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,15 @@ public async Task<DialogTurnResult> ForwardToSkill(DialogContext dc, Activity ac
}
else
{
queue.Add(skillResponse);
if (skillResponse.Type == ActivityTypes.Trace)
{
// Write out any trace messages from the skill to the emulator
await dc.Context.SendActivityAsync(skillResponse);
}
else
{
queue.Add(skillResponse);
}
}

skillResponse = _inProcAdapter.GetNextReply();
Expand All @@ -257,11 +265,7 @@ public async Task<DialogTurnResult> ForwardToSkill(DialogContext dc, Activity ac
// handle ending the skill conversation
if (endOfConversation)
{
await dc.Context.SendActivityAsync(
new Activity(
type: ActivityTypes.Trace,
text: $"<--Ending the skill conversation"
));
await dc.Context.SendActivityAsync(new Activity(type: ActivityTypes.Trace, text: $"<--Ending the skill conversation"));

return await dc.EndDialogAsync();
}
Expand Down

0 comments on commit ae873ca

Please sign in to comment.