-
Notifications
You must be signed in to change notification settings - Fork 486
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
feat: [#6865] Provide two new invoke handlers, (message/fetchTask, message/submitAction) for Custom Feedback Loops #6871
Open
sw-joelmut
wants to merge
4
commits into
main
Choose a base branch
from
southworks/add/teams-feedback-loop
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,10 +85,10 @@ protected override async Task<InvokeResponse> OnInvokeActivityAsync(ITurnContext | |
|
||
case "task/submit": | ||
return CreateInvokeResponse(await OnTeamsTaskModuleSubmitAsync(turnContext, SafeCast<TaskModuleRequest>(turnContext.Activity.Value), cancellationToken).ConfigureAwait(false)); | ||
|
||
case "tab/fetch": | ||
return CreateInvokeResponse(await OnTeamsTabFetchAsync(turnContext, SafeCast<TabRequest>(turnContext.Activity.Value), cancellationToken).ConfigureAwait(false)); | ||
|
||
case "tab/submit": | ||
return CreateInvokeResponse(await OnTeamsTabSubmitAsync(turnContext, SafeCast<TabSubmit>(turnContext.Activity.Value), cancellationToken).ConfigureAwait(false)); | ||
|
||
|
@@ -98,6 +98,13 @@ protected override async Task<InvokeResponse> OnInvokeActivityAsync(ITurnContext | |
case "config/submit": | ||
return CreateInvokeResponse(await OnTeamsConfigSubmitAsync(turnContext, turnContext.Activity.Value as JObject, cancellationToken).ConfigureAwait(false)); | ||
|
||
case "message/submitAction": | ||
await OnTeamsMessageSubmitActionAsync(turnContext, SafeCast<FeedbackResponse>(turnContext.Activity.Value), cancellationToken).ConfigureAwait(false); | ||
return CreateInvokeResponse(); | ||
|
||
case "message/fetchTask": | ||
return CreateInvokeResponse(await OnTeamsMessageFetchTaskAsync(turnContext, cancellationToken).ConfigureAwait(false)); | ||
|
||
default: | ||
return await base.OnInvokeActivityAsync(turnContext, cancellationToken).ConfigureAwait(false); | ||
} | ||
|
@@ -686,7 +693,7 @@ protected virtual Task OnTeamsChannelRenamedAsync(ChannelInfo channelInfo, TeamI | |
{ | ||
return Task.CompletedTask; | ||
} | ||
|
||
/// <summary> | ||
/// Invoked when a Channel Restored event activity is received from the connector. | ||
/// Channel Restored correspond to the user restoring a previously deleted channel. | ||
|
@@ -994,6 +1001,69 @@ protected virtual Task OnTeamsMessageSoftDeleteAsync(ITurnContext<IMessageDelete | |
return Task.CompletedTask; | ||
} | ||
|
||
/// <summary> | ||
/// Invoked when a feedback loop activity is received. | ||
/// </summary> | ||
/// <param name="turnContext">A strongly-typed context object for this turn.</param> | ||
/// <param name="feedback">A strongly-typed feedback loop object for this turn.</param> | ||
/// <param name="cancellationToken">A cancellation token that can be used by other objects | ||
/// or threads to receive notice of cancellation.</param> | ||
/// <returns>A task that represents the work queued to execute.</returns> | ||
protected virtual Task OnTeamsMessageSubmitActionAsync(ITurnContext<IInvokeActivity> turnContext, FeedbackResponse feedback, CancellationToken cancellationToken) | ||
{ | ||
throw new InvokeResponseException(HttpStatusCode.NotImplemented); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it expected to throw an error here? |
||
} | ||
|
||
/// <summary> | ||
/// Invoked when a custom feedback loop activity is received. | ||
/// The returned information is a <see cref="TaskModuleContinueResponse"/> instance, | ||
/// that Teams will use to show either an AdaptiveCard or website in the "feedback window form". | ||
/// <example> | ||
/// <br/><br/> | ||
/// <b>Example of a valid Adaptive Card payload:</b> | ||
/// <code> | ||
/// const taskModuleReturn = { | ||
/// task: { | ||
/// type: 'continue', | ||
/// value: { | ||
/// card: [Object], // Should contain valid Adaptive Card Payload | ||
/// height: 200, | ||
/// width: 400, | ||
/// title: 'Test Task Module Title with AC' | ||
/// } | ||
/// } | ||
/// }; | ||
/// return { | ||
/// status: 200, | ||
/// body: taskModuleReturn | ||
/// }; | ||
/// </code> | ||
/// <b>Example of a valid website payload:</b> | ||
/// <code> | ||
/// const taskModuleReturn = { | ||
/// task: { | ||
/// type: 'continue', | ||
/// value: { | ||
/// url: "https://bing.com", // Should contain valid URL with the valid domain listed under App Manifest | ||
/// } | ||
/// } | ||
/// }; | ||
/// return { | ||
/// status: 200, | ||
/// body: taskModuleReturn | ||
/// }; | ||
/// </code> | ||
/// </example> | ||
/// </summary> | ||
/// <param name="turnContext">A strongly-typed context object for this turn.</param> | ||
/// <param name="cancellationToken">A cancellation token that can be used by other objects | ||
/// or threads to receive notice of cancellation.</param> | ||
/// <returns>A task that represents a <see cref="TaskModuleContinueResponse"/> instance, containing the necessary <see cref="TaskModuleTaskInfo"/> metadata with either an AdaptiveCard or a website url information.</returns> | ||
protected virtual Task<TaskModuleContinueResponse> OnTeamsMessageFetchTaskAsync(ITurnContext<IInvokeActivity> turnContext, CancellationToken cancellationToken) | ||
{ | ||
throw new InvokeResponseException(HttpStatusCode.NotImplemented); | ||
} | ||
|
||
/// <summary> | ||
/// Safely casts an object to an object of type <typeparamref name="T"/> . | ||
/// </summary> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
namespace Microsoft.Bot.Schema.Teams | ||
{ | ||
using Newtonsoft.Json; | ||
|
||
/// <summary> | ||
/// Describes feedback loop information. | ||
/// </summary> | ||
public partial class FeedbackInfo | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="FeedbackInfo"/> class. | ||
/// </summary> | ||
public FeedbackInfo() | ||
{ | ||
CustomInit(); | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="FeedbackInfo"/> class. | ||
/// </summary> | ||
/// <param name="type">Unique identifier representing a team.</param> | ||
public FeedbackInfo(string type = FeedbackInfoTypes.Default) | ||
{ | ||
Type = type; | ||
CustomInit(); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the feedback loop type. Possible values include: 'default', 'custom'. | ||
/// </summary> | ||
/// <value> | ||
/// The feedback loop type (see <see cref="FeedbackInfoTypes"/>). | ||
/// </value> | ||
[JsonProperty(PropertyName = "type")] | ||
public string Type { get; set; } | ||
|
||
partial void CustomInit(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
namespace Microsoft.Bot.Schema.Teams | ||
{ | ||
/// <summary> | ||
/// Defines feedback loop type. Depending on the type, the feedback window will have a different structure. | ||
/// </summary> | ||
public static class FeedbackInfoTypes | ||
{ | ||
/// <summary> | ||
/// The type value for default feedback window form. | ||
/// </summary> | ||
public const string Default = "default"; | ||
|
||
/// <summary> | ||
/// The type value for custom feedback window, can be either an AdaptiveCard or website. | ||
/// </summary> | ||
public const string Custom = "custom"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
namespace Microsoft.Bot.Schema.Teams | ||
{ | ||
using Newtonsoft.Json; | ||
|
||
/// <summary> | ||
/// Envelope for Feedback Response. | ||
/// </summary> | ||
public partial class FeedbackResponse | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="FeedbackResponse"/> class. | ||
/// </summary> | ||
public FeedbackResponse() | ||
{ | ||
CustomInit(); | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="FeedbackResponse"/> class. | ||
/// </summary> | ||
/// <param name="actionName">The name of the action.</param> | ||
/// <param name="actionValue">The value of the action.</param> | ||
/// <param name="replyToId">The ID of the message to which this message is a reply.</param> | ||
public FeedbackResponse(string actionName = default, FeedbackResponseActionValue actionValue = default, string replyToId = default) | ||
{ | ||
ActionName = actionName; | ||
ActionValue = actionValue; | ||
ReplyToId = replyToId; | ||
CustomInit(); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the action name. | ||
/// </summary> | ||
/// <value>Name of the action.</value> | ||
public string ActionName { get; set; } = "feedback"; | ||
|
||
/// <summary> | ||
/// Gets or sets the response for the action value. | ||
/// </summary> | ||
/// <value>The action value that contains the feedback reaction and message.</value> | ||
[JsonProperty(PropertyName = "actionValue")] | ||
public FeedbackResponseActionValue ActionValue { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the ID of the message to which this message is a reply. | ||
/// </summary> | ||
/// <value>Value of the ID to reply.</value> | ||
[JsonProperty(PropertyName = "replyToId")] | ||
public string ReplyToId { get; set; } | ||
|
||
partial void CustomInit(); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
libraries/Microsoft.Bot.Schema/Teams/FeedbackResponseActionValue.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
namespace Microsoft.Bot.Schema.Teams | ||
{ | ||
using Newtonsoft.Json; | ||
|
||
/// <summary> | ||
/// Envelope for Feedback ActionValue Response. | ||
/// </summary> | ||
public partial class FeedbackResponseActionValue | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="FeedbackResponseActionValue"/> class. | ||
/// </summary> | ||
public FeedbackResponseActionValue() | ||
{ | ||
CustomInit(); | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="FeedbackResponseActionValue"/> class. | ||
/// </summary> | ||
/// <param name="reaction">The reaction of the feedback.</param> | ||
/// <param name="feedback">The feedback content.</param> | ||
public FeedbackResponseActionValue(string reaction = default, string feedback = default) | ||
{ | ||
Reaction = reaction; | ||
Feedback = feedback; | ||
CustomInit(); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the reaction, either "like" or "dislike". | ||
/// </summary> | ||
/// <value>val.</value> | ||
[JsonProperty(PropertyName = "reaction")] | ||
public string Reaction { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the feedback content provided by the user when prompted with "What did you like/dislike?". | ||
/// </summary> | ||
/// <value>val.</value> | ||
[JsonProperty(PropertyName = "feedback")] | ||
public string Feedback { get; set; } | ||
|
||
partial void CustomInit(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be more accurate to say "Invoked when a user submits a default or custom feedback loop form".