diff --git a/libraries/Microsoft.Bot.Builder/Teams/TeamsActivityHandler.cs b/libraries/Microsoft.Bot.Builder/Teams/TeamsActivityHandler.cs index 6a66d42a22..af54b2afee 100644 --- a/libraries/Microsoft.Bot.Builder/Teams/TeamsActivityHandler.cs +++ b/libraries/Microsoft.Bot.Builder/Teams/TeamsActivityHandler.cs @@ -92,6 +92,12 @@ protected override async Task OnInvokeActivityAsync(ITurnContext case "tab/submit": return CreateInvokeResponse(await OnTeamsTabSubmitAsync(turnContext, SafeCast(turnContext.Activity.Value), cancellationToken).ConfigureAwait(false)); + case "config/fetch": + return CreateInvokeResponse(await OnTeamsConfigFetchAsync(turnContext, turnContext.Activity.Value as JObject, cancellationToken).ConfigureAwait(false)); + + case "config/submit": + return CreateInvokeResponse(await OnTeamsConfigSubmitAsync(turnContext, turnContext.Activity.Value as JObject, cancellationToken).ConfigureAwait(false)); + default: return await base.OnInvokeActivityAsync(turnContext, cancellationToken).ConfigureAwait(false); } @@ -431,6 +437,32 @@ protected virtual Task OnTeamsTabSubmitAsync(ITurnContext + /// Override this in a derived class to provide logic for when a config is fetched. + /// + /// A strongly-typed context object for this turn. + /// The config fetch invoke request value payload. + /// A cancellation token that can be used by other objects + /// or threads to receive notice of cancellation. + /// A Config Response for the request. + protected virtual Task OnTeamsConfigFetchAsync(ITurnContext turnContext, JObject configData, CancellationToken cancellationToken) + { + throw new InvokeResponseException(HttpStatusCode.NotImplemented); + } + + /// + /// Override this in a derived class to provide logic for when a config is fetched. + /// + /// A strongly-typed context object for this turn. + /// The config fetch invoke request value payload. + /// A cancellation token that can be used by other objects + /// or threads to receive notice of cancellation. + /// A Config Response for the request. + protected virtual Task OnTeamsConfigSubmitAsync(ITurnContext turnContext, JObject configData, CancellationToken cancellationToken) + { + throw new InvokeResponseException(HttpStatusCode.NotImplemented); + } + /// /// Invoked when a conversation update activity is received from the channel. /// Conversation update activities are useful when it comes to responding to users being added to or removed from the channel. diff --git a/libraries/Microsoft.Bot.Schema/Teams/BotConfigAuth.cs b/libraries/Microsoft.Bot.Schema/Teams/BotConfigAuth.cs new file mode 100644 index 0000000000..393b0035fc --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/Teams/BotConfigAuth.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.Teams +{ + /// + /// Specifies bot config authe, including type and suggestedActions. + /// + public class BotConfigAuth + { + /// + /// Initializes a new instance of the class. + /// + public BotConfigAuth() + { + } + + /// + /// Gets or sets type of bot config auth. + /// + /// + /// The type of bot config auth. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } = "auth"; + + /// + /// Gets or sets suggested actions. + /// + /// + /// The suggested actions of bot config auth. + /// + [JsonProperty(PropertyName = "suggestedActions")] + public SuggestedActions SuggestedActions { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/Teams/ConfigAuthResponse.cs b/libraries/Microsoft.Bot.Schema/Teams/ConfigAuthResponse.cs new file mode 100644 index 0000000000..fc7549f49f --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/Teams/ConfigAuthResponse.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Bot.Schema.Teams +{ + /// + /// Envelope for Config Auth Response. + /// + public partial class ConfigAuthResponse : ConfigResponse + { + /// + /// Initializes a new instance of the class. + /// + public ConfigAuthResponse() + { + } + } +} diff --git a/libraries/Microsoft.Bot.Schema/Teams/ConfigResponse.cs b/libraries/Microsoft.Bot.Schema/Teams/ConfigResponse.cs new file mode 100644 index 0000000000..480c724711 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/Teams/ConfigResponse.cs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Bot.Schema.Teams +{ + using System; + using Newtonsoft.Json; + + /// + /// Envelope for Config Response Payload. + /// + /// The first generic type parameter.. + public partial class ConfigResponse : InvokeResponseBase + { + /// + /// Initializes a new instance of the class. + /// + public ConfigResponse() + { + ResponseType = "config"; + } + + /// + /// Gets or sets the response to the config message. + /// Possible values for the config type include: 'auth'or 'task'. + /// + /// + /// Response to a config request. + /// + [JsonProperty(PropertyName = "config")] + public T Config { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/Teams/ConfigTaskResponse.cs b/libraries/Microsoft.Bot.Schema/Teams/ConfigTaskResponse.cs new file mode 100644 index 0000000000..d766b009c3 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/Teams/ConfigTaskResponse.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Bot.Schema.Teams +{ + /// + /// Envelope for Config Task Response. + /// + public partial class ConfigTaskResponse : ConfigResponse + { + /// + /// Initializes a new instance of the class. + /// + public ConfigTaskResponse() + { + } + } +} diff --git a/libraries/Microsoft.Bot.Schema/Teams/InvokeResponseBase.cs b/libraries/Microsoft.Bot.Schema/Teams/InvokeResponseBase.cs new file mode 100644 index 0000000000..406d1832da --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/Teams/InvokeResponseBase.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.Teams +{ + /// + /// Specifies Invoke response base including response type. + /// + public class InvokeResponseBase + { + /// + /// Initializes a new instance of the class. + /// + protected InvokeResponseBase() + { + } + + /// + /// Gets or sets response type invoke request. + /// + /// + /// Invoke request response type. + /// + [JsonProperty("responseType")] + public string ResponseType { get; set; } + + /// + /// Gets or sets response cache Info. + /// + /// + /// Value of cache info. + /// + [JsonProperty(PropertyName = "cacheInfo")] + public CacheInfo CacheInfo { get; set; } + } +}