This repository has been archived by the owner on Jun 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add files for Hospitality Sample VA (#2030)
- Loading branch information
Showing
95 changed files
with
19,300 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,15 @@ | ||
{ | ||
"help": "https://go.microsoft.com/fwlink/?linkid=866610", | ||
"dependentFileProviders": { | ||
"add": { | ||
"pathSegment": { | ||
"add": { | ||
".*": [ | ||
".json", | ||
".resx" | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} |
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,40 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using Microsoft.Bot.Builder; | ||
using Microsoft.Bot.Builder.Azure; | ||
using Microsoft.Bot.Builder.Integration.AspNet.Core; | ||
using Microsoft.Bot.Builder.Solutions.Middleware; | ||
using Microsoft.Bot.Connector.Authentication; | ||
using Microsoft.Bot.Schema; | ||
using HospitalitySample.Responses.Main; | ||
using HospitalitySample.Services; | ||
|
||
namespace HospitalitySample.Adapters | ||
{ | ||
public class DefaultAdapter : BotFrameworkHttpAdapter | ||
{ | ||
public DefaultAdapter( | ||
BotSettings settings, | ||
ICredentialProvider credentialProvider, | ||
IBotTelemetryClient telemetryClient) | ||
: base(credentialProvider) | ||
{ | ||
OnTurnError = async (turnContext, exception) => | ||
{ | ||
await turnContext.SendActivityAsync(new Activity(type: ActivityTypes.Trace, text: $"{exception.Message}")); | ||
await turnContext.SendActivityAsync(new Activity(type: ActivityTypes.Trace, text: $"{exception.StackTrace}")); | ||
await turnContext.SendActivityAsync(MainStrings.ERROR); | ||
telemetryClient.TrackException(exception); | ||
}; | ||
|
||
// Uncomment the following line for local development without Azure Storage | ||
// Use(new TranscriptLoggerMiddleware(new MemoryTranscriptStore())); | ||
Use(new TranscriptLoggerMiddleware(new AzureBlobTranscriptStore(settings.BlobStorage.ConnectionString, settings.BlobStorage.Container))); | ||
Use(new TelemetryLoggerMiddleware(telemetryClient, logPersonalInformation: true)); | ||
Use(new ShowTypingMiddleware()); | ||
Use(new SetLocaleMiddleware(settings.DefaultLocale ?? "en-us")); | ||
Use(new EventDebuggerMiddleware()); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
solutions/HospitalitySample/Adapters/DefaultWebSocketAdapter.cs
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,41 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using Microsoft.Bot.Builder; | ||
using Microsoft.Bot.Builder.Solutions.Middleware; | ||
using Microsoft.Bot.Builder.StreamingExtensions; | ||
using Microsoft.Bot.Connector.Authentication; | ||
using Microsoft.Bot.Schema; | ||
using Microsoft.Extensions.Configuration; | ||
using HospitalitySample.Responses.Main; | ||
using HospitalitySample.Services; | ||
|
||
namespace HospitalitySample.Adapters | ||
{ | ||
public class DefaultWebSocketAdapter : WebSocketEnabledHttpAdapter | ||
{ | ||
public DefaultWebSocketAdapter( | ||
IConfiguration config, | ||
BotSettings settings, | ||
ICredentialProvider credentialProvider, | ||
IBotTelemetryClient telemetryClient) | ||
: base(config, credentialProvider) | ||
{ | ||
OnTurnError = async (turnContext, exception) => | ||
{ | ||
await turnContext.SendActivityAsync(new Activity(type: ActivityTypes.Trace, text: $"{exception.Message}")); | ||
await turnContext.SendActivityAsync(new Activity(type: ActivityTypes.Trace, text: $"{exception.StackTrace}")); | ||
await turnContext.SendActivityAsync(MainStrings.ERROR); | ||
telemetryClient.TrackException(exception); | ||
}; | ||
|
||
// Uncomment the following line for local development without Azure Storage | ||
// Use(new TranscriptLoggerMiddleware(new MemoryTranscriptStore())); Use(new TranscriptLoggerMiddleware(new AzureBlobTranscriptStore(settings.BlobStorage.ConnectionString, settings.BlobStorage.Container))); | ||
Use(new TelemetryLoggerMiddleware(telemetryClient, logPersonalInformation: true)); | ||
Use(new ShowTypingMiddleware()); | ||
Use(new SetLocaleMiddleware(settings.DefaultLocale ?? "en-us")); | ||
Use(new EventDebuggerMiddleware()); | ||
Use(new SetSpeakMiddleware(settings.DefaultLocale ?? "en-us")); | ||
} | ||
} | ||
} |
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,46 @@ | ||
// 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.Bot.Schema; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace HospitalitySample.Bots | ||
{ | ||
public class DialogBot<T> : IBot | ||
where T : Dialog | ||
{ | ||
private readonly Dialog _dialog; | ||
private readonly BotState _conversationState; | ||
private readonly BotState _userState; | ||
private readonly IBotTelemetryClient _telemetryClient; | ||
|
||
public DialogBot(IServiceProvider serviceProvider, T dialog) | ||
{ | ||
_dialog = dialog; | ||
_conversationState = serviceProvider.GetService<ConversationState>(); | ||
_userState = serviceProvider.GetService<UserState>(); | ||
_telemetryClient = serviceProvider.GetService<IBotTelemetryClient>(); | ||
} | ||
|
||
public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
// Client notifying this bot took to long to respond (timed out) | ||
if (turnContext.Activity.Code == EndOfConversationCodes.BotTimedOut) | ||
{ | ||
_telemetryClient.TrackTrace($"Timeout in {turnContext.Activity.ChannelId} channel: Bot took too long to respond.", Severity.Information, null); | ||
return; | ||
} | ||
|
||
await _dialog.RunAsync(turnContext, _conversationState.CreateProperty<DialogState>(nameof(DialogState)), cancellationToken); | ||
|
||
// Save any state changes that might have occured during the turn. | ||
await _conversationState.SaveChangesAsync(turnContext, false, cancellationToken); | ||
await _userState.SaveChangesAsync(turnContext, false, cancellationToken); | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
solutions/HospitalitySample/Connected Services/Application Insights/ConnectedService.json
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 @@ | ||
{ | ||
"ProviderId": "Microsoft.ApplicationInsights.ConnectedService.ConnectedServiceProvider", | ||
"Version": "8.13.10627.1", | ||
"GettingStartedDocument": { | ||
"Uri": "https://go.microsoft.com/fwlink/?LinkID=798432" | ||
} | ||
} |
Oops, something went wrong.