update webapi to core bot
This commit is contained in:
Родитель
c9d4642315
Коммит
461dc7073e
|
@ -70,7 +70,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Bot.ApplicationIn
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Bot.Builder.ApplicationInsights.Tests", "tests\Microsoft.Bot.Builder.ApplicationInsights.Tests\Microsoft.Bot.Builder.ApplicationInsights.Tests.csproj", "{D790A4BB-D8AC-4AAE-B3FE-0CF432CA8031}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Bot.Builder.TestBot", "tests\Microsoft.Bot.Builder.TestBot\Microsoft.Bot.Builder.TestBot.csproj", "{C113E0AE-5564-4389-BA39-183A8D574210}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Bot.Builder.TestBot", "tests\Microsoft.Bot.Builder.TestBot\Microsoft.Bot.Builder.TestBot.csproj", "{C113E0AE-5564-4389-BA39-183A8D574210}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Bot.Builder.TestBot.WebApi", "tests\Microsoft.Bot.Builder.TestBot.WebApi\Microsoft.Bot.Builder.TestBot.WebApi.csproj", "{610963BB-2717-47AB-BFEB-C8856A4A7CA7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -319,6 +321,14 @@ Global
|
|||
{C113E0AE-5564-4389-BA39-183A8D574210}.Documentation|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C113E0AE-5564-4389-BA39-183A8D574210}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C113E0AE-5564-4389-BA39-183A8D574210}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{610963BB-2717-47AB-BFEB-C8856A4A7CA7}.Debug - NuGet Packages|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{610963BB-2717-47AB-BFEB-C8856A4A7CA7}.Debug - NuGet Packages|Any CPU.Build.0 = Debug|Any CPU
|
||||
{610963BB-2717-47AB-BFEB-C8856A4A7CA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{610963BB-2717-47AB-BFEB-C8856A4A7CA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{610963BB-2717-47AB-BFEB-C8856A4A7CA7}.Documentation|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{610963BB-2717-47AB-BFEB-C8856A4A7CA7}.Documentation|Any CPU.Build.0 = Debug|Any CPU
|
||||
{610963BB-2717-47AB-BFEB-C8856A4A7CA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{610963BB-2717-47AB-BFEB-C8856A4A7CA7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -357,6 +367,7 @@ Global
|
|||
{873BCC1F-ED12-424E-93FA-D76F4BA022C2} = {0A0E26B0-7A46-4F1A-8BFE-9A763FDF6CF8}
|
||||
{D790A4BB-D8AC-4AAE-B3FE-0CF432CA8031} = {AD743B78-D61F-4FBF-B620-FA83CE599A50}
|
||||
{C113E0AE-5564-4389-BA39-183A8D574210} = {AD743B78-D61F-4FBF-B620-FA83CE599A50}
|
||||
{610963BB-2717-47AB-BFEB-C8856A4A7CA7} = {AD743B78-D61F-4FBF-B620-FA83CE599A50}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {7173C9F3-A7F9-496E-9078-9156E35D6E16}
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using Microsoft.Bot.Builder;
|
||||
using Microsoft.Bot.Builder.Integration.AspNet.WebApi;
|
||||
using Microsoft.Bot.Connector.Authentication;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Microsoft.BotBuilderSamples
|
||||
{
|
||||
public class AdapterWithErrorHandler : BotFrameworkHttpAdapter
|
||||
{
|
||||
public AdapterWithErrorHandler(ICredentialProvider credentialProvider, ILogger<BotFrameworkHttpAdapter> logger, ConversationState conversationState = null)
|
||||
: base(credentialProvider)
|
||||
{
|
||||
OnTurnError = async (turnContext, exception) =>
|
||||
{
|
||||
// Log any leaked exception from the application.
|
||||
logger.LogError($"Exception caught : {exception.Message}");
|
||||
|
||||
// Send a catch-all appology to the user.
|
||||
await turnContext.SendActivityAsync("Sorry, it looks like something went wrong.");
|
||||
|
||||
if (conversationState != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Delete the conversationState for the current conversation to prevent the
|
||||
// bot from getting stuck in a error-loop caused by being in a bad state.
|
||||
// ConversationState should be thought of as similar to "cookie-state" in a Web pages.
|
||||
await conversationState.DeleteAsync(turnContext);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogError($"Exception caught on attempting to Delete ConversationState : {e.Message}");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace Microsoft.Bot.Builder.TestBot.WebApi
|
||||
{
|
||||
public static class WebApiConfig
|
||||
{
|
||||
public static void Register(HttpConfiguration config)
|
||||
{
|
||||
// Web API configuration and services
|
||||
|
||||
// Web API routes
|
||||
config.MapHttpAttributeRoutes();
|
||||
|
||||
config.Routes.MapHttpRoute(
|
||||
name: "DefaultApi",
|
||||
routeTemplate: "api/{controller}/{id}",
|
||||
defaults: new { id = RouteParameter.Optional }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
namespace Microsoft.BotBuilderSamples
|
||||
{
|
||||
public class BookingDetails
|
||||
{
|
||||
public string Destination { get; set; }
|
||||
public string Origin { get; set; }
|
||||
public string TravelDate { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Microsoft.Bot.Builder;
|
||||
using Microsoft.Bot.Builder.Dialogs;
|
||||
using Microsoft.Bot.Schema;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.BotBuilderSamples
|
||||
{
|
||||
public class DialogAndWelcomeBot<T> : DialogBot<T> where T : Dialog
|
||||
{
|
||||
public DialogAndWelcomeBot(ConversationState conversationState, UserState userState, T dialog, ILogger<DialogBot<T>> logger)
|
||||
: base(conversationState, userState, dialog, logger)
|
||||
{
|
||||
}
|
||||
|
||||
protected override async Task OnMembersAddedAsync(IList<ChannelAccount> membersAdded, ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken)
|
||||
{
|
||||
foreach (var member in membersAdded)
|
||||
{
|
||||
// Greet anyone that was not the target (recipient) of this message.
|
||||
// To learn more about Adaptive Cards, see https://aka.ms/msbot-adaptivecards for more details.
|
||||
if (member.Id != turnContext.Activity.Recipient.Id)
|
||||
{
|
||||
var welcomeCard = CreateAdaptiveCardAttachment();
|
||||
var response = CreateResponse(turnContext.Activity, welcomeCard);
|
||||
await turnContext.SendActivityAsync(response, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create an attachment message response.
|
||||
private Activity CreateResponse(IActivity activity, Attachment attachment)
|
||||
{
|
||||
var response = ((Activity)activity).CreateReply();
|
||||
response.Attachments = new List<Attachment>() { attachment };
|
||||
return response;
|
||||
}
|
||||
|
||||
// Load attachment from file.
|
||||
private Attachment CreateAdaptiveCardAttachment()
|
||||
{
|
||||
// This is WebApi specific code to get the absolute path.
|
||||
string fullPath = HttpContext.Current.Server.MapPath("/Cards/welcomeCard.json");
|
||||
|
||||
var adaptiveCard = File.ReadAllText(fullPath);
|
||||
return new Attachment()
|
||||
{
|
||||
ContentType = "application/vnd.microsoft.card.adaptive",
|
||||
Content = JsonConvert.DeserializeObject(adaptiveCard),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Bot.Builder;
|
||||
using Microsoft.Bot.Builder.Dialogs;
|
||||
using Microsoft.Bot.Schema;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Microsoft.BotBuilderSamples
|
||||
{
|
||||
// This IBot implementation can run any type of Dialog. The use of type parameterization is to allows multiple different bots
|
||||
// to be run at different endpoints within the same project. This can be achieved by defining distinct Controller types
|
||||
// each with dependency on distinct IBot types, this way ASP Dependency Injection can glue everything together without ambiguity.
|
||||
// The ConversationState is used by the Dialog system. The UserState isn't, however, it might have been used in a Dialog implementation,
|
||||
// and the requirement is that all BotState objects are saved at the end of a turn.
|
||||
public class DialogBot<T> : ActivityHandler where T : Dialog
|
||||
{
|
||||
protected readonly Dialog _dialog;
|
||||
protected readonly BotState _conversationState;
|
||||
protected readonly BotState _userState;
|
||||
protected readonly ILogger _logger;
|
||||
|
||||
public DialogBot(ConversationState conversationState, UserState userState, T dialog, ILogger<DialogBot<T>> logger)
|
||||
{
|
||||
_conversationState = conversationState;
|
||||
_userState = userState;
|
||||
_dialog = dialog;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public override async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken)
|
||||
{
|
||||
await base.OnTurnAsync(turnContext, cancellationToken);
|
||||
|
||||
// Save any state changes that might have occured during the turn.
|
||||
await _conversationState.SaveChangesAsync(turnContext, false, cancellationToken);
|
||||
await _userState.SaveChangesAsync(turnContext, false, cancellationToken);
|
||||
}
|
||||
|
||||
protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.LogInformation("Running dialog with Message Activity.");
|
||||
|
||||
// Run the Dialog with the new message Activity.
|
||||
await _dialog.Run(turnContext, _conversationState.CreateProperty<DialogState>("DialogState"), cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
|
||||
"type": "AdaptiveCard",
|
||||
"version": "1.0",
|
||||
"body": [
|
||||
{
|
||||
"type": "Image",
|
||||
"url": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQtB3AwMUeNoq4gUBGe6Ocj8kyh3bXa9ZbV7u1fVKQoyKFHdkqU",
|
||||
"size": "stretch"
|
||||
},
|
||||
{
|
||||
"type": "TextBlock",
|
||||
"spacing": "medium",
|
||||
"size": "default",
|
||||
"weight": "bolder",
|
||||
"text": "Welcome to Bot Framework!",
|
||||
"wrap": true,
|
||||
"maxLines": 0
|
||||
},
|
||||
{
|
||||
"type": "TextBlock",
|
||||
"size": "default",
|
||||
"isSubtle": "yes",
|
||||
"text": "Now that you have successfully run your bot, follow the links in this Adaptive Card to expand your knowledge of Bot Framework.",
|
||||
"wrap": true,
|
||||
"maxLines": 0
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"type": "Action.OpenUrl",
|
||||
"title": "Get an overview",
|
||||
"url": "https://docs.microsoft.com/en-us/azure/bot-service/?view=azure-bot-service-4.0"
|
||||
},
|
||||
{
|
||||
"type": "Action.OpenUrl",
|
||||
"title": "Ask a question",
|
||||
"url": "https://stackoverflow.com/questions/tagged/botframework"
|
||||
},
|
||||
{
|
||||
"type": "Action.OpenUrl",
|
||||
"title": "Learn how to deploy",
|
||||
"url": "https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-howto-deploy-azure?view=azure-bot-service-4.0"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Http;
|
||||
using Microsoft.Bot.Builder;
|
||||
using Microsoft.Bot.Builder.BotFramework;
|
||||
using Microsoft.Bot.Builder.Integration.AspNet.WebApi;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Microsoft.BotBuilderSamples
|
||||
{
|
||||
[Route("api/messages")]
|
||||
public class BotController : ApiController
|
||||
{
|
||||
private static LoggerFactory _loggerFactory;
|
||||
private static IBotFrameworkHttpAdapter _adapter;
|
||||
private static ConversationState _conversationState;
|
||||
private static UserState _userState;
|
||||
private static MainDialog _dialog;
|
||||
|
||||
// In this example we will be using a static constructor on the Controller as these objects
|
||||
// should be singletons. Most likely a production application will be using one of the
|
||||
// Dependency Injection systems from NuGet such as Autofac, Unity, Ninject etc.
|
||||
static BotController()
|
||||
{
|
||||
_loggerFactory = new LoggerFactory();
|
||||
|
||||
// create the User and ConversationState objects (in this case, for testing, both based on the same memory store)
|
||||
var storage = new MemoryStorage();
|
||||
_conversationState = new ConversationState(storage);
|
||||
_userState = new UserState(storage);
|
||||
|
||||
// create the BotAdapter we will be using
|
||||
var credentialProvider = new ConfigurationCredentialProvider();
|
||||
_adapter = new AdapterWithErrorHandler(credentialProvider, _loggerFactory.CreateLogger<BotFrameworkHttpAdapter>(), _conversationState);
|
||||
|
||||
// read the old style Web.Config settings and construct a new style dot net core IConfiguration object
|
||||
var appsettings = ConfigurationManager.AppSettings.AllKeys.SelectMany(
|
||||
ConfigurationManager.AppSettings.GetValues,
|
||||
(k, v) => new KeyValuePair<string, string>(k, v));
|
||||
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.AddInMemoryCollection(appsettings)
|
||||
.Build();
|
||||
|
||||
// create the Dialog this bot will run - we need configuration because this Dialog will call LUIS
|
||||
_dialog = new MainDialog(configuration, _loggerFactory.CreateLogger<MainDialog>());
|
||||
}
|
||||
|
||||
public async Task<HttpResponseMessage> Post()
|
||||
{
|
||||
var response = new HttpResponseMessage();
|
||||
|
||||
var bot = new DialogAndWelcomeBot<MainDialog>(_conversationState, _userState, _dialog, _loggerFactory.CreateLogger<DialogBot<MainDialog>>());
|
||||
|
||||
await _adapter.ProcessAsync(Request, response, bot);
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Bot.Builder;
|
||||
using Microsoft.Bot.Builder.Dialogs;
|
||||
|
||||
namespace Microsoft.BotBuilderSamples
|
||||
{
|
||||
public static class DialogExtensions
|
||||
{
|
||||
public static async Task Run(this Dialog dialog, ITurnContext turnContext, IStatePropertyAccessor<DialogState> accessor, CancellationToken cancellationToken)
|
||||
{
|
||||
var dialogSet = new DialogSet(accessor);
|
||||
dialogSet.Add(dialog);
|
||||
|
||||
var dialogContext = await dialogSet.CreateContextAsync(turnContext, cancellationToken);
|
||||
var results = await dialogContext.ContinueDialogAsync(cancellationToken);
|
||||
if (results.Status == DialogTurnStatus.Empty)
|
||||
{
|
||||
await dialogContext.BeginDialogAsync(dialog.Id, null, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Bot.Builder;
|
||||
using Microsoft.Bot.Builder.Dialogs;
|
||||
using Microsoft.Recognizers.Text.DataTypes.TimexExpression;
|
||||
|
||||
namespace Microsoft.BotBuilderSamples
|
||||
{
|
||||
public class BookingDialog : CancelAndHelpDialog
|
||||
{
|
||||
public BookingDialog()
|
||||
: base(nameof(BookingDialog))
|
||||
{
|
||||
AddDialog(new TextPrompt(nameof(TextPrompt)));
|
||||
AddDialog(new ConfirmPrompt(nameof(ConfirmPrompt)));
|
||||
AddDialog(new DateResolverDialog());
|
||||
AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
|
||||
{
|
||||
DestinationStepAsync,
|
||||
OriginStepAsync,
|
||||
TravelDateStepAsync,
|
||||
ConfirmStepAsync,
|
||||
FinalStepAsync,
|
||||
}));
|
||||
|
||||
// The initial child Dialog to run.
|
||||
InitialDialogId = nameof(WaterfallDialog);
|
||||
}
|
||||
|
||||
private async Task<DialogTurnResult> DestinationStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
|
||||
{
|
||||
var bookingDetails = (BookingDetails)stepContext.Options;
|
||||
|
||||
if (bookingDetails.Destination == null)
|
||||
{
|
||||
return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Where would you like to travel to?") }, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
return await stepContext.NextAsync(bookingDetails.Destination);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<DialogTurnResult> OriginStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
|
||||
{
|
||||
var bookingDetails = (BookingDetails)stepContext.Options;
|
||||
|
||||
bookingDetails.Destination = (string)stepContext.Result;
|
||||
|
||||
if (bookingDetails.Origin == null)
|
||||
{
|
||||
return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Where are you traveling from?") }, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
return await stepContext.NextAsync(bookingDetails.Origin);
|
||||
}
|
||||
}
|
||||
private async Task<DialogTurnResult> TravelDateStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
|
||||
{
|
||||
var bookingDetails = (BookingDetails)stepContext.Options;
|
||||
|
||||
bookingDetails.Origin = (string)stepContext.Result;
|
||||
|
||||
if (bookingDetails.TravelDate == null || IsAmbiguous(bookingDetails.TravelDate))
|
||||
{
|
||||
return await stepContext.BeginDialogAsync(nameof(DateResolverDialog), bookingDetails.TravelDate, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
return await stepContext.NextAsync(bookingDetails.TravelDate);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<DialogTurnResult> ConfirmStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
|
||||
{
|
||||
var bookingDetails = (BookingDetails)stepContext.Options;
|
||||
|
||||
bookingDetails.TravelDate = (string)stepContext.Result;
|
||||
|
||||
var msg = $"Please confirm, I have you traveling to: {bookingDetails.Destination} from: {bookingDetails.Origin} on: {bookingDetails.TravelDate}";
|
||||
|
||||
return await stepContext.PromptAsync(nameof(ConfirmPrompt), new PromptOptions { Prompt = MessageFactory.Text(msg) }, cancellationToken);
|
||||
}
|
||||
|
||||
private async Task<DialogTurnResult> FinalStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
|
||||
{
|
||||
if ((bool)stepContext.Result == true)
|
||||
{
|
||||
var bookingDetails = (BookingDetails)stepContext.Options;
|
||||
|
||||
return await stepContext.EndDialogAsync(bookingDetails);
|
||||
}
|
||||
else
|
||||
{
|
||||
return await stepContext.EndDialogAsync(null);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsAmbiguous(string timex)
|
||||
{
|
||||
var timexPropery = new TimexProperty(timex);
|
||||
return !timexPropery.Types.Contains(Constants.TimexTypes.Definite);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Bot.Builder.Dialogs;
|
||||
using Microsoft.Bot.Schema;
|
||||
|
||||
namespace Microsoft.BotBuilderSamples
|
||||
{
|
||||
public class CancelAndHelpDialog : ComponentDialog
|
||||
{
|
||||
public CancelAndHelpDialog(string id)
|
||||
: base(id)
|
||||
{
|
||||
}
|
||||
|
||||
protected override async Task<DialogTurnResult> OnBeginDialogAsync(DialogContext innerDc, object options, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await InterruptAsync(innerDc, cancellationToken);
|
||||
if (result != null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
return await base.OnBeginDialogAsync(innerDc, options, cancellationToken);
|
||||
}
|
||||
|
||||
protected override async Task<DialogTurnResult> OnContinueDialogAsync(DialogContext innerDc, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await InterruptAsync(innerDc, cancellationToken);
|
||||
if (result != null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
return await base.OnContinueDialogAsync(innerDc, cancellationToken);
|
||||
}
|
||||
|
||||
private async Task<DialogTurnResult> InterruptAsync(DialogContext innerDc, CancellationToken cancellationToken)
|
||||
{
|
||||
if (innerDc.Context.Activity.Type == ActivityTypes.Message)
|
||||
{
|
||||
var text = innerDc.Context.Activity.Text.ToLowerInvariant();
|
||||
|
||||
switch (text)
|
||||
{
|
||||
case "help":
|
||||
case "?":
|
||||
await innerDc.Context.SendActivityAsync($"Show Help...");
|
||||
return new DialogTurnResult(DialogTurnStatus.Waiting);
|
||||
|
||||
case "cancel":
|
||||
case "quit":
|
||||
await innerDc.Context.SendActivityAsync($"Cancelling");
|
||||
return await innerDc.CancelAllDialogsAsync();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Bot.Builder;
|
||||
using Microsoft.Bot.Builder.Dialogs;
|
||||
using Microsoft.Recognizers.Text.DataTypes.TimexExpression;
|
||||
|
||||
namespace Microsoft.BotBuilderSamples
|
||||
{
|
||||
public class DateResolverDialog : CancelAndHelpDialog
|
||||
{
|
||||
public DateResolverDialog(string id = null)
|
||||
: base(id ?? nameof(DateResolverDialog))
|
||||
{
|
||||
AddDialog(new DateTimePrompt(nameof(DateTimePrompt), DateTimePromptValidator));
|
||||
AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
|
||||
{
|
||||
InitialStepAsync,
|
||||
FinalStepAsync,
|
||||
}));
|
||||
|
||||
// The initial child Dialog to run.
|
||||
InitialDialogId = nameof(WaterfallDialog);
|
||||
}
|
||||
|
||||
private async Task<DialogTurnResult> InitialStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
|
||||
{
|
||||
var timex = (string)stepContext.Options;
|
||||
|
||||
var promptMsg = "When would you like to travel?";
|
||||
var repromptMsg = $"I'm sorry, to make your booking please enter a full travel date including Day Month and Year.";
|
||||
|
||||
if (timex == null)
|
||||
{
|
||||
// We were not given any date at all so prompt the user.
|
||||
return await stepContext.PromptAsync(nameof(DateTimePrompt),
|
||||
new PromptOptions
|
||||
{
|
||||
Prompt = MessageFactory.Text(promptMsg),
|
||||
RetryPrompt = MessageFactory.Text(repromptMsg)
|
||||
}, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We have a Date we just need to check it is unambiguous.
|
||||
var timexProperty = new TimexProperty(timex);
|
||||
if (!timexProperty.Types.Contains(Constants.TimexTypes.Definite))
|
||||
{
|
||||
// This is essentially a "reprompt" of the data we were given up front.
|
||||
return await stepContext.PromptAsync(nameof(DateTimePrompt),
|
||||
new PromptOptions
|
||||
{
|
||||
Prompt = MessageFactory.Text(repromptMsg)
|
||||
}, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
return await stepContext.NextAsync(new List<DateTimeResolution> { new DateTimeResolution { Timex = timex } });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<DialogTurnResult> FinalStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
|
||||
{
|
||||
var timex = ((List<DateTimeResolution>)stepContext.Result)[0].Timex;
|
||||
return await stepContext.EndDialogAsync(timex);
|
||||
}
|
||||
|
||||
private static Task<bool> DateTimePromptValidator(PromptValidatorContext<IList<DateTimeResolution>> promptContext, CancellationToken cancellationToken)
|
||||
{
|
||||
if (promptContext.Recognized.Succeeded)
|
||||
{
|
||||
// This value will be a TIMEX. And we are only interested in a Date so grab the first result and drop the Time part.
|
||||
// TIMEX is a format that represents DateTime expressions that include some ambiguity. e.g. missing a Year.
|
||||
var timex = promptContext.Recognized.Value[0].Timex.Split('T')[0];
|
||||
|
||||
// If this is a definite Date including year, month and day we are good otherwise reprompt.
|
||||
// A better solution might be to let the user know what part is actually missing.
|
||||
var isDefinite = new TimexProperty(timex).Types.Contains(Constants.TimexTypes.Definite);
|
||||
|
||||
return Task.FromResult(isDefinite);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Bot.Builder;
|
||||
using Microsoft.Bot.Builder.Dialogs;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Recognizers.Text.DataTypes.TimexExpression;
|
||||
|
||||
namespace Microsoft.BotBuilderSamples
|
||||
{
|
||||
public class MainDialog : ComponentDialog
|
||||
{
|
||||
protected readonly IConfiguration _configuration;
|
||||
protected readonly ILogger _logger;
|
||||
|
||||
public MainDialog(IConfiguration configuration, ILogger<MainDialog> logger)
|
||||
: base(nameof(MainDialog))
|
||||
{
|
||||
_configuration = configuration;
|
||||
_logger = logger;
|
||||
|
||||
AddDialog(new TextPrompt(nameof(TextPrompt)));
|
||||
AddDialog(new BookingDialog());
|
||||
AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
|
||||
{
|
||||
IntroStepAsync,
|
||||
ActStepAsync,
|
||||
FinalStepAsync,
|
||||
}));
|
||||
|
||||
// The initial child Dialog to run.
|
||||
InitialDialogId = nameof(WaterfallDialog);
|
||||
}
|
||||
|
||||
private async Task<DialogTurnResult> IntroStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_configuration["LuisAppId"]) || string.IsNullOrEmpty(_configuration["LuisAPIKey"]) || string.IsNullOrEmpty(_configuration["LuisAPIHostName"]))
|
||||
{
|
||||
await stepContext.Context.SendActivityAsync(
|
||||
MessageFactory.Text("NOTE: LUIS is not configured. To enable all capabilities, add 'LuisAppId', 'LuisAPIKey' and 'LuisAPIHostName' to the appsettings.json file."), cancellationToken);
|
||||
|
||||
return await stepContext.NextAsync(null, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("What can I help you with today?") }, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
|
||||
{
|
||||
// Call LUIS and gather any potential booking details. (Note the TurnContext has the response to the prompt.)
|
||||
var bookingDetails = stepContext.Result != null
|
||||
?
|
||||
await LuisHelper.ExecuteLuisQuery(_configuration, _logger, stepContext.Context, cancellationToken)
|
||||
:
|
||||
new BookingDetails();
|
||||
|
||||
// In this sample we only have a single Intent we are concerned with. However, typically a scneario
|
||||
// will have multiple different Intents each corresponding to starting a different child Dialog.
|
||||
|
||||
// Run the BookingDialog giving it whatever details we have from the LUIS call, it will fill out the remainder.
|
||||
return await stepContext.BeginDialogAsync(nameof(BookingDialog), bookingDetails, cancellationToken);
|
||||
}
|
||||
|
||||
private async Task<DialogTurnResult> FinalStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
|
||||
{
|
||||
// If the child dialog ("BookingDialog") was cancelled or the user failed to confirm, the Result here will be null.
|
||||
if (stepContext.Result != null)
|
||||
{
|
||||
var result = (BookingDetails)stepContext.Result;
|
||||
|
||||
// Now we have all the booking details call the booking service.
|
||||
|
||||
// If the call to the booking service was successful tell the user.
|
||||
|
||||
var timeProperty = new TimexProperty(result.TravelDate);
|
||||
var travelDateMsg = timeProperty.ToNaturalLanguage(DateTime.Now);
|
||||
var msg = $"I have you booked to {result.Destination} from {result.Origin} on {travelDateMsg}";
|
||||
await stepContext.Context.SendActivityAsync(MessageFactory.Text(msg), cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
await stepContext.Context.SendActivityAsync(MessageFactory.Text("Thank you."), cancellationToken);
|
||||
}
|
||||
return await stepContext.EndDialogAsync();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
<%@ Application Codebehind="Global.asax.cs" Inherits="Microsoft.Bot.Builder.TestBot.WebApi.WebApiApplication" Language="C#" %>
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Web.Http;
|
||||
|
||||
namespace Microsoft.Bot.Builder.TestBot.WebApi
|
||||
{
|
||||
public class WebApiApplication : System.Web.HttpApplication
|
||||
{
|
||||
protected void Application_Start()
|
||||
{
|
||||
GlobalConfiguration.Configure(WebApiConfig.Register);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Bot.Builder;
|
||||
using Microsoft.Bot.Builder.AI.Luis;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Microsoft.BotBuilderSamples
|
||||
{
|
||||
public static class LuisHelper
|
||||
{
|
||||
public static async Task<BookingDetails> ExecuteLuisQuery(IConfiguration configuration, ILogger logger, ITurnContext turnContext, CancellationToken cancellationToken)
|
||||
{
|
||||
var bookingDetails = new BookingDetails();
|
||||
|
||||
try
|
||||
{
|
||||
// Create the LUIS settings from configuration.
|
||||
var luisApplication = new LuisApplication(
|
||||
configuration["LuisAppId"],
|
||||
configuration["LuisAPIKey"],
|
||||
"https://" + configuration["LuisAPIHostName"]
|
||||
);
|
||||
|
||||
// TODO: fix the ambiguity introduced in 4.4.n
|
||||
var recognizer = new LuisRecognizer(luisApplication, null, false, null, null, false);
|
||||
|
||||
// The actual call to LUIS
|
||||
var recognizerResult = await recognizer.RecognizeAsync(turnContext, cancellationToken);
|
||||
|
||||
var (intent, score) = recognizerResult.GetTopScoringIntent();
|
||||
if (intent == "Book_flight")
|
||||
{
|
||||
// We need to get the result from the LUIS JSON which at every level returns an array.
|
||||
bookingDetails.Destination = recognizerResult.Entities["To"]?.FirstOrDefault()?["Airport"]?.FirstOrDefault()?.FirstOrDefault()?.ToString();
|
||||
bookingDetails.Origin = recognizerResult.Entities["From"]?.FirstOrDefault()?["Airport"]?.FirstOrDefault()?.FirstOrDefault()?.ToString();
|
||||
|
||||
// This value will be a TIMEX. And we are only interested in a Date so grab the first result and drop the Time part.
|
||||
// TIMEX is a format that represents DateTime expressions that include some ambiguity. e.g. missing a Year.
|
||||
bookingDetails.TravelDate = recognizerResult.Entities["datetime"]?.FirstOrDefault()?["timex"]?.FirstOrDefault()?.ToString().Split('T')[0];
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogWarning($"LUIS Exception: {e.Message} Check your LUIS configuration.");
|
||||
}
|
||||
|
||||
return bookingDetails;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,4 @@
|
|||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
|
||||
<Import Project="..\..\packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props" Condition="Exists('..\..\packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
|
@ -8,7 +6,7 @@
|
|||
<ProductVersion>
|
||||
</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{298009D3-971D-4375-A2F2-04CFB168CED9}</ProjectGuid>
|
||||
<ProjectGuid>{610963BB-2717-47AB-BFEB-C8856A4A7CA7}</ProjectGuid>
|
||||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
|
@ -22,9 +20,8 @@
|
|||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
<UseGlobalApplicationHostFile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<TargetFrameworkProfile />
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<EnableDefaultItems>false</EnableDefaultItems>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
@ -46,60 +43,39 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.Extensions.Logging.Abstractions.2.1.1\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.Rest.ClientRuntime.2.3.13\lib\net452\Microsoft.Rest.ClientRuntime.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Net.Http.Formatting, Version=5.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.6\lib\net45\System.Net.Http.Formatting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.WebRequest" />
|
||||
<Reference Include="System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Web.DynamicData" />
|
||||
<Reference Include="System.Web.Entity" />
|
||||
<Reference Include="System.Web.ApplicationServices" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Web.Http, Version=5.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Core.5.2.6\lib\net45\System.Web.Http.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http.WebHost, Version=5.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.6\lib\net45\System.Web.Http.WebHost.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="System.EnterpriseServices" />
|
||||
<Reference Include="Unity.Abstractions, Version=3.3.1.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Unity.Abstractions.3.3.1\lib\net46\Unity.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.AspNet.WebApi, Version=5.0.15.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Unity.AspNet.WebApi.5.0.15\lib\net46\Unity.AspNet.WebApi.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Container, Version=5.8.10.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Unity.Container.5.8.10\lib\net46\Unity.Container.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WebActivatorEx, Version=2.0.0.0, Culture=neutral, PublicKeyToken=7b26dc2a43f6a0d4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\WebActivatorEx.2.2.0\lib\net40\WebActivatorEx.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.Formatting">
|
||||
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.4\lib\net45\System.Net.Http.Formatting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http">
|
||||
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Core.5.2.4\lib\net45\System.Web.Http.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http.WebHost">
|
||||
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.4\lib\net45\System.Web.Http.WebHost.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform">
|
||||
<HintPath>..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
|
||||
<HintPath>..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -107,17 +83,25 @@
|
|||
<Content Include="Web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App_Start\UnityConfig.cs" />
|
||||
<Compile Include="App_Start\UnityWebApiActivator.cs" />
|
||||
<Compile Include="App_Start\BotConfig.cs" />
|
||||
<Compile Include="AdapterWithErrorHandler.cs" />
|
||||
<Compile Include="App_Start\WebApiConfig.cs" />
|
||||
<Compile Include="BookingDetails.cs" />
|
||||
<Compile Include="Bots\DialogAndWelcomeBot.cs" />
|
||||
<Compile Include="Bots\DialogBot.cs" />
|
||||
<Compile Include="Controllers\BotController.cs" />
|
||||
<Compile Include="DialogExtensions.cs" />
|
||||
<Compile Include="Dialogs\BookingDialog.cs" />
|
||||
<Compile Include="Dialogs\CancelAndHelpDialog.cs" />
|
||||
<Compile Include="Dialogs\DateResolverDialog.cs" />
|
||||
<Compile Include="Dialogs\MainDialog.cs" />
|
||||
<Compile Include="Global.asax.cs">
|
||||
<DependentUpon>Global.asax</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="InteceptorAdapter.cs" />
|
||||
<Compile Include="LuisHelper.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TestBot.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Cards\welcomeCard.json" />
|
||||
<None Include="Web.Debug.config">
|
||||
<DependentUpon>Web.config</DependentUpon>
|
||||
</None>
|
||||
|
@ -125,33 +109,6 @@
|
|||
<DependentUpon>Web.config</DependentUpon>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
<Folder Include="Controllers\" />
|
||||
<Folder Include="Models\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\libraries\integration\Microsoft.Bot.Builder.Integration.AspNet.WebApi\Microsoft.Bot.Builder.Integration.AspNet.WebApi.csproj">
|
||||
<Project>{bd0b82ef-1601-4e87-b78a-b43de7eb36b0}</Project>
|
||||
<Name>Microsoft.Bot.Builder.Integration.AspNet.WebApi</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\libraries\Microsoft.Bot.Builder.Dialogs\Microsoft.Bot.Builder.Dialogs.csproj">
|
||||
<Project>{0f639eb4-fb64-4909-8a10-fb93e7be3afb}</Project>
|
||||
<Name>Microsoft.Bot.Builder.Dialogs</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\libraries\Microsoft.Bot.Builder\Microsoft.Bot.Builder.csproj">
|
||||
<Project>{ada8ab8b-2066-4193-b8f7-985669b23e00}</Project>
|
||||
<Name>Microsoft.Bot.Builder</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\libraries\Microsoft.Bot.Connector\Microsoft.Bot.Connector.csproj">
|
||||
<Project>{6462da5d-27dc-4cd5-9467-5efb998fd838}</Project>
|
||||
<Name>Microsoft.Bot.Connector</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\libraries\Microsoft.Bot.Schema\Microsoft.Bot.Schema.csproj">
|
||||
<Project>{c1f54cdc-ad1d-45bb-8f7d-f49e411afaf1}</Project>
|
||||
<Name>Microsoft.Bot.Schema</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi">
|
||||
<Version>5.2.6</Version>
|
||||
|
@ -166,38 +123,49 @@
|
|||
<Version>5.2.6</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform">
|
||||
<Version>1.0.8</Version>
|
||||
<Version>2.0.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions">
|
||||
<Version>2.1.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Net.Compilers">
|
||||
<Version>2.6.1</Version>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Rest.ClientRuntime">
|
||||
<Version>2.3.13</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Web.Infrastructure">
|
||||
<Version>1.0.0</Version>
|
||||
<PackageReference Include="Microsoft.Recognizers.Text.DataTypes.TimexExpression">
|
||||
<Version>1.1.6</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json">
|
||||
<Version>10.0.3</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Unity.Abstractions">
|
||||
<Version>3.3.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Unity.AspNet.WebApi">
|
||||
<Version>5.0.15</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Unity.Container">
|
||||
<Version>5.8.10</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="WebActivatorEx">
|
||||
<Version>2.2.0</Version>
|
||||
<Version>11.0.1</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
<Folder Include="Models\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\libraries\integration\Microsoft.Bot.Builder.Integration.AspNet.WebApi\Microsoft.Bot.Builder.Integration.AspNet.WebApi.csproj">
|
||||
<Project>{bd0b82ef-1601-4e87-b78a-b43de7eb36b0}</Project>
|
||||
<Name>Microsoft.Bot.Builder.Integration.AspNet.WebApi</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\libraries\Microsoft.Bot.Builder.AI.LUIS\Microsoft.Bot.Builder.AI.Luis.csproj">
|
||||
<Project>{67aa3c00-e2c5-4d13-ba5e-72eb0e5b8daa}</Project>
|
||||
<Name>Microsoft.Bot.Builder.AI.Luis</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\libraries\Microsoft.Bot.Builder.Dialogs\Microsoft.Bot.Builder.Dialogs.csproj">
|
||||
<Project>{0f639eb4-fb64-4909-8a10-fb93e7be3afb}</Project>
|
||||
<Name>Microsoft.Bot.Builder.Dialogs</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\libraries\Microsoft.Bot.Builder\Microsoft.Bot.Builder.csproj">
|
||||
<Project>{ada8ab8b-2066-4193-b8f7-985669b23e00}</Project>
|
||||
<Name>Microsoft.Bot.Builder</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\libraries\Microsoft.Bot.Configuration\Microsoft.Bot.Configuration.csproj">
|
||||
<Project>{0b8abfdb-f9cf-4ec6-988e-9c32d9e01c26}</Project>
|
||||
<Name>Microsoft.Bot.Configuration</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\libraries\Microsoft.Bot.Connector\Microsoft.Bot.Connector.csproj">
|
||||
<Project>{6462da5d-27dc-4cd5-9467-5efb998fd838}</Project>
|
||||
<Name>Microsoft.Bot.Connector</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\libraries\Microsoft.Bot.Schema\Microsoft.Bot.Schema.csproj">
|
||||
<Project>{c1f54cdc-ad1d-45bb-8f7d-f49e411afaf1}</Project>
|
||||
<Name>Microsoft.Bot.Schema</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
|
@ -211,9 +179,9 @@
|
|||
<WebProjectProperties>
|
||||
<UseIIS>True</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>14972</DevelopmentServerPort>
|
||||
<DevelopmentServerPort>1811</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>http://localhost:11034/</IISUrl>
|
||||
<IISUrl>http://localhost:3978/</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>False</UseCustomServer>
|
||||
<CustomServerUrl>
|
||||
|
@ -223,11 +191,6 @@
|
|||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Microsoft.Bot.Builder.TestBot.WebApi")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Microsoft.Bot.Builder.TestBot.WebApi")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("610963bb-2717-47ab-bfeb-c8856a4a7ca7")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 -->
|
||||
|
||||
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
|
||||
<!--
|
||||
In the example below, the "SetAttributes" transform will change the value of
|
||||
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
|
||||
finds an attribute "name" that has a value of "MyDB".
|
||||
|
||||
<connectionStrings>
|
||||
<add name="MyDB"
|
||||
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
|
||||
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
|
||||
</connectionStrings>
|
||||
-->
|
||||
<system.web>
|
||||
<!--
|
||||
In the example below, the "Replace" transform will replace the entire
|
||||
<customErrors> section of your web.config file.
|
||||
Note that because there is only one customErrors section under the
|
||||
<system.web> node, there is no need to use the "xdt:Locator" attribute.
|
||||
|
||||
<customErrors defaultRedirect="GenericError.htm"
|
||||
mode="RemoteOnly" xdt:Transform="Replace">
|
||||
<error statusCode="500" redirect="InternalError.htm"/>
|
||||
</customErrors>
|
||||
-->
|
||||
</system.web>
|
||||
</configuration>
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 -->
|
||||
|
||||
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
|
||||
<!--
|
||||
In the example below, the "SetAttributes" transform will change the value of
|
||||
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
|
||||
finds an attribute "name" that has a value of "MyDB".
|
||||
|
||||
<connectionStrings>
|
||||
<add name="MyDB"
|
||||
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
|
||||
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
|
||||
</connectionStrings>
|
||||
-->
|
||||
<system.web>
|
||||
<compilation xdt:Transform="RemoveAttributes(debug)" />
|
||||
<!--
|
||||
In the example below, the "Replace" transform will replace the entire
|
||||
<customErrors> section of your web.config file.
|
||||
Note that because there is only one customErrors section under the
|
||||
<system.web> node, there is no need to use the "xdt:Locator" attribute.
|
||||
|
||||
<customErrors defaultRedirect="GenericError.htm"
|
||||
mode="RemoteOnly" xdt:Transform="Replace">
|
||||
<error statusCode="500" redirect="InternalError.htm"/>
|
||||
</customErrors>
|
||||
-->
|
||||
</system.web>
|
||||
</configuration>
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
For more information on how to configure your ASP.NET application, please visit
|
||||
https://go.microsoft.com/fwlink/?LinkId=301879
|
||||
-->
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="LuisAppId" value="" />
|
||||
<add key="LuisAPIKey" value="" />
|
||||
<add key="LuisAPIHostName" value="" />
|
||||
</appSettings>
|
||||
<system.web>
|
||||
<compilation debug="true" targetFramework="4.6.1" />
|
||||
<httpRuntime targetFramework="4.6.1" />
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
|
||||
<remove name="OPTIONSVerbHandler" />
|
||||
<remove name="TRACEVerbHandler" />
|
||||
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
Загрузка…
Ссылка в новой задаче