Skip to content

Commit

Permalink
samples and generator updates for 4.4 release
Browse files Browse the repository at this point in the history
- 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
sgellock committed May 2, 2019
1 parent d63f981 commit 447028b
Show file tree
Hide file tree
Showing 1,686 changed files with 44,393 additions and 123,319 deletions.
6 changes: 3 additions & 3 deletions INSTALLING_CLI_TOOLS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ The Bot Framework now has CLI tools to help quickly create bots and bot-specific
| [![npm version](https://badge.fury.io/js/luisgen.svg)](https://badge.fury.io/js/luisgen)| [LUISGen](packages/LUISGen) | Auto generate backing C#/Typescript classes for your LUIS intents and entities.|

## Install CLI tools:
Pre-requisites:
- [Node.js](https://nodejs.org/) version 8.5 or higher
- [dotnetcore 2.0](https://www.microsoft.com/net/download/dotnet-core/2.0) for `luisgen` and `botdispatch`
Pre-requisites:
- [Node.js](https://nodejs.org/) version 10.14 or higher
- [dotnetcore 2.1](https://www.microsoft.com/net/download/dotnet-core/2.1) for `luisgen` and `botdispatch`

Windows users can type the following into their CLI to install the tools:
```bash
Expand Down
147 changes: 36 additions & 111 deletions README.md

Large diffs are not rendered by default.

368 changes: 81 additions & 287 deletions SPEC.md

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions generators/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
## Overview
# Overview

This folder contains code generators for Microsoft **Bot Framework V4 SDK** - [dotnet SDK][10], [JS SDK][11].

Currently there are three code generator options to choose from. They are:

# Supported Code Generators
## Supported Code Generators

| Generator | Language Support | OS Support |
| --------- | ---------------- | ---------- |
| [.NET Core SDK Templates][1] | C# | `dotnet new` for Windows, macOS, Linux |
| [Yeoman Generator][2] | Javascript, TypeScript | Windows, macOS, Linux |
| [Visual Studio Extension][3] | C# | Visual Studio for Windows |

# Help Me Choose a Generator
## Help Me Choose a Generator

Which code generator to use largely depends on the development tools and programming language you use. The table below can help you decide:

| Language | Programming Editor | OS Support | Code Generator |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>Microsoft.BotFramework.CSharp.CoreBot</id>
<version>0.1.6</version>
<version>0.4.6</version>
<description>
A .NET Core Template for Microsoft Bot Framework v4. Will let you quickly set up a conversational AI bot with core features every bot is likely to have.
</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"defaultName": "CoreBot",
"groupIdentity": "Microsoft.BotFramework.CSharp.CoreBot",
"identity": "Microsoft.BotFramework.CSharp.CoreBot",
"name": "Bot Framework Core Bot (v0.1.6)",
"name": "Bot Framework Core Bot (v0.4.6)",
"preferNameDirectory": true,
"sourceName": "Microsoft.BotFramework.Samples",
"sourceName": "Microsoft.BotFramework.CoreBot",
"shortName": "corebot",
"tags": {
"language": "C#",
Expand All @@ -24,15 +24,20 @@
"type": "generated",
"generator": "constant",
"parameters": {
"value": "v0.1.6"
"value": "v0.4.6"
},
"replaces": "vX.X.X"
"replaces": "__vX.X.X__"
},
"output": {
"type": "parameter",
"replaces": "{OUTPUT_PATH}",
"defaultValue": "CoreBot"
},
"name": {
"type": "parameter",
"replaces": "__PROJECT_NAME__",
"defaultValue": "CoreBot"
},
"Framework": {
"type": "parameter",
"description": "The target framework for the project.",
Expand All @@ -45,10 +50,6 @@
{
"choice": "netcoreapp2.1",
"description": "Target netcoreapp2.1"
},
{
"choice": "netcoreapp2.0",
"description": "Target netcoreapp2.0"
}
],
"replaces": "__NETCOREAPP_VERSION__",
Expand All @@ -64,38 +65,30 @@
"cases": [
{
"condition": "(Framework==\"netcoreapp2.2\")",
"value": "\"Microsoft.AspNetCore\" Version=\"2.2.0\""
"value": "'Microsoft.AspNetCore' Version='2.2.0'"
},
{
"condition": "(Framework==\"netcoreapp2.1\")",
"value": "\"Microsoft.AspNetCore\" Version=\"2.1.6\""
},
{
"condition": "(Framework==\"netcoreapp2.0\")",
"value": "\"Microsoft.AspNetCore\" Version=\"2.0.4\""
"value": "'Microsoft.AspNetCore' Version='2.1.6'"
}
]
}
},
"AspCoreAllAssemblyVersion": {
"ReadmeNetCorePrereqVersion": {
"type":"generated",
"generator": "switch",
"dataType": "string",
"replaces": "__MICROSOFT_ASPNETCORE_ALL_VERSION__",
"replaces": "__NETCORE_VERSION__",
"parameters": {
"evaluator": "C++",
"cases": [
{
"condition": "(Framework==\"netcoreapp2.2\")",
"value": "\"Microsoft.AspNetCore.All\""
"value": "2.2"
},
{
"condition": "(Framework==\"netcoreapp2.1\")",
"value": "\"Microsoft.AspNetCore.All\""
},
{
"condition": "(Framework==\"netcoreapp2.0\")",
"value": "\"Microsoft.AspNetCore.All\" Version=\"2.0.9\""
"value": "2.1"
}
]
}
Expand All @@ -108,6 +101,13 @@
"isRequired": false
}
},
"sources": [
{
"modifiers": [
{"exclude": [ "**/NuGet.Config", "**/.DS_Store" ]}
]
}
],
"postActions": [
{
"condition": "(!SkipRestore)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/CoreBot.dll",
"program": "${workspaceFolder}/bin/Debug/netcoreapp__NETCORE_VERSION__/__PROJECT_NAME__.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
Expand Down Expand Up @@ -43,4 +43,4 @@
"processId": "${command:pickProcess}"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"type": "process",
"args": [
"build",
"${workspaceFolder}/CoreBot.csproj"
"${workspaceFolder}/__PROJECT_NAME__.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
}
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}");
}
}
};
}
}
}
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; }
}
}

This file was deleted.

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),
};
}
}
}

Loading

0 comments on commit 447028b

Please sign in to comment.