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
using Microsoft.Bot.Builder.Adapters.Twilio; | |
using Microsoft.Bot.Builder.TraceExtensions; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.Logging; | |
namespace AppointmentBot | |
{ | |
public class TwilioAdapterWithErrorHandler : TwilioAdapter | |
{ | |
public TwilioAdapterWithErrorHandler(IConfiguration configuration, ILogger<TwilioAdapter> logger) |
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
private async Task<DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) | |
{ | |
if (!_luisRecognizer.IsConfigured) | |
{ | |
// LUIS is not configured, we just run the BookingDialog path with an empty BookingDetailsInstance. | |
return await stepContext.BeginDialogAsync(nameof(AppointmentBookingDialog), new AppointmentDetails(), cancellationToken); | |
} | |
// Call LUIS and gather any potential booking details. (Note the TurnContext has the response to the prompt.) | |
var luisResult = await _luisRecognizer.RecognizeAsync<DoctorBooking>(stepContext.Context, cancellationToken); |
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
public class AppointmentBookingDialog : CancelAndHelpDialog | |
{ | |
private const string DoctorStepMsgText = "Who would you like to see?"; | |
public AppointmentBookingDialog() | |
: base(nameof(AppointmentBookingDialog)) | |
{ | |
AddDialog(new TextPrompt(nameof(TextPrompt))); | |
AddDialog(new ConfirmPrompt(nameof(ConfirmPrompt))); |
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
namespace AppointmentBot | |
{ | |
public class AppointmentDetails | |
{ | |
public string Doctor { get; set; } | |
public string AppointmentDate { get; set; } | |
} | |
} |
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
using Microsoft.Bot.Builder; | |
using Microsoft.Bot.Builder.AI.Luis; | |
using Microsoft.Extensions.Configuration; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace AppointmentBot | |
{ | |
public class AppointmentBookingRecognizer : IRecognizer | |
{ |
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
using System.Linq; | |
namespace AppointmentBot.CognitiveModels | |
{ | |
// Extends the partial DoctorBooking class with methods and properties that simplify accessing entities in the luis results | |
public partial class DoctorBooking | |
{ | |
public string Doctor | |
{ |
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
using Microsoft.Bot.Builder; | |
using Microsoft.Bot.Builder.AI.Luis; | |
using Newtonsoft.Json; | |
using System.Collections.Generic; | |
namespace AppointmentBot.CognitiveModels | |
{ | |
public partial class DoctorBooking : IRecognizerConvert | |
{ |
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
public class Startup | |
{ | |
// This method gets called by the runtime. Use this method to add services to the container. | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddHttpClient().AddControllers().AddNewtonsoftJson(); | |
// Create the Bot Framework Authentication to be used with the Bot Adapter. | |
services.AddSingleton<BotFrameworkAuthentication, ConfigurationBotFrameworkAuthentication>(); |
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
// Register LUIS recognizer | |
services.AddSingleton<FlightBookingRecognizer>(); | |
// Register the BookingDialog. | |
services.AddSingleton<BookingDialog>(); | |
// The MainDialog that will be run by the bot. | |
services.AddSingleton<MainDialog>(); | |
// Create the bot as a transient. In this case the ASP Controller is expecting an IBot. |
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
Remove-Item ./CognitiveModels/FlightBooking.cs | |
Remove-Item ./CognitiveModels/FlightBooking.json | |
Remove-Item ./CognitiveModels/FlightBookingEx.cs | |
Remove-Item ./Dialogs/BookingDialog.cs | |
Remove-Item ./Dialogs/MainDialog.cs | |
Remove-Item BookingDetails.cs | |
Remove-Item FlightBookingRecognizer.cs |