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

[C#] refactor: return AdaptiveCardInvokeResponse for ActionExecute #673

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

kuojianlu
Copy link
Contributor

@kuojianlu kuojianlu commented Oct 12, 2023

Linked issues

closes: #601

Details

Change details

  • use AdaptiveCardInvokeResponse as return type of ActionExecuteHandler. The change is because the original style cannot meet the following requirement: return values with different types in one handler. For example, if I'd like to return Adaptive Card or text message by some cases in OnActionExecute("verb"), I have to define OnActionExecute("verb", ActionExecuteAdaptiveCardHandler) and OnActionExecute("verb", ActionExecuteTextHandler) respectively. Although the two handlers will be hit, only one result will be returned. A concrete example is SubmitAction in gptME sample.

Attestation Checklist

  • My code follows the style guidelines of this project

  • I have checked for/fixed spelling, linting, and other errors

  • I have commented my code for clarity

  • I have made corresponding changes to the documentation (we use TypeDoc to document our code)

  • My changes generate no new warnings

  • I have added tests that validates my changes, and provides sufficient test coverage. I have tested with:

    • Local testing
    • E2E testing in Teams
  • New and existing unit tests pass locally with my changes

Additional information

Feel free to add other relevant information below

@kuojianlu kuojianlu requested a review from singhk97 as a code owner October 12, 2023 12:19
@kuojianlu kuojianlu requested a review from swatDong October 13, 2023 02:05
@@ -191,13 +178,7 @@ public AdaptiveCards(Application<TState, TTurnStateManager> app)
throw new TeamsAIException($"Unexpected AdaptiveCards.OnActionExecute() triggered for activity type: {turnContext.Activity.Type}");
}

AdaptiveCard adaptiveCard = await handler(turnContext, turnState, invokeValue.Action.Data, cancellationToken);
AdaptiveCardInvokeResponse adaptiveCardInvokeResponse = new()
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better if providing something like AdaptiveCardInvokeResponseBuilder.FromCard?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, but let me add it in separate PR.

@kuojianlu kuojianlu merged commit be5ccca into dotnetfluent Oct 13, 2023
9 checks passed
@kuojianlu kuojianlu deleted the kuojianlu/card-refactor branch October 13, 2023 03:40
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.

2 participants