forked from microsoft/BotBuilder-Samples
-
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.
samples and generator updates for 4.4 release
- update all samples, all languages, all platforms - update VSIX and yeoman code generators - add .NET Templates - update master README.md - update SPEC.md - update INSTALLING_CLI_TOOLS.md
- Loading branch information
Showing
1,686 changed files
with
44,393 additions
and
123,319 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
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
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
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
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
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
44 changes: 44 additions & 0 deletions
44
...dotnet-templates/Microsoft.BotFramework.CSharp.CoreBot/content/AdapterWithErrorHandler.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,44 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
// | ||
// Generated with CoreBot .NET Template version __vX.X.X__ | ||
|
||
using System; | ||
using Microsoft.Bot.Builder; | ||
using Microsoft.Bot.Builder.Integration.AspNet.Core; | ||
using Microsoft.Bot.Connector.Authentication; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace __PROJECT_NAME__ | ||
{ | ||
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}"); | ||
} | ||
} | ||
}; | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
generators/dotnet-templates/Microsoft.BotFramework.CSharp.CoreBot/content/BookingDetails.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,16 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
// | ||
// Generated with CoreBot .NET Template version __vX.X.X__ | ||
|
||
namespace __PROJECT_NAME__ | ||
{ | ||
public class BookingDetails | ||
{ | ||
public string Destination { get; set; } | ||
|
||
public string Origin { get; set; } | ||
|
||
public string TravelDate { get; set; } | ||
} | ||
} |
61 changes: 0 additions & 61 deletions
61
generators/dotnet-templates/Microsoft.BotFramework.CSharp.CoreBot/content/BotServices.cs
This file was deleted.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
...otnet-templates/Microsoft.BotFramework.CSharp.CoreBot/content/Bots/DialogAndWelcomeBot.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,63 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
// | ||
// Generated with CoreBot .NET Template version __vX.X.X__ | ||
|
||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Bot.Builder; | ||
using Microsoft.Bot.Builder.Dialogs; | ||
using Microsoft.Bot.Schema; | ||
using Microsoft.Extensions.Logging; | ||
using Newtonsoft.Json; | ||
|
||
namespace __PROJECT_NAME__.Bots | ||
{ | ||
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() | ||
{ | ||
// combine path for cross platform support | ||
string[] paths = { ".", "Cards", "welcomeCard.json" }; | ||
string fullPath = Path.Combine(paths); | ||
var adaptiveCard = File.ReadAllText(fullPath); | ||
return new Attachment() | ||
{ | ||
ContentType = "application/vnd.microsoft.card.adaptive", | ||
Content = JsonConvert.DeserializeObject(adaptiveCard), | ||
}; | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.