-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a204bdd
commit 4539d90
Showing
37 changed files
with
15,234 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.30503.244 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HCI_Chatbot", "HCI_Chatbot\HCI_Chatbot.csproj", "{4ECBE11B-69D8-4FF3-9820-8492C811215A}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{4ECBE11B-69D8-4FF3-9820-8492C811215A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4ECBE11B-69D8-4FF3-9820-8492C811215A}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4ECBE11B-69D8-4FF3-9820-8492C811215A}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4ECBE11B-69D8-4FF3-9820-8492C811215A}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {69E922A7-BFCD-4893-B220-286950178ABA} | ||
EndGlobalSection | ||
EndGlobal |
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,2 @@ | ||
# files generated during the lubuild process | ||
generated/ |
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,76 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Bot.Builder; | ||
using Microsoft.Bot.Builder.Dialogs.Adaptive.Runtime.Settings; | ||
using Microsoft.Bot.Builder.Integration.AspNet.Core; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace HCI_Chatbot.Controllers | ||
{ | ||
// This ASP Controller is created to handle a request. Dependency Injection will provide the Adapter and IBot | ||
// implementation at runtime. Multiple different IBot implementations running at different endpoints can be | ||
// achieved by specifying a more specific type for the bot constructor argument. | ||
[ApiController] | ||
public class BotController : ControllerBase | ||
{ | ||
private readonly Dictionary<string, IBotFrameworkHttpAdapter> _adapters = new Dictionary<string, IBotFrameworkHttpAdapter>(); | ||
private readonly IBot _bot; | ||
private readonly ILogger<BotController> _logger; | ||
|
||
public BotController( | ||
IConfiguration configuration, | ||
IEnumerable<IBotFrameworkHttpAdapter> adapters, | ||
IBot bot, | ||
ILogger<BotController> logger) | ||
{ | ||
_bot = bot ?? throw new ArgumentNullException(nameof(bot)); | ||
_logger = logger; | ||
|
||
var adapterSettings = configuration.GetSection(AdapterSettings.AdapterSettingsKey).Get<List<AdapterSettings>>() ?? new List<AdapterSettings>(); | ||
adapterSettings.Add(AdapterSettings.CoreBotAdapterSettings); | ||
|
||
foreach (var adapter in adapters ?? throw new ArgumentNullException(nameof(adapters))) | ||
{ | ||
var settings = adapterSettings.FirstOrDefault(s => s.Enabled && s.Type == adapter.GetType().FullName); | ||
|
||
if (settings != null) | ||
{ | ||
_adapters.Add(settings.Route, adapter); | ||
} | ||
} | ||
} | ||
|
||
[HttpPost] | ||
[HttpGet] | ||
[Route("api/{route}")] | ||
public async Task PostAsync(string route) | ||
{ | ||
if (string.IsNullOrEmpty(route)) | ||
{ | ||
_logger.LogError($"PostAsync: No route provided."); | ||
throw new ArgumentNullException(nameof(route)); | ||
} | ||
|
||
if (_adapters.TryGetValue(route, out IBotFrameworkHttpAdapter adapter)) | ||
{ | ||
if (_logger.IsEnabled(LogLevel.Debug)) | ||
{ | ||
_logger.LogInformation($"PostAsync: routed '{route}' to {adapter.GetType().Name}"); | ||
} | ||
|
||
// Delegate the processing of the HTTP POST to the appropriate adapter. | ||
// The adapter will invoke the bot. | ||
await adapter.ProcessAsync(Request, Response, _bot).ConfigureAwait(false); | ||
} | ||
else | ||
{ | ||
_logger.LogError($"PostAsync: No adapter registered and enabled for route {route}."); | ||
throw new KeyNotFoundException($"No adapter registered and enabled for route {route}."); | ||
} | ||
} | ||
} | ||
} |
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,62 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Bot.Builder; | ||
using Microsoft.Bot.Builder.Integration.AspNet.Core; | ||
using Microsoft.Bot.Schema; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace HCI_Chatbot.Controllers | ||
{ | ||
/// <summary> | ||
/// A controller that handles skill replies to the bot. | ||
/// </summary> | ||
[ApiController] | ||
[Route("api/skills")] | ||
public class SkillController : ChannelServiceController | ||
{ | ||
private readonly ILogger<SkillController> _logger; | ||
|
||
public SkillController(ChannelServiceHandlerBase handler, ILogger<SkillController> logger) | ||
: base(handler) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public override Task<IActionResult> ReplyToActivityAsync(string conversationId, string activityId, Activity activity) | ||
{ | ||
try | ||
{ | ||
if (_logger.IsEnabled(LogLevel.Debug)) | ||
{ | ||
_logger.LogDebug($"ReplyToActivityAsync: conversationId={conversationId}, activityId={activityId}"); | ||
} | ||
|
||
return base.ReplyToActivityAsync(conversationId, activityId, activity); | ||
} | ||
catch (Exception ex) | ||
{ | ||
_logger.LogError(ex, $"ReplyToActivityAsync: {ex}"); | ||
throw; | ||
} | ||
} | ||
|
||
public override Task<IActionResult> SendToConversationAsync(string conversationId, Activity activity) | ||
{ | ||
try | ||
{ | ||
if (_logger.IsEnabled(LogLevel.Debug)) | ||
{ | ||
_logger.LogDebug($"SendToConversationAsync: conversationId={conversationId}"); | ||
} | ||
|
||
return base.SendToConversationAsync(conversationId, activity); | ||
} | ||
catch (Exception ex) | ||
{ | ||
_logger.LogError(ex, $"SendToConversationAsync: {ex}"); | ||
throw; | ||
} | ||
} | ||
} | ||
} |
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,5 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/microsoft/BotFramework-Composer/main/Composer/packages/server/schemas/botproject.schema", | ||
"name": "HCI_Chatbot", | ||
"skills": {} | ||
} |
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,19 @@ | ||
|
||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel> | ||
<UserSecretsId>9b74a358-bcae-472f-9553-55494c7c1eb1</UserSecretsId> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Content Include="**/*.blu;**/*.dialog;**/*.lg;**/*.lu;**/*.model;**/*.onnx;**/*.qna;**/*.txt" Exclude="$(BaseOutputPath)/**;$(BaseIntermediateOutputPath)/**;wwwroot/**"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.8" /> | ||
<PackageReference Include="Microsoft.Bot.Builder.AI.Luis" Version="4.18.1" /> | ||
<PackageReference Include="Microsoft.Bot.Builder.AI.QnA" Version="4.18.1" /> | ||
<PackageReference Include="Microsoft.Bot.Builder.Dialogs.Adaptive.Runtime" Version="4.18.1" /> | ||
</ItemGroup> | ||
</Project> |
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,71 @@ | ||
{ | ||
"$kind": "Microsoft.AdaptiveDialog", | ||
"$designer": { | ||
"name": "HCI_Chatbot", | ||
"description": "", | ||
"id": "A79tBe" | ||
}, | ||
"autoEndDialog": true, | ||
"defaultResultProperty": "dialog.result", | ||
"triggers": [ | ||
{ | ||
"$kind": "Microsoft.OnConversationUpdateActivity", | ||
"$designer": { | ||
"id": "376720", | ||
"comment": "This trigger runs when a conversation update activity is sent to the bot. This indicates a user or bot being added or removed from a conversation." | ||
}, | ||
"actions": [ | ||
{ | ||
"$kind": "Microsoft.Foreach", | ||
"$designer": { | ||
"id": "518944", | ||
"name": "Loop: for each item", | ||
"comment": "For each member added to the conversation." | ||
}, | ||
"itemsProperty": "turn.Activity.membersAdded", | ||
"actions": [ | ||
{ | ||
"$kind": "Microsoft.IfCondition", | ||
"$designer": { | ||
"id": "641773", | ||
"name": "Branch: if/else", | ||
"comment": "Checks that that member added ID does not match the bot ID. This prevents the greeting message from being sent when the bot is added to a conversation." | ||
}, | ||
"condition": "=string(dialog.foreach.value.id) != string(turn.Activity.Recipient.id)", | ||
"actions": [ | ||
{ | ||
"$kind": "Microsoft.SendActivity", | ||
"$designer": { | ||
"id": "859266", | ||
"name": "Send a response" | ||
}, | ||
"activity": "${SendActivity_Greeting()}" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"$kind": "Microsoft.OnUnknownIntent", | ||
"$designer": { | ||
"id": "mb2n1u", | ||
"comment": "This trigger fires when an incoming activity is not handled by any other trigger." | ||
}, | ||
"actions": [ | ||
{ | ||
"$kind": "Microsoft.SendActivity", | ||
"$designer": { | ||
"id": "kMjqz1", | ||
"comment": "It is recommended to show a message to the user when the bot does not know how to handle an incoming activity and provide follow up options or a help message." | ||
}, | ||
"activity": "${SendActivity_DidNotUnderstand()}" | ||
} | ||
] | ||
} | ||
], | ||
"generator": "HCI_Chatbot.lg", | ||
"id": "HCI_Chatbot", | ||
"recognizer": "HCI_Chatbot.lu.qna" | ||
} |
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,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<packageSources> | ||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> | ||
<add key="BotBuilder.myget.org" value="https://botbuilder.myget.org/F/botbuilder-v4-dotnet-daily/api/v3/index.json" protocolVersion="3" /> | ||
</packageSources> | ||
</configuration> |
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,33 @@ | ||
using System; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Bot.Builder.Dialogs.Adaptive.Runtime.Extensions; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Hosting; | ||
|
||
namespace HCI_Chatbot | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
CreateHostBuilder(args).Build().Run(); | ||
} | ||
|
||
public static IHostBuilder CreateHostBuilder(string[] args) => | ||
Host.CreateDefaultBuilder(args) | ||
.ConfigureAppConfiguration((hostingContext, builder) => | ||
{ | ||
var applicationRoot = AppDomain.CurrentDomain.BaseDirectory; | ||
var environmentName = hostingContext.HostingEnvironment.EnvironmentName; | ||
var settingsDirectory = "settings"; | ||
|
||
builder.AddBotRuntimeConfiguration(applicationRoot, settingsDirectory, environmentName); | ||
|
||
builder.AddCommandLine(args); | ||
}) | ||
.ConfigureWebHostDefaults(webBuilder => | ||
{ | ||
webBuilder.UseStartup<Startup>(); | ||
}); | ||
} | ||
} |
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,27 @@ | ||
{ | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:3978", | ||
"sslPort": 0 | ||
} | ||
}, | ||
"profiles": { | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"BotProject": { | ||
"commandName": "Project", | ||
"launchBrowser": true, | ||
"applicationUrl": "http://localhost:3978", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
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,27 @@ | ||
# Welcome to your new bot | ||
|
||
This bot project was created using the Empty Bot template, and contains a minimal set of files necessary to have a working bot. | ||
|
||
## Next steps | ||
|
||
### Start building your bot | ||
|
||
Composer can help guide you through getting started building your bot. From your bot settings page (the wrench icon on the left navigation rail), click on the rocket-ship icon on the top right for some quick navigation links. | ||
|
||
Another great resource if you're just getting started is the **[guided tutorial](https://docs.microsoft.com/en-us/composer/tutorial/tutorial-introduction)** in our documentation. | ||
|
||
### Connect with your users | ||
|
||
Your bot comes pre-configured to connect to our Web Chat and DirectLine channels, but there are many more places you can connect your bot to - including Microsoft Teams, Telephony, DirectLine Speech, Slack, Facebook, Outlook and more. Check out all of the places you can connect to on the bot settings page. | ||
|
||
### Publish your bot to Azure from Composer | ||
|
||
Composer can help you provision the Azure resources necessary for your bot, and publish your bot to them. To get started, create a publishing profile from your bot settings page in Composer (the wrench icon on the left navigation rail). Make sure you only provision the optional Azure resources you need! | ||
|
||
### Extend your bot with packages | ||
|
||
From Package Manager in Composer you can find useful packages to help add additional pre-built functionality you can add to your bot - everything from simple dialogs & custom actions for working with specific scenarios to custom adapters for connecting your bot to users on clients like Facebook or Slack. | ||
|
||
### Extend your bot with code | ||
|
||
You can also extend your bot with code - simply open up the folder that was generated for you in the location you chose during the creation process with your favorite IDE (like Visual Studio). You can do things like create custom actions that can be used during dialog flows, create custom middleware to pre-process (or post-process) messages, and more. See [our documentation](https://aka.ms/bf-extend-with-code) for more information. |
Oops, something went wrong.