Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@

namespace Microsoft.Bot.Builder.Skills.Tests.Mocks
{
public class MockSkillTransport : ISkillTransport
{
private Activity _activityForwarded;
public class MockSkillTransport : ISkillTransport
{
private Activity _activityForwarded;

public Task CancelRemoteDialogsAsync(SkillManifest skillManifest, IServiceClientCredentials serviceClientCredentials, ITurnContext turnContext)
{
return Task.CompletedTask;
}

public void Disconnect()
{
}
public void Disconnect()
{
}

public Task<bool> ForwardToSkillAsync(SkillManifest skillManifest, IServiceClientCredentials serviceClientCredentials, ITurnContext dialogContext, Activity activity, Action<Activity> tokenRequestHandler = null)
public Task<bool> ForwardToSkillAsync(SkillManifest skillManifest, IServiceClientCredentials serviceClientCredentials, ITurnContext dialogContext, Activity activity, Action<Activity> tokenRequestHandler = null, Action<Activity> fallbackHandler = null)
{
_activityForwarded = activity;

return Task.FromResult(true);
}
return Task.FromResult(true);
}

public bool CheckIfSkillInvoked()
{
return _activityForwarded != null;
}
public bool CheckIfSkillInvoked()
{
return _activityForwarded != null;
}

public void VerifyActivityForwardedCorrectly(Action<Activity> assertion)
{
assertion(_activityForwarded);
}
}
public void VerifyActivityForwardedCorrectly(Action<Activity> assertion)
{
assertion(_activityForwarded);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Microsoft.Bot.Builder.Skills.Tests
internal class SkillDialogTest : SkillDialog
{
public SkillDialogTest(SkillManifest skillManifest, IServiceClientCredentials serviceClientCredentials, IBotTelemetryClient telemetryClient, UserState userState, ISkillTransport skillTransport = null)
: base(skillManifest, serviceClientCredentials, telemetryClient, userState, null, skillTransport)
: base(skillManifest, serviceClientCredentials, telemetryClient, userState, null, null, skillTransport)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Threading.Tasks;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Builder.Skills.Models.Manifest;

namespace Microsoft.Bot.Builder.Skills
{
public interface ISkillIntentRecognizer
{
Func<DialogContext, Task<string>> RecognizeSkillIntentAsync { get; }

bool ConfirmIntentSwitch { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.Bot.Builder.Skills
{
public interface ISkillTransport
{
Task<bool> ForwardToSkillAsync(SkillManifest skillManifest, IServiceClientCredentials serviceClientCredentials, ITurnContext dialogContext, Activity activity, Action<Activity> tokenRequestHandler = null);
Task<bool> ForwardToSkillAsync(SkillManifest skillManifest, IServiceClientCredentials serviceClientCredentials, ITurnContext dialogContext, Activity activity, Action<Activity> tokenRequestHandler = null, Action<Activity> fallbackHandler = null);

Task CancelRemoteDialogsAsync(SkillManifest skillManifest, IServiceClientCredentials serviceClientCredentials, ITurnContext turnContext);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
public class SkillEvents
{
public const string CancelAllSkillDialogsEventName = "skill/cancelallskilldialogs";
public const string FallbackEventName = "skill/fallbackrequest";
public const string FallbackHandledEventName = "skill/fallbackhandled";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Bot.Builder.Skills.Models;
using Microsoft.Bot.Builder.Skills.Protocol;
using Microsoft.Bot.Builder.Solutions;
using Microsoft.Bot.Schema;
Expand All @@ -18,13 +19,20 @@ public class SkillCallingRequestHandler : RequestHandler
private readonly ITurnContext _turnContext;
private readonly IBotTelemetryClient _botTelemetryClient;
private readonly Action<Activity> _tokenRequestHandler;
private readonly Action<Activity> _fallbackRequestHandler;
private readonly Action<Activity> _handoffActivityHandler;

public SkillCallingRequestHandler(ITurnContext turnContext, IBotTelemetryClient botTelemetryClient, Action<Activity> tokenRequestHandler = null, Action<Activity> handoffActivityHandler = null)
public SkillCallingRequestHandler(
ITurnContext turnContext,
IBotTelemetryClient botTelemetryClient,
Action<Activity> tokenRequestHandler = null,
Action<Activity> fallbackRequestHandler = null,
Action<Activity> handoffActivityHandler = null)
{
_turnContext = turnContext ?? throw new ArgumentNullException(nameof(turnContext));
_botTelemetryClient = botTelemetryClient;
_tokenRequestHandler = tokenRequestHandler;
_fallbackRequestHandler = fallbackRequestHandler;
_handoffActivityHandler = handoffActivityHandler;

var routes = new RouteTemplate[]
Expand Down Expand Up @@ -54,6 +62,19 @@ public SkillCallingRequestHandler(ITurnContext turnContext, IBotTelemetryClient
throw new ArgumentNullException("TokenRequestHandler", "Skill is requesting for token but there's no handler on the calling side!");
}
}
else if (activity.Type == ActivityTypes.Event && activity.Name == SkillEvents.FallbackEventName)
{
if (_fallbackRequestHandler != null)
{
_fallbackRequestHandler(activity);

return new ResourceResponse();
}
else
{
throw new ArgumentNullException("FallbackRequestHandler", "Skill is asking for fallback but there is no handler on the calling side!");
}
}
else if (activity.Type == ActivityTypes.EndOfConversation)
{
if (_handoffActivityHandler != null)
Expand Down
Loading