8000 Support bot config invoke type · microsoft/botbuilder-dotnet@7215218 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7215218

Browse files
author
Ying Du
committed
Support bot config invoke type
1 parent bb6a077 commit 7215218

File tree

6 files changed

+176
-0
lines changed

6 files changed

+176
-0
lines changed

libraries/Microsoft.Bot.Builder/Teams/TeamsActivityHandler.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ protected override async Task<InvokeResponse> OnInvokeActivityAsync(ITurnContext
9292
case "tab/submit":
9393
return CreateInvokeResponse(await OnTeamsTabSubmitAsync(turnContext, SafeCast<TabSubmit>(turnContext.Activity.Value), cancellationToken).ConfigureAwait(false));
9494

95+
case "config/fetch":
96+
return CreateInvokeResponse(await OnTeamsConfigFetchAsync(turnContext, turnContext.Activity.Value as JObject, cancellationToken).ConfigureAwait(false));
97+
98+
case "config/submit":
99+
return CreateInvokeResponse(await OnTeamsConfigSubmitAsync(turnContext, turnContext.Activity.Value as JObject, cancellationToken).ConfigureAwait(false));
100+
95101
default:
96102
return await base.OnInvokeActivityAsync(turnContext, cancellationToken).ConfigureAwait(false);
97103
}
@@ -431,6 +437,32 @@ protected virtual Task<TabResponse> OnTeamsTabSubmitAsync(ITurnContext<IInvokeAc
431437
throw new InvokeResponseException(HttpStatusCode.NotImplemented);
432438
}
433439

440+
/// <summary>
441+
/// Override this in a derived class to provide logic for when a config is fetched.
442+
/// </summary>
443+
/// <param name="turnContext">A strongly-typed context object for this turn.</param>
444+
/// <param name="configData">The config fetch invoke request value payload.</param>
445+
/// <param name="cancellationToken">A cancellation token that can be used by other objects
446+
/// or threads to receive notice of cancellation.</param>
447+
/// <returns>A Config Response for the request.</returns>
448+
protected virtual Task<InvokeResponseBase> OnTeamsConfigFetchAsync(ITurnContext<IInvokeActivity> turnContext, JObject configData, CancellationToken cancellationToken)
449+
{
450+
throw new InvokeResponseException(HttpStatusCode.NotImplemented);
451+
}
452+
453+
/// <summary>
454+
/// Override this in a derived class to provide logic for when a config is fetched.
455+
/// </summary>
456+
/// <param name="turnContext">A strongly-typed context object for this turn.</param>
457+
/// <param name="configData">The config fetch invoke request value payload.</param>
458+
/// <param name="cancellationToken">A cancellation token that can be used by other objects
459+
/// or threads to receive notice of cancellation.</param>
460+
/// <returns>A Config Response for the request.</returns>
461+
protected virtual Task<InvokeResponseBase> OnTeamsConfigSubmitAsync(ITurnContext<IInvokeActivity> turnContext, JObject configData, CancellationToken cancellationToken)
462+
{
463+
throw new InvokeResponseException(HttpStatusCode.NotImplemented);
464+
}
465+
434466
/// <summary>
435467
/// Invoked when a conversation update activity is received from the channel.
436468
/// Conversation update activities are useful when it comes to responding to users being added to or removed from the channel.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
using Newtonsoft.Json;
4+
5+
namespace Microsoft.Bot.Schema.Teams
6+
{
7+
/// <summary>
8+
/// Specifies bot config authe, including type and suggestedActions.
9+
/// </summary>
10+
public class BotConfigAuth
11+
{
12+
/// <summary>
13+
/// Initializes a new instance of the <see cref="BotConfigAuth"/> class.
14+
/// </summary>
15+
public BotConfigAuth()
16+
{
17+
}
18+
19+
/// <summary>
20+
/// Gets or sets type of bot config auth.
21+
/// </summary>
22+
/// <value>
23+
/// The type of bot config auth.
24+
/// </value>
25+
[JsonProperty(PropertyName = "type")]
26+
public string Type { get; set; } = "auth";
27+
28+
/// <summary>
29+
/// Gets or sets suggested actions.
30+
/// </summary>
31+
/// <value>
32+
/// The suggested actions of bot config auth.
33+
/// </value>
34+
[JsonProperty(PropertyName = "suggestedActions")]
35+
public SuggestedActions SuggestedActions { get; set; }
36+
}
37+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
namespace Microsoft.Bot.Schema.Teams
5+
{
6+
/// <summary>
7+
/// Envelope for Config Auth Response.
8+
/// </summary>
9+
public partial class ConfigAuthResponse : ConfigResponse<BotConfigAuth>
10+
{
11+
/// <summary>
12+
/// Initializes a new instance of the <see cref="ConfigAuthResponse"/> class.
13+
/// </summary>
14+
public ConfigAuthResponse()
15+
{
16+
}
17+
}
18+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
namespace Microsoft.Bot.Schema.Teams
5+
{
6+
using System;
7+
using Newtonsoft.Json;
8+
9+
/// <summary>
10+
/// Envelope for Config Response Payload.
11+
/// </summary>
12+
/// <typeparam name="T">The first generic type parameter.</typeparam>.
13+
public partial class ConfigResponse<T> : InvokeResponseBase
14+
{
15+
/// <summary>
16+
/// Initializes a new instance of the <see cref="ConfigResponse{T}"/> class.
17+
/// </summary>
18+
public ConfigResponse()
19+
{
20+
ResponseType = "config";
21+
}
22+
23+
/// <summary>
24+
/// Gets or sets the response to the config message.
25+
/// Possible values for the config type include: 'auth'or 'task'.
26+
/// </summary>
27+
/// <value>
28+
/// Response to a config request.
29+
/// </value>
30+
[JsonProperty(PropertyName = "config")]
31+
public T Config { get; set; }
32+
}
33+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
namespace Microsoft.Bot.Schema.Teams
5+
{
6+
/// <summary>
7+
/// Envelope for Config Task Response.
8+
/// </summary>
9+
public partial class ConfigTaskResponse : ConfigResponse<TaskModuleResponseBase>
10+
{
11+
/// <summary>
12+
/// Initializes a new instance of the <see cref="ConfigTaskResponse"/> class.
13+
/// </summary>
14+
public ConfigTaskResponse()
15+
{
16+
}
17+
}
18+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using Newtonsoft.Json;
5+
6+
namespace Microsoft.Bot.Schema.Teams
7+
{
8+
/// <summary>
9+
/// Specifies Invoke response base including response type.
10+
/// </summary>
11+
public class InvokeResponseBase
12+
{
13+
/// <summary>
14+
/// Initializes a new instance of the <see cref="InvokeResponseBase"/> class.
15+
/// </summary>
16+
protected InvokeResponseBase()
17+
{
18+
}
19+
20+
/// <summary>
21+
/// Gets or sets response type invoke request.
22+
/// </summary>
23+
/// <value>
24+
/// Invoke request response type.
25+
/// </value>
26+
[JsonProperty("responseType")]
27+
public string ResponseType { get; set; }
28+
29+
/// <summary>
30+
/// Gets or sets response cache Info.
31+
/// </summary>
32+
/// <value>
33+
/// Value of cache info.
34+
/// </value>
35+
[JsonProperty(PropertyName = "cacheInfo")]
36+
public CacheInfo CacheInfo { get; set; }
37+
}
38+
}

0 commit comments

Comments
 (0)
0