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

Commit

Permalink
return semantic response as dialog result (#2069)
Browse files Browse the repository at this point in the history
* return semanticAction response in dialog result

* add null check
  • Loading branch information
lzc850612 committed Aug 7, 2019
1 parent a50268c commit 66e4a39
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public void Disconnect()
{
}

public Task<bool> ForwardToSkillAsync(SkillManifest skillManifest, IServiceClientCredentials serviceClientCredentials, ITurnContext dialogContext, Activity activity, Action<Activity> tokenRequestHandler = null, Action<Activity> fallbackHandler = null)
public Task<Activity> 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<Activity>(null);
}

public bool CheckIfSkillInvoked()
Expand Down
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, Action<Activity> fallbackHandler = null);
Task<Activity> 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 @@ -77,6 +77,7 @@ public SkillCallingRequestHandler(
}
else if (activity.Type == ActivityTypes.EndOfConversation)
{
var result = await _turnContext.SendActivityAsync(activity).ConfigureAwait(false);
if (_handoffActivityHandler != null)
{
_handoffActivityHandler(activity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,12 @@ private async Task<DialogTurnResult> ForwardToSkillAsync(DialogContext innerDc,
{
try
{
var endOfConversation = await _skillTransport.ForwardToSkillAsync(_skillManifest, _serviceClientCredentials, innerDc.Context, activity, GetTokenRequestCallback(innerDc), GetFallbackCallback(innerDc));
var endOfConversationActivity = await _skillTransport.ForwardToSkillAsync(_skillManifest, _serviceClientCredentials, innerDc.Context, activity, GetTokenRequestCallback(innerDc), GetFallbackCallback(innerDc));

if (endOfConversation)
if (endOfConversationActivity != null)
{
await innerDc.Context.SendActivityAsync(new Activity(type: ActivityTypes.Trace, text: $"<--Ending the skill conversation with the {_skillManifest.Name} Skill and handing off to Parent Bot."));
return await innerDc.EndDialogAsync();
return await innerDc.EndDialogAsync(endOfConversationActivity.SemanticAction?.Entities);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class SkillWebSocketTransport : ISkillTransport
{
private IStreamingTransportClient _streamingTransportClient;
private readonly IBotTelemetryClient _botTelemetryClient;
private bool endOfConversation = false;
private Activity endOfConversationActivity;

public SkillWebSocketTransport(
IBotTelemetryClient botTelemetryClient,
Expand All @@ -29,7 +29,7 @@ public SkillWebSocketTransport(
_streamingTransportClient = streamingTransportClient;
}

public async Task<bool> ForwardToSkillAsync(SkillManifest skillManifest, IServiceClientCredentials serviceClientCredentials, ITurnContext turnContext, Activity activity, Action<Activity> tokenRequestHandler = null, Action<Activity> fallbackHandler = null)
public async Task<Activity> ForwardToSkillAsync(SkillManifest skillManifest, IServiceClientCredentials serviceClientCredentials, ITurnContext turnContext, Activity activity, Action<Activity> tokenRequestHandler = null, Action<Activity> fallbackHandler = null)
{
if (_streamingTransportClient == null)
{
Expand Down Expand Up @@ -67,7 +67,7 @@ public async Task<bool> ForwardToSkillAsync(SkillManifest skillManifest, IServic

await _streamingTransportClient.SendAsync(request);

return endOfConversation;
return endOfConversationActivity;
}

public async Task CancelRemoteDialogsAsync(SkillManifest skillManifest, IServiceClientCredentials appCredentials, ITurnContext turnContext)
Expand Down Expand Up @@ -108,7 +108,7 @@ private Action<Activity> GetHandoffActivityCallback()
{
return (activity) =>
{
endOfConversation = true;
endOfConversationActivity = activity;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public RouterDialog(string dialogId, IBotTelemetryClient telemetryClient)
{
await OnEventAsync(innerDc).ConfigureAwait(false);
}
else if (!string.IsNullOrEmpty(activity.Text))
else
{
var result = await innerDc.ContinueDialogAsync().ConfigureAwait(false);

Expand Down

0 comments on commit 66e4a39

Please sign in to comment.