Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SkillDialog to handle all activity types (e.g. set DeliveryMode for Invokes) #2161

Merged
merged 5 commits into from
May 4, 2020

Conversation

stevengum
Copy link
Member

@stevengum stevengum commented May 2, 2020

Fixes #2139

Specific Changes

  • Add StatusCodes.MULTIPLE_CHOICES = 300
  • Add protected method SkillDialog.onValidateActivity()
  • SkillDialog now forwards all ActivityTypes to the Skill.
  • Add new C# SkillDialog tests and refactor old tests
  • Add missing test for TurnContext when deliveryMode === 'expectReplies'
  • Fix error message in BotFrameworkAdapter.createConnectorClientWithIdentity()
  • Add tests for BotFrameworkAdapter.createConnectorClientWithIdentity()
  • Add test for BotFrameworkAdapter.processActivity() when deliveryMode === 'expectReplies', type is Invoke and reply activities have type invokeResponse

@coveralls
Copy link

coveralls commented May 2, 2020

Pull Request Test Coverage Report for Build 127831

  • 39 of 43 (90.7%) changed or added relevant lines in 3 files are covered.
  • 9 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.03%) to 79.897%

Changes Missing Coverage Covered Lines Changed/Added Lines %
libraries/botbuilder-dialogs/src/skillDialog.ts 32 36 88.89%
Files with Coverage Reduction New Missed Lines %
libraries/botframework-streaming/src/webSocket/webSocketTransport.ts 2 80.65%
libraries/botframework-streaming/src/webSocket/webSocketServer.ts 7 66.67%
Totals Coverage Status
Change from base Build 127684: 0.03%
Covered Lines: 12444
Relevant Lines: 14864

💛 - Coveralls

@stevengum stevengum marked this pull request as ready for review May 2, 2020 03:56
// If the SkillConversationIdFactoryBase implementation doesn't support createSkillConversationIdWithOptions(),
// use createSkillConversationId() instead.
skillConversationId = await this.dialogOptions.conversationIdFactory.createSkillConversationId(TurnContext.getConversationReference(activity) as ConversationReference);
if (activity.type === ActivityTypes.Invoke) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having to switch expectReplies on for an invoke seems a little odd.

Copy link
Contributor

@gabog gabog May 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the dialog is interacting with a skill that only works with invokes, this makes sure that EoC replies are buffered with the invokeResponse and the dialog ends when an EoC comes back.

Here is an example on how this would look on a skill for teams:

protected override async Task<TaskModuleResponse> OnTeamsTaskModuleSubmitAsync(ITurnContext<IInvokeActivity> turnContext, TaskModuleRequest taskModuleRequest, CancellationToken cancellationToken)
{
    var reply = MessageFactory.Text("OnTeamsTaskModuleSubmitAsync Value: " + JsonConvert.SerializeObject(taskModuleRequest));
    await turnContext.SendActivityAsync(reply, cancellationToken);
            
    // Send End of conversation at the end.
    var activity = new Activity(ActivityTypes.EndOfConversation) { Value = taskModuleRequest.Data, Locale = ((Activity)turnContext.Activity).Locale };
    await turnContext.SendActivityAsync(activity, cancellationToken);

    return new TaskModuleResponse
    {
        Task = new TaskModuleMessageResponse
        {
            Value = "Thanks!",
        },
    };
}

@@ -843,8 +843,18 @@ export class BotFrameworkAdapter extends BotAdapter implements ConnectorClientBu
context.turnState.set(BotCallbackHandlerKey, logic);
await this.runMiddleware(context, logic);

// Retrieve cached invoke response.
if (request.type === ActivityTypes.Invoke) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this change presumably for consistency with the other place this condition occurs...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, these changes are ported from C# with exactly the same spirit (and tests) in mind. That said, I will add some more complex unit tests tomorrow to cover the interactions between the BFAdapter and ActivityHandler, and the two with SkillDialog.

@cleemullins cleemullins merged commit 54e4c2d into master May 4, 2020
@cleemullins cleemullins deleted the stgum/skillDialog2 branch May 4, 2020 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update SkillDialog to handle all activity types
5 participants