Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit 956861b

Browse files
committed
updated phone skill to latest packages
1 parent 5760202 commit 956861b

File tree

5 files changed

+31
-31
lines changed

5 files changed

+31
-31
lines changed

skills/src/csharp/phoneskill/phoneskill/Bots/DialogBot.cs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@
1111

1212
namespace PhoneSkill.Bots
1313
{
14-
public class DialogBot<T> : ActivityHandler
14+
public class DialogBot<T> : IBot
1515
where T : Dialog
1616
{
17+
private readonly Dialog _dialog;
18+
private readonly BotState _conversationState;
19+
private readonly BotState _userState;
1720
private readonly IBotTelemetryClient _telemetryClient;
18-
private DialogSet _dialogs;
1921

2022
public DialogBot(IServiceProvider serviceProvider, T dialog)
2123
{
22-
var conversationState = serviceProvider.GetService<ConversationState>() ?? throw new ArgumentNullException(nameof(ConversationState));
23-
_telemetryClient = serviceProvider.GetService<IBotTelemetryClient>() ?? throw new ArgumentNullException(nameof(IBotTelemetryClient));
24-
25-
var dialogState = conversationState.CreateProperty<DialogState>(nameof(PhoneSkill));
26-
_dialogs = new DialogSet(dialogState);
27-
_dialogs.Add(dialog);
24+
_dialog = dialog;
25+
_conversationState = serviceProvider.GetService<ConversationState>();
26+
_userState = serviceProvider.GetService<UserState>();
27+
_telemetryClient = serviceProvider.GetService<IBotTelemetryClient>();
2828
}
2929

30-
public override async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken)
30+
public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken))
3131
{
3232
// Client notifying this bot took to long to respond (timed out)
3333
if (turnContext.Activity.Code == EndOfConversationCodes.BotTimedOut)
@@ -36,16 +36,11 @@ public override async Task OnTurnAsync(ITurnContext turnContext, CancellationTok
3636
return;
3737
}
3838

39-
var dc = await _dialogs.CreateContextAsync(turnContext);
39+
await _dialog.RunAsync(turnContext, _conversationState.CreateProperty<DialogState>(nameof(DialogState)), cancellationToken);
4040

41-
if (dc.ActiveDialog != null)
42-
{
43-
var result = await dc.ContinueDialogAsync();
44-
}
45-
else
46-
{
47-
await dc.BeginDialogAsync(typeof(T).Name);
48-
}
41+
// Save any state changes that might have occured during the turn.
42+
await _conversationState.SaveChangesAsync(turnContext, false, cancellationToken);
43+
await _userState.SaveChangesAsync(turnContext, false, cancellationToken);
4944
}
5045
}
5146
}

skills/src/csharp/phoneskill/phoneskill/Controllers/BotController.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@
55
using Microsoft.Bot.Builder;
66
using Microsoft.Bot.Builder.Integration.AspNet.Core;
77
using Microsoft.Bot.Builder.Skills;
8+
using Microsoft.Bot.Builder.Skills.Auth;
89
using Microsoft.Bot.Builder.Solutions;
910

1011
namespace PhoneSkill.Controllers
1112
{
1213
[ApiController]
1314
public class BotController : SkillController
14-
{
15-
public BotController(
16-
IBot bot,
17-
BotSettingsBase botSettings,
18-
IBotFrameworkHttpAdapter botFrameworkHttpAdapter,
19-
SkillWebSocketAdapter skillWebSocketAdapter)
20-
: base(bot, botSettings, botFrameworkHttpAdapter, skillWebSocketAdapter)
21-
{
22-
}
23-
}
15+
{
16+
public BotController(
17+
IBot bot,
18+
BotSettingsBase botSettings,
19+
IBotFrameworkHttpAdapter botFrameworkHttpAdapter,
20+
SkillWebSocketAdapter skillWebSocketAdapter,
21+
IWhitelistAuthenticationProvider whitelistAuthenticationProvider)
22+
: base(bot, botSettings, botFrameworkHttpAdapter, skillWebSocketAdapter, whitelistAuthenticationProvider)
23+
{
24+
}
25+
}
2426
}

skills/src/csharp/phoneskill/phoneskill/PhoneSkill.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.5.1" />
2121
<PackageReference Include="Microsoft.Bot.Builder.Integration.ApplicationInsights.Core" Version="4.5.1" />
2222
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.5.1" />
23-
<PackageReference Include="Microsoft.Bot.Builder.Skills" Version="4.5.1" />
24-
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.5.1" />
23+
<PackageReference Include="Microsoft.Bot.Builder.Skills" Version="4.6.0-rc4" />
24+
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.6.0-rc4" />
2525
<PackageReference Include="Microsoft.Bot.Builder.TemplateManager" Version="4.5.1" />
2626
<PackageReference Include="Microsoft.Bot.Configuration" Version="4.5.1" />
2727
<PackageReference Include="Microsoft.Bot.Connector" Version="4.5.1" />

skills/src/csharp/phoneskill/phoneskill/Startup.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Microsoft.Bot.Builder.Integration.ApplicationInsights.Core;
1313
using Microsoft.Bot.Builder.Integration.AspNet.Core;
1414
using Microsoft.Bot.Builder.Skills;
15+
using Microsoft.Bot.Builder.Skills.Auth;
1516
using Microsoft.Bot.Builder.Solutions;
1617
using Microsoft.Bot.Builder.Solutions.Responses;
1718
using Microsoft.Bot.Builder.Solutions.TaskExtensions;
@@ -104,6 +105,9 @@ public void ConfigureServices(IServiceCollection services)
104105
services.AddTransient<SkillWebSocketBotAdapter, PhoneSkillWebSocketBotAdapter>();
105106
services.AddTransient<SkillWebSocketAdapter>();
106107

108+
// Register WhiteListAuthProvider
109+
services.AddSingleton<IWhitelistAuthenticationProvider, WhitelistAuthenticationProvider>();
110+
107111
// Configure bot
108112
services.AddTransient<MainDialog>();
109113
services.AddTransient<IBot, DialogBot<MainDialog>>();

skills/src/csharp/phoneskill/phoneskilltest/PhoneSkillTest.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.5.1" />
1110
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
1211
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
1312
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />

0 commit comments

Comments
 (0)