├── .gitattributes ├── .gitignore ├── BotDemos.sln ├── BotFramework3 ├── BugDialogBot │ ├── App_Start │ │ └── WebApiConfig.cs │ ├── BugDialogBot.csproj │ ├── BugReportDialog.cs │ ├── Controllers │ │ └── MessagesController.cs │ ├── Global.asax │ ├── Global.asax.cs │ ├── HelpScorable.cs │ ├── PlatformOptions.cs │ ├── ProductOptions.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── default.htm │ └── packages.config ├── BugFormFlowBot1 │ ├── App_Start │ │ └── WebApiConfig.cs │ ├── BugFormFlowBot1.csproj │ ├── BugReport.cs │ ├── Controllers │ │ └── MessagesController.cs │ ├── Global.asax │ ├── Global.asax.cs │ ├── PlatformOptions.cs │ ├── ProductOptions.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── default.htm │ └── packages.config ├── BugFormFlowBot2 │ ├── App_Start │ │ └── WebApiConfig.cs │ ├── BugFormFlowBot2.csproj │ ├── BugReport.cs │ ├── Controllers │ │ └── MessagesController.cs │ ├── Global.asax │ ├── Global.asax.cs │ ├── PlatformField.cs │ ├── PlatformOptions.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── default.htm │ └── packages.config ├── ContactInfoBot │ ├── App_Start │ │ └── WebApiConfig.cs │ ├── ContactInfoBot.csproj │ ├── ContactInfoDialog.cs │ ├── Controllers │ │ └── MessagesController.cs │ ├── Global.asax │ ├── Global.asax.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── PublishProfiles │ │ │ └── ContactInfoBot - Web Deploy.pubxml │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── default.htm │ └── packages.config ├── LUIS Models │ └── ContactInfo.json ├── LinqToTwitterFAQ │ ├── App_Start │ │ └── WebApiConfig.cs │ ├── Controllers │ │ └── MessagesController.cs │ ├── Dialogs │ │ ├── LinqToTwitterDialog.cs │ │ └── RootDialog.cs │ ├── Global.asax │ ├── Global.asax.cs │ ├── LinqToTwitterFAQ.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── default.htm │ └── packages.config ├── PCBot │ ├── App_Start │ │ └── WebApiConfig.cs │ ├── Controllers │ │ └── MessagesController.cs │ ├── Global.asax │ ├── Global.asax.cs │ ├── MessageHandler.cs │ ├── PCBot.csproj │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── PublishProfiles │ │ │ └── PCBot - Web Deploy.pubxml │ ├── UserInfo.cs │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── default.htm │ ├── images │ │ └── PCBot256x128.png │ └── packages.config ├── PigLatinBot │ ├── App_Start │ │ └── WebApiConfig.cs │ ├── Controllers │ │ ├── MessagesController.cs │ │ └── WebChatController.cs │ ├── Global.asax │ ├── Global.asax.cs │ ├── PigLatin.cs │ ├── PigLatinBot.csproj │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── PublishProfiles │ │ │ ├── PigLatinBotJoeMayo - Web Deploy (2).pubxml │ │ │ ├── PigLatinBotJoeMayo - Web Deploy.pubxml │ │ │ └── PigLatinJoeMayo - Web Deploy.pubxml │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── WebChatTokenResponse.cs │ ├── default.htm │ ├── images │ │ └── PigLatinBot.png │ └── packages.config └── Presentations │ ├── AzureBotService.pptx │ ├── BotFrameworkTactics.pptx │ └── IntroBotFramework.pptx ├── BotFramework4 ├── BugDialogBot │ ├── AdapterWithErrorHandler.cs │ ├── Bots │ │ └── MainBot.cs │ ├── BugDialogBot.csproj │ ├── Controllers │ │ └── BotController.cs │ ├── DeploymentTemplates │ │ ├── new-rg-parameters.json │ │ ├── preexisting-rg-parameters.json │ │ ├── template-with-new-rg.json │ │ └── template-with-preexisting-rg.json │ ├── Dialogs │ │ ├── MainDialog.cs │ │ └── ReportDialog.cs │ ├── Models │ │ ├── BugReport.cs │ │ ├── PlatformOptions.cs │ │ └── ProductOptions.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── README.md │ ├── Startup.cs │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ │ └── default.htm ├── ContactInfoBot │ ├── AdapterWithErrorHandler.cs │ ├── BookingDetails.cs │ ├── Bots │ │ ├── DialogAndWelcomeBot.cs │ │ ├── DialogBot.cs │ │ └── MainBot.cs │ ├── Cards │ │ └── welcomeCard.json │ ├── CognitiveModels │ │ ├── FlightBooking.cs │ │ ├── FlightBooking.json │ │ └── FlightBookingEx.cs │ ├── ContactInfoBot.csproj │ ├── Controllers │ │ └── BotController.cs │ ├── DeploymentTemplates │ │ ├── new-rg-parameters.json │ │ ├── preexisting-rg-parameters.json │ │ ├── template-with-new-rg.json │ │ └── template-with-preexisting-rg.json │ ├── Dialogs │ │ ├── BookingDialog.cs │ │ ├── CancelAndHelpDialog.cs │ │ ├── DateResolverDialog.cs │ │ └── MainDialog.cs │ ├── FlightBookingRecognizer.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── README.md │ ├── Startup.cs │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ │ └── default.htm └── PigLatinBot │ ├── AdapterWithErrorHandler.cs │ ├── Controllers │ └── BotController.cs │ ├── DeploymentTemplates │ ├── new-rg-parameters.json │ ├── preexisting-rg-parameters.json │ ├── template-with-new-rg.json │ └── template-with-preexisting-rg.json │ ├── IPigLatin.cs │ ├── MainBot.cs │ ├── PigLatin.cs │ ├── PigLatinBot.csproj │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── README.md │ ├── Startup.cs │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ └── default.htm └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | 85 | # Visual Studio profiler 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | *.sap 90 | 91 | # TFS 2012 Local Workspace 92 | $tf/ 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | *.DotSettings.user 101 | 102 | # JustCode is a .NET coding add-in 103 | .JustCode 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | _NCrunch_* 113 | .*crunch*.local.xml 114 | nCrunchTemp_* 115 | 116 | # MightyMoose 117 | *.mm.* 118 | AutoTest.Net/ 119 | 120 | # Web workbench (sass) 121 | .sass-cache/ 122 | 123 | # Installshield output folder 124 | [Ee]xpress/ 125 | 126 | # DocProject is a documentation generator add-in 127 | DocProject/buildhelp/ 128 | DocProject/Help/*.HxT 129 | DocProject/Help/*.HxC 130 | DocProject/Help/*.hhc 131 | DocProject/Help/*.hhk 132 | DocProject/Help/*.hhp 133 | DocProject/Help/Html2 134 | DocProject/Help/html 135 | 136 | # Click-Once directory 137 | publish/ 138 | 139 | # Publish Web Output 140 | *.[Pp]ublish.xml 141 | *.azurePubxml 142 | 143 | # TODO: Un-comment the next line if you do not want to checkin 144 | # your web deploy settings because they may include unencrypted 145 | # passwords 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # NuGet Packages 150 | *.nupkg 151 | # The packages folder can be ignored because of Package Restore 152 | **/packages/* 153 | # except build/, which is used as an MSBuild target. 154 | !**/packages/build/ 155 | # Uncomment if necessary however generally it will be regenerated when needed 156 | #!**/packages/repositories.config 157 | # NuGet v3's project.json files produces more ignoreable files 158 | *.nuget.props 159 | *.nuget.targets 160 | 161 | # Microsoft Azure Build Output 162 | csx/ 163 | *.build.csdef 164 | 165 | # Microsoft Azure Emulator 166 | ecf/ 167 | rcf/ 168 | 169 | # Microsoft Azure ApplicationInsights config file 170 | ApplicationInsights.config 171 | 172 | # Windows Store app package directory 173 | AppPackages/ 174 | BundleArtifacts/ 175 | 176 | # Visual Studio cache files 177 | # files ending in .cache can be ignored 178 | *.[Cc]ache 179 | # but keep track of directories ending in .cache 180 | !*.[Cc]ache/ 181 | 182 | # Others 183 | ClientBin/ 184 | [Ss]tyle[Cc]op.* 185 | ~$* 186 | *~ 187 | *.dbmdl 188 | *.dbproj.schemaview 189 | *.pfx 190 | *.publishsettings 191 | node_modules/ 192 | orleans.codegen.cs 193 | 194 | # RIA/Silverlight projects 195 | Generated_Code/ 196 | 197 | # Backup & report files from converting an old project file 198 | # to a newer Visual Studio version. Backup files are not needed, 199 | # because we have git ;-) 200 | _UpgradeReport_Files/ 201 | Backup*/ 202 | UpgradeLog*.XML 203 | UpgradeLog*.htm 204 | 205 | # SQL Server files 206 | *.mdf 207 | *.ldf 208 | 209 | # Business Intelligence projects 210 | *.rdl.data 211 | *.bim.layout 212 | *.bim_*.settings 213 | 214 | # Microsoft Fakes 215 | FakesAssemblies/ 216 | 217 | # GhostDoc plugin setting file 218 | *.GhostDoc.xml 219 | 220 | # Node.js Tools for Visual Studio 221 | .ntvs_analysis.dat 222 | 223 | # Visual Studio 6 build log 224 | *.plg 225 | 226 | # Visual Studio 6 workspace options file 227 | *.opt 228 | 229 | # Visual Studio LightSwitch build output 230 | **/*.HTMLClient/GeneratedArtifacts 231 | **/*.DesktopClient/GeneratedArtifacts 232 | **/*.DesktopClient/ModelManifest.xml 233 | **/*.Server/GeneratedArtifacts 234 | **/*.Server/ModelManifest.xml 235 | _Pvt_Extensions 236 | 237 | # LightSwitch generated files 238 | GeneratedArtifacts/ 239 | ModelManifest.xml 240 | 241 | # Paket dependency manager 242 | .paket/paket.exe 243 | 244 | # FAKE - F# Make 245 | .fake/ -------------------------------------------------------------------------------- /BotFramework3/BugDialogBot/App_Start/WebApiConfig.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Serialization; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Web.Http; 7 | 8 | namespace BugDialogBot 9 | { 10 | public static class WebApiConfig 11 | { 12 | public static void Register(HttpConfiguration config) 13 | { 14 | // Json settings 15 | config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; 16 | config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); 17 | config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented; 18 | JsonConvert.DefaultSettings = () => new JsonSerializerSettings() 19 | { 20 | ContractResolver = new CamelCasePropertyNamesContractResolver(), 21 | Formatting = Newtonsoft.Json.Formatting.Indented, 22 | NullValueHandling = NullValueHandling.Ignore, 23 | }; 24 | 25 | // Web API configuration and services 26 | 27 | // Web API routes 28 | config.MapHttpAttributeRoutes(); 29 | 30 | config.Routes.MapHttpRoute( 31 | name: "DefaultApi", 32 | routeTemplate: "api/{controller}/{id}", 33 | defaults: new { id = RouteParameter.Optional } 34 | ); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /BotFramework3/BugDialogBot/BugReportDialog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | using Microsoft.Bot.Builder.Dialogs; 5 | using Microsoft.Bot.Connector; 6 | 7 | namespace BugDialogBot 8 | { 9 | [Serializable] 10 | class BugReportDialog : IDialog 11 | { 12 | ProductOptions productOptions; 13 | PlatformOptions platformOptions; 14 | string description; 15 | 16 | public Task StartAsync(IDialogContext context) 17 | { 18 | context.Wait(ConversationStartedAsync); 19 | return Task.CompletedTask; 20 | } 21 | 22 | public async Task ConversationStartedAsync(IDialogContext context, IAwaitable argument) 23 | { 24 | IMessageActivity activity = await argument; 25 | await context.PostAsync(activity.Text); 26 | 27 | PromptDialog.Choice( 28 | context: context, 29 | resume: ResumeAndPromptPlatformAsync, 30 | options: Enum.GetValues(typeof(ProductOptions)).Cast().ToArray(), 31 | prompt: "Welcome to the Bug Report Bot! Please select the product you're having a problem with (SQLServer or VisualStudio):", 32 | retry: "I didn't understand. Please try again."); 33 | } 34 | 35 | public async Task ResumeAndPromptPlatformAsync(IDialogContext context, IAwaitable argument) 36 | { 37 | productOptions = await argument; 38 | 39 | PromptDialog.Choice( 40 | context: context, 41 | resume: ResumeAndPromptDescriptionAsync, 42 | options: Enum.GetValues(typeof(PlatformOptions)).Cast().ToArray(), 43 | prompt: "Which platform did the problem occur on? (Linux, Mac, or Windows):", 44 | retry: "I didn't understand. Please try again."); 45 | } 46 | 47 | public async Task ResumeAndPromptDescriptionAsync(IDialogContext context, IAwaitable argument) 48 | { 49 | platformOptions = await argument; 50 | 51 | PromptDialog.Text( 52 | context: context, 53 | resume: ResumeAndPromptSummaryAsync, 54 | prompt: "Please provide a detailed description of the problem:", 55 | retry: "I didn't understand. Please try again."); 56 | } 57 | 58 | public async Task ResumeAndPromptSummaryAsync(IDialogContext context, IAwaitable argument) 59 | { 60 | description = await argument; 61 | 62 | PromptDialog.Confirm( 63 | context: context, 64 | resume: ResumeAndHandleConfirmAsync, 65 | prompt: $"You entered '{productOptions}', '{platformOptions}', and '{description}'. Is that correct?", 66 | retry: "I didn't understand. Please try again."); 67 | } 68 | 69 | public async Task ResumeAndHandleConfirmAsync(IDialogContext context, IAwaitable argument) 70 | { 71 | bool choicesAreCorrect = await argument; 72 | 73 | if (choicesAreCorrect) 74 | await context.PostAsync("Your bug report has been submitted. Thanks for the feedback!"); 75 | else 76 | await context.PostAsync("I see. You're welcome to try again."); 77 | 78 | context.Wait(ConversationStartedAsync); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /BotFramework3/BugDialogBot/Controllers/MessagesController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | using System.Web.Http; 5 | using Microsoft.Bot.Builder.Dialogs; 6 | using Microsoft.Bot.Connector; 7 | using System.Net.Http; 8 | using System.Net; 9 | 10 | namespace BugDialogBot 11 | { 12 | [BotAuthentication] 13 | public class MessagesController : ApiController 14 | { 15 | /// 16 | /// POST: api/Messages 17 | /// Receive a message from a user and reply to it 18 | /// 19 | public async Task Post([FromBody]Activity activity) 20 | { 21 | if (activity?.Type == ActivityTypes.Message) 22 | await Conversation.SendAsync(activity, () => new BugReportDialog()); 23 | 24 | return Request.CreateResponse(HttpStatusCode.OK); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /BotFramework3/BugDialogBot/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="BugDialogBot.WebApiApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /BotFramework3/BugDialogBot/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using Autofac; 2 | using Microsoft.Bot.Builder.Dialogs; 3 | using Microsoft.Bot.Connector; 4 | using System.Web.Http; 5 | using Microsoft.Bot.Builder.Scorables; 6 | 7 | namespace BugDialogBot 8 | { 9 | public class WebApiApplication : System.Web.HttpApplication 10 | { 11 | protected void Application_Start() 12 | { 13 | GlobalConfiguration.Configure(WebApiConfig.Register); 14 | 15 | RegisterScorables(); 16 | } 17 | 18 | void RegisterScorables() 19 | { 20 | Conversation.UpdateContainer(builder => 21 | { 22 | builder.RegisterType() 23 | .As>() 24 | .InstancePerLifetimeScope(); 25 | }); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BotFramework3/BugDialogBot/HelpScorable.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Bot.Connector; 2 | using System.Text.RegularExpressions; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Microsoft.Bot.Builder.Dialogs; 6 | using Microsoft.Bot.Builder.Dialogs.Internals; 7 | using Microsoft.Bot.Builder.Scorables.Internals; 8 | 9 | namespace BugDialogBot 10 | { 11 | public class HelpScorable : ScorableBase 12 | { 13 | readonly IBotToUser botToUser; 14 | 15 | public HelpScorable(IBotToUser botToUser) 16 | { 17 | this.botToUser = botToUser; 18 | } 19 | 20 | protected override async Task PrepareAsync(IActivity activity, CancellationToken token) 21 | { 22 | var text = (activity as IMessageActivity)?.Text ?? ""; 23 | var regex = new Regex("/help", RegexOptions.IgnoreCase); 24 | var match = regex.Match(text); 25 | 26 | return match.Success ? match.Groups[0].Value : null; 27 | } 28 | 29 | protected override bool HasScore(IActivity item, string state) 30 | { 31 | return state != null; 32 | } 33 | 34 | protected override double GetScore(IActivity item, string state) 35 | { 36 | return 1.0; 37 | } 38 | 39 | protected override async Task PostAsync(IActivity item, string state, CancellationToken token) 40 | { 41 | await botToUser.PostAsync("Help is on the way!", cancellationToken: token); 42 | } 43 | 44 | protected override Task DoneAsync(IActivity item, string state, CancellationToken token) 45 | { 46 | return Task.CompletedTask; 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /BotFramework3/BugDialogBot/PlatformOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace BugDialogBot 5 | { 6 | public enum PlatformOptions 7 | { 8 | Linux, 9 | Mac, 10 | Windows 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /BotFramework3/BugDialogBot/ProductOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace BugDialogBot 5 | { 6 | public enum ProductOptions 7 | { 8 | Office, 9 | SQLServer, 10 | VisualStudio 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /BotFramework3/BugDialogBot/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("BugDialogBot")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("BugDialogBot")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a8ba1066-5695-4d71-abb4-65e5a5e0c3d4")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /BotFramework3/BugDialogBot/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /BotFramework3/BugDialogBot/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /BotFramework3/BugDialogBot/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /BotFramework3/BugDialogBot/default.htm: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 |

BugDialogBot

9 |

Describe your bot here and your terms of use etc.

10 |

Visit Bot Framework to register your bot. When you register it, remember to set your bot's endpoint to

https://your_bots_hostname/api/messages

11 | 12 | 13 | -------------------------------------------------------------------------------- /BotFramework3/BugDialogBot/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot1/App_Start/WebApiConfig.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Serialization; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Web.Http; 7 | 8 | namespace BugFormFlowBot1 9 | { 10 | public static class WebApiConfig 11 | { 12 | public static void Register(HttpConfiguration config) 13 | { 14 | // Json settings 15 | config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; 16 | config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); 17 | config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented; 18 | JsonConvert.DefaultSettings = () => new JsonSerializerSettings() 19 | { 20 | ContractResolver = new CamelCasePropertyNamesContractResolver(), 21 | Formatting = Newtonsoft.Json.Formatting.Indented, 22 | NullValueHandling = NullValueHandling.Ignore, 23 | }; 24 | 25 | // Web API configuration and services 26 | 27 | // Web API routes 28 | config.MapHttpAttributeRoutes(); 29 | 30 | config.Routes.MapHttpRoute( 31 | name: "DefaultApi", 32 | routeTemplate: "api/{controller}/{id}", 33 | defaults: new { id = RouteParameter.Optional } 34 | ); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot1/BugReport.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Microsoft.Bot.Builder.FormFlow; 4 | using Microsoft.Bot.Builder.Dialogs; 5 | 6 | namespace BugFormFlowBot1 7 | { 8 | [Serializable] 9 | public class BugReport 10 | { 11 | public ProductOptions Product { get; set; } 12 | 13 | public List Platform { get; set; } 14 | 15 | public string ProblemDescription { get; set; } 16 | 17 | public static IForm BuildForm() 18 | { 19 | return new FormBuilder() 20 | .Message("Welcome to Bug Report bot!") 21 | .OnCompletion(async (context, bugReport) => 22 | { 23 | await context.PostAsync("Thanks for the report!"); 24 | }) 25 | .Build(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot1/Controllers/MessagesController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | using System.Web.Http; 5 | using Microsoft.Bot.Builder.Dialogs; 6 | using Microsoft.Bot.Builder.FormFlow; 7 | using Microsoft.Bot.Connector; 8 | using System.Net.Http; 9 | using System.Net; 10 | 11 | namespace BugFormFlowBot1 12 | { 13 | [BotAuthentication] 14 | public class MessagesController : ApiController 15 | { 16 | internal static IDialog MakeRootDialog() 17 | { 18 | return Chain.From(() => FormDialog.FromForm(BugReport.BuildForm)) 19 | .Loop(); 20 | } 21 | 22 | /// 23 | /// POST: api/Messages 24 | /// Receive a message from a user and reply to it 25 | /// 26 | public async Task Post([FromBody]Activity activity) 27 | { 28 | if (activity?.Type == ActivityTypes.Message) 29 | await Conversation.SendAsync(activity, MakeRootDialog); 30 | 31 | return Request.CreateResponse(HttpStatusCode.OK); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot1/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="BugFormFlowBot1.WebApiApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot1/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Http; 6 | using System.Web.Routing; 7 | 8 | namespace BugFormFlowBot1 9 | { 10 | public class WebApiApplication : System.Web.HttpApplication 11 | { 12 | protected void Application_Start() 13 | { 14 | GlobalConfiguration.Configure(WebApiConfig.Register); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot1/PlatformOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace BugFormFlowBot1 5 | { 6 | public enum PlatformOptions 7 | { 8 | Linux = 1, 9 | Mac, 10 | Windows 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot1/ProductOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace BugFormFlowBot1 5 | { 6 | public enum ProductOptions 7 | { 8 | Office = 1, 9 | SQLServer, 10 | VisualStudio 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot1/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("BugFormFlowBot1")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("BugFormFlowBot1")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a8ba1066-5695-4d71-abb4-65e5a5e0c3d4")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot1/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot1/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot1/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot1/default.htm: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 |

BugFormFlowBot1

9 |

Describe your bot here and your terms of use etc.

10 |

Visit Bot Framework to register your bot. When you register it, remember to set your bot's endpoint to

https://your_bots_hostname/api/messages

11 | 12 | 13 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot1/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot2/App_Start/WebApiConfig.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Serialization; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Web.Http; 7 | 8 | namespace BugFormFlowBot2 9 | { 10 | public static class WebApiConfig 11 | { 12 | public static void Register(HttpConfiguration config) 13 | { 14 | // Json settings 15 | config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; 16 | config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); 17 | config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented; 18 | JsonConvert.DefaultSettings = () => new JsonSerializerSettings() 19 | { 20 | ContractResolver = new CamelCasePropertyNamesContractResolver(), 21 | Formatting = Newtonsoft.Json.Formatting.Indented, 22 | NullValueHandling = NullValueHandling.Ignore, 23 | }; 24 | 25 | // Web API configuration and services 26 | 27 | // Web API routes 28 | config.MapHttpAttributeRoutes(); 29 | 30 | config.Routes.MapHttpRoute( 31 | name: "DefaultApi", 32 | routeTemplate: "api/{controller}/{id}", 33 | defaults: new { id = RouteParameter.Optional } 34 | ); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot2/BugReport.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Microsoft.Bot.Builder.FormFlow; 4 | using Microsoft.Bot.Builder.Dialogs; 5 | using Microsoft.Bot.Builder.FormFlow.Advanced; 6 | using System.Threading.Tasks; 7 | 8 | namespace BugFormFlowBot2 9 | { 10 | [Serializable] 11 | [Template(TemplateUsage.EnumSelectOne, "Which {&} were you working with? {||}")] 12 | [Template(TemplateUsage.EnumSelectMany, "Which {&} were you working with? {||}", ChoiceStyle = ChoiceStyleOptions.PerLine)] 13 | public class BugReport 14 | { 15 | public string Product { get; set; } 16 | 17 | public string Version { get; set; } 18 | 19 | public List Platform { get; set; } 20 | 21 | [Prompt("What is the {&}")] 22 | [Describe("Description of the Problem")] 23 | public string ProblemDescription { get; set; } 24 | 25 | [Numeric(1, 3)] 26 | public int Priority { get; set; } 27 | 28 | private static int versionAttempts = 0; 29 | 30 | public static IForm BuildForm() 31 | { 32 | return new FormBuilder() 33 | .Message("Welcome to Bug Report bot!") 34 | .Field(new FieldReflector(nameof(Product)) 35 | .SetType(null) 36 | .SetDefine((state, field) => 37 | { 38 | foreach (var prod in GetProducts()) 39 | field 40 | .AddDescription(prod, prod) 41 | .AddTerms(prod, prod); 42 | 43 | return Task.FromResult(true); 44 | })) 45 | .Field(nameof(Version), 46 | validate: async (state, response) => 47 | { 48 | var result = new ValidateResult { IsValid = true, Value = response }; 49 | 50 | foreach (var segment in (response as string ?? "").Split('.')) 51 | { 52 | int digit; 53 | if (!int.TryParse(segment, out digit)) 54 | { 55 | result.Feedback = 56 | "Version number must be numeric segments, optionally separated by dots. e.g. 7.2, 10, or 3.56"; 57 | result.IsValid = false; 58 | 59 | if (++versionAttempts > 2) 60 | throw new TooManyAttemptsException("Too many attempts at the version number."); 61 | 62 | break; 63 | } 64 | } 65 | 66 | return await Task.FromResult(result); 67 | }) 68 | .Field(nameof(Platform)) 69 | .AddRemainingFields() 70 | .Confirm(async (bugReport) => 71 | { 72 | var response = new PromptAttribute( 73 | $"You entered {bugReport.Product}, {bugReport.Version}, {string.Join(", ", bugReport.Platform)}" + 74 | $"{bugReport.ProblemDescription}, {bugReport.Priority}. Is this Correct?"); 75 | return await Task.FromResult(response); 76 | }) 77 | .OnCompletion(async (context, bugReport) => 78 | { 79 | await context.PostAsync("Thanks for the report!"); 80 | }) 81 | .Build(); 82 | } 83 | 84 | static List GetProducts() 85 | { 86 | return new List 87 | { 88 | "Office", 89 | "SQL Server", 90 | "Visual Studio" 91 | }; 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot2/Controllers/MessagesController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using System.Web.Http; 4 | using Microsoft.Bot.Connector; 5 | using Microsoft.Bot.Builder.Dialogs; 6 | using Microsoft.Bot.Builder.FormFlow; 7 | using System.Net.Http; 8 | using System.Net; 9 | 10 | namespace BugFormFlowBot2 11 | { 12 | [BotAuthentication] 13 | public class MessagesController : ApiController 14 | { 15 | internal static IDialog MakeRootDialog() 16 | { 17 | return Chain.From(() => FormDialog.FromForm(BugReport.BuildForm)) 18 | .Loop(); 19 | } 20 | 21 | public async Task Post([FromBody]Activity activity) 22 | { 23 | if (activity?.Type == ActivityTypes.Message) 24 | try 25 | { 26 | await Conversation.SendAsync(activity, MakeRootDialog); 27 | } 28 | catch (FormCanceledException fcEx) when(fcEx.InnerException is TooManyAttemptsException) 29 | { 30 | ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl)); 31 | 32 | Activity reply = activity.CreateReply( 33 | $"Too Many Attempts at {fcEx.Last}. " + 34 | $"Completed Steps: {string.Join(", ", fcEx.Completed)}"); 35 | 36 | await connector.Conversations.ReplyToActivityAsync(reply); 37 | } 38 | catch (FormCanceledException fcEx) 39 | { 40 | ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl)); 41 | 42 | Activity reply = activity.CreateReply( 43 | $"Form cancelled at {fcEx.Last}. " + 44 | $"Completed Steps: {string.Join(", ", fcEx.Completed)}"); 45 | 46 | await connector.Conversations.ReplyToActivityAsync(reply); 47 | } 48 | 49 | return Request.CreateResponse(HttpStatusCode.OK); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot2/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="BugFormFlowBot2.WebApiApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot2/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Http; 6 | using System.Web.Routing; 7 | 8 | namespace BugFormFlowBot2 9 | { 10 | public class WebApiApplication : System.Web.HttpApplication 11 | { 12 | protected void Application_Start() 13 | { 14 | GlobalConfiguration.Configure(WebApiConfig.Register); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot2/PlatformField.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using Microsoft.Bot.Builder.FormFlow.Advanced; 6 | 7 | namespace BugFormFlowBot2 8 | { 9 | public class PlatformField : Field 10 | { 11 | public PlatformField(string name, FieldRole role) : base(name, role) 12 | { 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot2/PlatformOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace BugFormFlowBot2 5 | { 6 | public enum PlatformOptions 7 | { 8 | Linux = 1, 9 | Mac, 10 | Windows 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot2/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("BugFormFlowBot2")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("BugFormFlowBot2")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a8ba1066-5695-4d71-abb4-65e5a5e0c3d4")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot2/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot2/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot2/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot2/default.htm: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 |

BugFormFlowBot2

9 |

Describe your bot here and your terms of use etc.

10 |

Visit Bot Framework to register your bot. When you register it, remember to set your bot's endpoint to

https://your_bots_hostname/api/messages

11 | 12 | 13 | -------------------------------------------------------------------------------- /BotFramework3/BugFormFlowBot2/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /BotFramework3/ContactInfoBot/App_Start/WebApiConfig.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Serialization; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Web.Http; 7 | 8 | namespace ContactInfoBot 9 | { 10 | public static class WebApiConfig 11 | { 12 | public static void Register(HttpConfiguration config) 13 | { 14 | // Json settings 15 | config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; 16 | config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); 17 | config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented; 18 | JsonConvert.DefaultSettings = () => new JsonSerializerSettings() 19 | { 20 | ContractResolver = new CamelCasePropertyNamesContractResolver(), 21 | Formatting = Newtonsoft.Json.Formatting.Indented, 22 | NullValueHandling = NullValueHandling.Ignore, 23 | }; 24 | 25 | // Web API configuration and services 26 | 27 | // Web API routes 28 | config.MapHttpAttributeRoutes(); 29 | 30 | config.Routes.MapHttpRoute( 31 | name: "DefaultApi", 32 | routeTemplate: "api/{controller}/{id}", 33 | defaults: new { id = RouteParameter.Optional } 34 | ); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /BotFramework3/ContactInfoBot/ContactInfoDialog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Microsoft.Bot.Builder.Dialogs; 4 | using Microsoft.Bot.Builder.Luis; 5 | using Microsoft.Bot.Builder.Luis.Models; 6 | 7 | namespace ContactInfoBot 8 | { 9 | [LuisModel("", "")] 10 | [Serializable] 11 | public class ContactInfoDialog : LuisDialog 12 | { 13 | public const string ContactType = "ContactType"; 14 | string currentEntity = ""; 15 | 16 | [LuisIntent("")] 17 | public async Task None(IDialogContext context, LuisResult result) 18 | { 19 | string userUtterance = result.Query; 20 | await context.PostAsync($"Sorry, I didn't understand \"{userUtterance}\"."); 21 | context.Wait(MessageReceived); 22 | } 23 | 24 | [LuisIntent("ChangeInfo")] 25 | public async Task ChangeInfo(IDialogContext context, LuisResult result) 26 | { 27 | EntityRecommendation entityRec; 28 | result.TryFindEntity(ContactType, out entityRec); 29 | 30 | currentEntity = entityRec.Entity; 31 | 32 | PromptDialog.Text( 33 | context: context, 34 | resume: ResumeAndHandleTextAsync, 35 | prompt: $"What would you like to change your {currentEntity} to?", 36 | retry: "I didn't understand. Please try again."); 37 | } 38 | 39 | public async Task ResumeAndHandleTextAsync(IDialogContext context, IAwaitable argument) 40 | { 41 | string newEntityValue = await argument; 42 | 43 | await context.PostAsync($"Your {currentEntity} is now {newEntityValue}"); 44 | 45 | context.Wait(MessageReceived); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /BotFramework3/ContactInfoBot/Controllers/MessagesController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Net; 4 | using System.Net.Http; 5 | using System.Threading.Tasks; 6 | using System.Web.Http; 7 | using Microsoft.Bot.Builder.Dialogs; 8 | using Microsoft.Bot.Connector; 9 | using System.Configuration; 10 | using System.Web.Http.Description; 11 | 12 | namespace ContactInfoBot 13 | { 14 | [BotAuthentication] 15 | public class MessagesController : ApiController 16 | { 17 | /// 18 | /// POST: api/Messages 19 | /// Receive a message from a user and reply to it 20 | /// 21 | [ResponseType(typeof(void))] 22 | public async Task Post([FromBody]Activity activity) 23 | { 24 | if (activity?.Type == ActivityTypes.Message) 25 | await Conversation.SendAsync(activity, () => new ContactInfoDialog()); 26 | 27 | return new HttpResponseMessage(HttpStatusCode.Accepted); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /BotFramework3/ContactInfoBot/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="ContactInfoBot.WebApiApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /BotFramework3/ContactInfoBot/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Http; 6 | using System.Web.Routing; 7 | 8 | namespace ContactInfoBot 9 | { 10 | public class WebApiApplication : System.Web.HttpApplication 11 | { 12 | protected void Application_Start() 13 | { 14 | GlobalConfiguration.Configure(WebApiConfig.Register); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /BotFramework3/ContactInfoBot/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ContactInfoBot")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ContactInfoBot")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a8ba1066-5695-4d71-abb4-65e5a5e0c3d4")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /BotFramework3/ContactInfoBot/Properties/PublishProfiles/ContactInfoBot - Web Deploy.pubxml: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | MSDeploy 9 | AzureWebSite 10 | Release 11 | Any CPU 12 | http://contactinfobot.azurewebsites.net 13 | True 14 | False 15 | contactinfobot.scm.azurewebsites.net:443 16 | ContactInfoBot 17 | 18 | True 19 | WMSVC 20 | True 21 | $ContactInfoBot 22 | <_SavePWD>True 23 | <_DestinationType>AzureWebSite 24 | False 25 | 26 | -------------------------------------------------------------------------------- /BotFramework3/ContactInfoBot/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /BotFramework3/ContactInfoBot/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /BotFramework3/ContactInfoBot/default.htm: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 |

ContactInfoBot

9 |

Describe your bot here and your terms of use etc.

10 |

Visit Bot Framework to register your bot. When you register it, remember to set your bot's endpoint to

https://your_bots_hostname/api/messages

11 | 12 | 13 | -------------------------------------------------------------------------------- /BotFramework3/ContactInfoBot/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /BotFramework3/LinqToTwitterFAQ/App_Start/WebApiConfig.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Serialization; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Web.Http; 7 | 8 | namespace LinqToTwitterFAQ 9 | { 10 | public static class WebApiConfig 11 | { 12 | public static void Register(HttpConfiguration config) 13 | { 14 | // Json settings 15 | config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; 16 | config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); 17 | config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented; 18 | JsonConvert.DefaultSettings = () => new JsonSerializerSettings() 19 | { 20 | ContractResolver = new CamelCasePropertyNamesContractResolver(), 21 | Formatting = Newtonsoft.Json.Formatting.Indented, 22 | NullValueHandling = NullValueHandling.Ignore, 23 | }; 24 | 25 | // Web API configuration and services 26 | 27 | // Web API routes 28 | config.MapHttpAttributeRoutes(); 29 | 30 | config.Routes.MapHttpRoute( 31 | name: "DefaultApi", 32 | routeTemplate: "api/{controller}/{id}", 33 | defaults: new { id = RouteParameter.Optional } 34 | ); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /BotFramework3/LinqToTwitterFAQ/Controllers/MessagesController.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | using System.Net.Http; 3 | using System.Threading.Tasks; 4 | using System.Web.Http; 5 | using Microsoft.Bot.Builder.Dialogs; 6 | using Microsoft.Bot.Connector; 7 | 8 | namespace LinqToTwitterFAQ 9 | { 10 | [BotAuthentication] 11 | public class MessagesController : ApiController 12 | { 13 | /// 14 | /// POST: api/Messages 15 | /// Receive a message from a user and reply to it 16 | /// 17 | public async Task Post([FromBody]Activity activity) 18 | { 19 | if (activity.Type == ActivityTypes.Message) 20 | { 21 | await Conversation.SendAsync(activity, () => new Dialogs.LinqToTwitterDialog()); 22 | } 23 | else 24 | { 25 | HandleSystemMessage(activity); 26 | } 27 | var response = Request.CreateResponse(HttpStatusCode.OK); 28 | return response; 29 | } 30 | 31 | private Activity HandleSystemMessage(Activity message) 32 | { 33 | if (message.Type == ActivityTypes.DeleteUserData) 34 | { 35 | // Implement user deletion here 36 | // If we handle user deletion, return a real message 37 | } 38 | else if (message.Type == ActivityTypes.ConversationUpdate) 39 | { 40 | // Handle conversation state changes, like members being added and removed 41 | // Use Activity.MembersAdded and Activity.MembersRemoved and Activity.Action for info 42 | // Not available in all channels 43 | } 44 | else if (message.Type == ActivityTypes.ContactRelationUpdate) 45 | { 46 | // Handle add/remove from contact lists 47 | // Activity.From + Activity.Action represent what happened 48 | } 49 | else if (message.Type == ActivityTypes.Typing) 50 | { 51 | // Handle knowing tha the user is typing 52 | } 53 | else if (message.Type == ActivityTypes.Ping) 54 | { 55 | } 56 | 57 | return null; 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /BotFramework3/LinqToTwitterFAQ/Dialogs/LinqToTwitterDialog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Bot.Builder.CognitiveServices.QnAMaker; 3 | 4 | namespace LinqToTwitterFAQ.Dialogs 5 | { 6 | [Serializable] 7 | [QnAMaker( 8 | subscriptionKey: "", 9 | knowledgebaseId: "")] 10 | public class LinqToTwitterDialog : QnAMakerDialog 11 | { 12 | } 13 | } -------------------------------------------------------------------------------- /BotFramework3/LinqToTwitterFAQ/Dialogs/RootDialog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Microsoft.Bot.Builder.Dialogs; 4 | using Microsoft.Bot.Connector; 5 | 6 | namespace LinqToTwitterFAQ.Dialogs 7 | { 8 | [Serializable] 9 | public class RootDialog : IDialog 10 | { 11 | public Task StartAsync(IDialogContext context) 12 | { 13 | context.Wait(MessageReceivedAsync); 14 | 15 | return Task.CompletedTask; 16 | } 17 | 18 | private async Task MessageReceivedAsync(IDialogContext context, IAwaitable result) 19 | { 20 | var activity = await result as Activity; 21 | 22 | // calculate something for us to return 23 | int length = (activity.Text ?? string.Empty).Length; 24 | 25 | // return our reply to the user 26 | await context.PostAsync($"You sent {activity.Text} which was {length} characters"); 27 | 28 | context.Wait(MessageReceivedAsync); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /BotFramework3/LinqToTwitterFAQ/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="LinqToTwitterFAQ.WebApiApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /BotFramework3/LinqToTwitterFAQ/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Http; 6 | using System.Web.Routing; 7 | 8 | namespace LinqToTwitterFAQ 9 | { 10 | public class WebApiApplication : System.Web.HttpApplication 11 | { 12 | protected void Application_Start() 13 | { 14 | GlobalConfiguration.Configure(WebApiConfig.Register); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /BotFramework3/LinqToTwitterFAQ/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("LinqToTwitterFAQ")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("LinqToTwitterFAQ")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("7da2343b-3ce2-4c7f-b1e0-f7a7b8e35b8e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /BotFramework3/LinqToTwitterFAQ/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /BotFramework3/LinqToTwitterFAQ/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /BotFramework3/LinqToTwitterFAQ/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /BotFramework3/LinqToTwitterFAQ/default.htm: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 |

LinqToTwitterFAQ

9 |

Describe your bot here and your terms of use etc.

10 |

Visit Bot Framework to register your bot. When you register it, remember to set your bot's endpoint to

https://your_bots_hostname/api/messages

11 | 12 | 13 | -------------------------------------------------------------------------------- /BotFramework3/LinqToTwitterFAQ/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /BotFramework3/PCBot/App_Start/WebApiConfig.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Serialization; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Web.Http; 7 | 8 | namespace PCBot 9 | { 10 | public static class WebApiConfig 11 | { 12 | public static void Register(HttpConfiguration config) 13 | { 14 | // Json settings 15 | config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; 16 | config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); 17 | config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented; 18 | JsonConvert.DefaultSettings = () => new JsonSerializerSettings() 19 | { 20 | ContractResolver = new CamelCasePropertyNamesContractResolver(), 21 | Formatting = Newtonsoft.Json.Formatting.Indented, 22 | NullValueHandling = NullValueHandling.Ignore, 23 | }; 24 | 25 | // Web API configuration and services 26 | 27 | // Web API routes 28 | config.MapHttpAttributeRoutes(); 29 | 30 | config.Routes.MapHttpRoute( 31 | name: "DefaultApi", 32 | routeTemplate: "api/{controller}/{id}", 33 | defaults: new { id = RouteParameter.Optional } 34 | ); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /BotFramework3/PCBot/Controllers/MessagesController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Net.Http; 4 | using System.Threading.Tasks; 5 | using System.Web.Http; 6 | using Microsoft.Bot.Connector; 7 | 8 | namespace PCBot 9 | { 10 | [BotAuthentication] 11 | public class MessagesController : ApiController 12 | { 13 | public async Task Post([FromBody]Activity activity) 14 | { 15 | var connector = new ConnectorClient(new Uri(activity.ServiceUrl)); 16 | 17 | Activity reply = await new MessageHandler().ReactAsync(activity); 18 | 19 | if (reply != null) 20 | await connector.Conversations.ReplyToActivityAsync(reply); 21 | 22 | return Request.CreateResponse(HttpStatusCode.OK); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /BotFramework3/PCBot/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="PCBot.WebApiApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /BotFramework3/PCBot/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Http; 6 | using System.Web.Routing; 7 | 8 | namespace PCBot 9 | { 10 | public class WebApiApplication : System.Web.HttpApplication 11 | { 12 | protected void Application_Start() 13 | { 14 | GlobalConfiguration.Configure(WebApiConfig.Register); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /BotFramework3/PCBot/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("PCBot")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("PCBot")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a8ba1066-5695-4d71-abb4-65e5a5e0c3d4")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /BotFramework3/PCBot/Properties/PublishProfiles/PCBot - Web Deploy.pubxml: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | MSDeploy 9 | False 10 | AzureWebSite 11 | Release 12 | Any CPU 13 | http://pcbot.azurewebsites.net 14 | True 15 | False 16 | pcbot.scm.azurewebsites.net:443 17 | PCBot 18 | 19 | True 20 | WMSVC 21 | True 22 | $PCBot 23 | <_SavePWD>True 24 | <_DestinationType>AzureWebSite 25 | 26 | -------------------------------------------------------------------------------- /BotFramework3/PCBot/UserInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PCBot 4 | { 5 | [Serializable] 6 | public class UserInfo 7 | { 8 | public string UserName { get; set; } 9 | public DateTime Joined { get; set; } 10 | public DateTime LastVisit { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /BotFramework3/PCBot/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /BotFramework3/PCBot/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /BotFramework3/PCBot/default.htm: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | PC Bot 5 | 6 | 7 | 8 |

PC Bot

9 | PC Bot 10 |

This bot is Politically Correct (PC) - it reacts to everything. It echoes messages and acknowledges occurrence of other events.

11 |

Note: It will not overreact; as you would expect of proper botiquette.

12 | 13 | 14 | -------------------------------------------------------------------------------- /BotFramework3/PCBot/images/PCBot256x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoeMayo/BotDemos/0b4d93da17d743cfe58564174ed8ec1fc7a56529/BotFramework3/PCBot/images/PCBot256x128.png -------------------------------------------------------------------------------- /BotFramework3/PCBot/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /BotFramework3/PigLatinBot/App_Start/WebApiConfig.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Serialization; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Web.Http; 7 | 8 | namespace PigLatinBot 9 | { 10 | public static class WebApiConfig 11 | { 12 | public static void Register(HttpConfiguration config) 13 | { 14 | // Json settings 15 | config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; 16 | config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); 17 | config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented; 18 | JsonConvert.DefaultSettings = () => new JsonSerializerSettings() 19 | { 20 | ContractResolver = new CamelCasePropertyNamesContractResolver(), 21 | Formatting = Newtonsoft.Json.Formatting.Indented, 22 | NullValueHandling = NullValueHandling.Ignore, 23 | }; 24 | 25 | // Web API configuration and services 26 | 27 | // Web API routes 28 | config.MapHttpAttributeRoutes(); 29 | 30 | config.Routes.MapHttpRoute( 31 | name: "DefaultApi", 32 | routeTemplate: "api/{controller}/{id}", 33 | defaults: new { id = RouteParameter.Optional } 34 | ); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /BotFramework3/PigLatinBot/Controllers/MessagesController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | using System.Web.Http; 5 | using Microsoft.Bot.Connector; 6 | using System.Net.Http; 7 | using System.Net; 8 | 9 | namespace PigLatinBot 10 | { 11 | [BotAuthentication] 12 | public class MessagesController : ApiController 13 | { 14 | public async Task Post([FromBody]Activity activity) 15 | { 16 | var connector = new ConnectorClient(new Uri(activity.ServiceUrl)); 17 | 18 | if (activity?.Type == ActivityTypes.Message) 19 | { 20 | string pigLatinReply = new PigLatin().FromEnglish(activity.Text); 21 | 22 | Activity reply = activity.CreateReply(pigLatinReply); 23 | await connector.Conversations.ReplyToActivityAsync(reply); 24 | } 25 | else 26 | { 27 | await HandleSystemMessageAsync(activity); 28 | } 29 | 30 | 31 | return Request.CreateResponse(HttpStatusCode.OK); 32 | } 33 | 34 | async Task HandleSystemMessageAsync(Activity activity) 35 | { 36 | const string WelcomeMessage = @" 37 | # Welcome to Pig Latin Bot! 38 | Type anything and I'll convert it to Pig Latin."; 39 | 40 | if (activity.Type == ActivityTypes.ConversationUpdate) 41 | { 42 | Func isChatbot = 43 | channelAcct => channelAcct.Id == activity.Recipient.Id; 44 | 45 | if (activity.MembersAdded?.Any(isChatbot) ?? false) 46 | { 47 | Activity reply = (activity as Activity).CreateReply(WelcomeMessage); 48 | 49 | var connector = new ConnectorClient(new Uri(activity.ServiceUrl)); 50 | await connector.Conversations.ReplyToActivityAsync(reply); 51 | } 52 | } 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /BotFramework3/PigLatinBot/Controllers/WebChatController.cs: -------------------------------------------------------------------------------- 1 | using System.Configuration; 2 | using System.Net; 3 | using System.Net.Http; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Web.Http; 7 | 8 | namespace PigLatinBot 9 | { 10 | public class WebChatController : ApiController 11 | { 12 | public async Task Get() 13 | { 14 | string webChatSecret = ConfigurationManager.AppSettings["WebChatSecret"]; 15 | 16 | string result = await GetIFrameWithTokenAsync(webChatSecret); 17 | 18 | //string result = await GetIFrameViaPostWithToken(webChatSecret); 19 | 20 | HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK); 21 | response.Content = new StringContent(result, Encoding.UTF8, "text/html"); 22 | return response; 23 | } 24 | 25 | string GetIFrameWithSecret(string webChatSecret) 26 | { 27 | // This technique is insecure because you're exposing your secret in the Web page 28 | return $""; 29 | } 30 | 31 | async Task GetIFrameWithTokenAsync(string webChatSecret) 32 | { 33 | var request = new HttpRequestMessage(HttpMethod.Get, "https://webchat.botframework.com/api/tokens"); 34 | request.Headers.Add("Authorization", "BOTCONNECTOR " + webChatSecret); 35 | 36 | HttpResponseMessage response = await new HttpClient().SendAsync(request); 37 | string token = await response.Content.ReadAsStringAsync(); 38 | token = token.Replace("\"", ""); 39 | 40 | return $""; 41 | } 42 | 43 | //async Task GetIFrameViaPostWithToken(string webChatSecret) 44 | //{ 45 | // var request = new HttpRequestMessage(HttpMethod.Post, "https://webchat.botframework.com/api/conversations"); 46 | // request.Headers.Add("Authorization", "BOTCONNECTOR " + webChatSecret); 47 | 48 | // HttpResponseMessage response = await new HttpClient().SendAsync(request); 49 | // string responseJson = await response.Content.ReadAsStringAsync(); 50 | // WebChatTokenResponse webChatResponse = JsonConvert.DeserializeObject(responseJson); 51 | 52 | // return $""; 53 | //} 54 | } 55 | } -------------------------------------------------------------------------------- /BotFramework3/PigLatinBot/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="PigLatinBot.WebApiApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /BotFramework3/PigLatinBot/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Http; 2 | 3 | namespace PigLatinBot 4 | { 5 | public class WebApiApplication : System.Web.HttpApplication 6 | { 7 | protected void Application_Start() 8 | { 9 | GlobalConfiguration.Configure(WebApiConfig.Register); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /BotFramework3/PigLatinBot/PigLatin.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace PigLatinBot 6 | { 7 | public class PigLatin 8 | { 9 | readonly char[] alphas = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".ToCharArray(); 10 | readonly char[] vowels = "AEIOUaeiou".ToCharArray(); 11 | const string VowelSuffix = "yay"; 12 | const string ConsonantSuffix = "ay"; 13 | 14 | public string FromEnglish(string text) 15 | { 16 | string[] rawWords = text.Split(' '); 17 | 18 | List cleanedWords = 19 | (from word in rawWords 20 | let wordChars = word.ToLower().ToCharArray() 21 | let cleanChars = 22 | (from ch in wordChars 23 | where alphas.Contains(ch) 24 | select ch) 25 | .ToArray() 26 | select new string(cleanChars)) 27 | .ToList(); 28 | 29 | List cookedWords = 30 | (from word in cleanedWords 31 | select ConvertWord(word)) 32 | .ToList(); 33 | 34 | return string.Join(" ", cookedWords); 35 | } 36 | 37 | string ConvertWord(string text) 38 | { 39 | if (string.IsNullOrWhiteSpace(text)) 40 | return ""; 41 | 42 | char[] textChars = text.ToCharArray(); 43 | char firstChar = textChars[0]; 44 | 45 | if (vowels.Contains(firstChar)) 46 | { 47 | return text + VowelSuffix; 48 | } 49 | else 50 | { 51 | int newPrefixSize = textChars.Length > 0 ? textChars.Length - 1 : 0; 52 | var newPrefix = new char[newPrefixSize]; 53 | Array.Copy(textChars, 1, newPrefix, 0, newPrefixSize); 54 | 55 | return new string(newPrefix) + firstChar + ConsonantSuffix; 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /BotFramework3/PigLatinBot/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("PigLatinBot")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("PigLatinBot")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a8ba1066-5695-4d71-abb4-65e5a5e0c3d4")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /BotFramework3/PigLatinBot/Properties/PublishProfiles/PigLatinBotJoeMayo - Web Deploy (2).pubxml: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | MSDeploy 9 | False 10 | AzureWebSite 11 | Release 12 | Any CPU 13 | http://piglatinbotjoemayo.azurewebsites.net 14 | True 15 | False 16 | piglatinbotjoemayo.scm.azurewebsites.net:443 17 | PigLatinBotJoeMayo 18 | 19 | True 20 | WMSVC 21 | True 22 | $PigLatinBotJoeMayo 23 | <_SavePWD>True 24 | <_DestinationType>AzureWebSite 25 | 26 | -------------------------------------------------------------------------------- /BotFramework3/PigLatinBot/Properties/PublishProfiles/PigLatinBotJoeMayo - Web Deploy.pubxml: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | MSDeploy 9 | False 10 | AzureWebSite 11 | Release 12 | Any CPU 13 | http://piglatinbotjoemayo.azurewebsites.net 14 | True 15 | False 16 | piglatinbotjoemayo.scm.azurewebsites.net:443 17 | PigLatinBotJoeMayo 18 | 19 | True 20 | WMSVC 21 | True 22 | $PigLatinBotJoeMayo 23 | <_SavePWD>True 24 | <_DestinationType>AzureWebSite 25 | 26 | -------------------------------------------------------------------------------- /BotFramework3/PigLatinBot/Properties/PublishProfiles/PigLatinJoeMayo - Web Deploy.pubxml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | MSDeploy 9 | /subscriptions/67963947-8b9b-4bfe-b752-31738f16f437/resourcegroups/BotDemos/providers/Microsoft.Web/sites/PigLatinJoeMayo 10 | BotDemos 11 | AzureWebSite 12 | Release 13 | Any CPU 14 | http://piglatinjoemayo.azurewebsites.net 15 | True 16 | False 17 | piglatinjoemayo.scm.azurewebsites.net:443 18 | PigLatinJoeMayo 19 | 20 | True 21 | WMSVC 22 | True 23 | $PigLatinJoeMayo 24 | <_SavePWD>True 25 | <_DestinationType>AzureWebSite 26 | 27 | -------------------------------------------------------------------------------- /BotFramework3/PigLatinBot/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /BotFramework3/PigLatinBot/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /BotFramework3/PigLatinBot/WebChatTokenResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace PigLatinBot 5 | { 6 | public class WebChatTokenResponse 7 | { 8 | public string ConversationID { get; set; } 9 | 10 | public string Token { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /BotFramework3/PigLatinBot/default.htm: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Pig Latin Bot 5 | 6 | 7 | 8 | Pig Latin Bot 9 |

Pig Latin Bot

10 |

Translates your text to Pig Latin.

11 | 12 |
13 | 14 |
15 | 16 |

17 | Add to Slack 18 |

19 | 20 | 21 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /BotFramework3/PigLatinBot/images/PigLatinBot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoeMayo/BotDemos/0b4d93da17d743cfe58564174ed8ec1fc7a56529/BotFramework3/PigLatinBot/images/PigLatinBot.png -------------------------------------------------------------------------------- /BotFramework3/PigLatinBot/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /BotFramework3/Presentations/AzureBotService.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoeMayo/BotDemos/0b4d93da17d743cfe58564174ed8ec1fc7a56529/BotFramework3/Presentations/AzureBotService.pptx -------------------------------------------------------------------------------- /BotFramework3/Presentations/BotFrameworkTactics.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoeMayo/BotDemos/0b4d93da17d743cfe58564174ed8ec1fc7a56529/BotFramework3/Presentations/BotFrameworkTactics.pptx -------------------------------------------------------------------------------- /BotFramework3/Presentations/IntroBotFramework.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoeMayo/BotDemos/0b4d93da17d743cfe58564174ed8ec1fc7a56529/BotFramework3/Presentations/IntroBotFramework.pptx -------------------------------------------------------------------------------- /BotFramework4/BugDialogBot/AdapterWithErrorHandler.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | // 4 | // Generated with Bot Builder V4 SDK Template for Visual Studio CoreBot v4.6.2 5 | 6 | using Microsoft.Bot.Builder.Integration.AspNet.Core; 7 | using Microsoft.Bot.Builder.TraceExtensions; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace BugDialogBot 12 | { 13 | public class AdapterWithErrorHandler : BotFrameworkHttpAdapter 14 | { 15 | public AdapterWithErrorHandler(IConfiguration configuration, ILogger logger) 16 | : base(configuration, logger) 17 | { 18 | OnTurnError = async (turnContext, exception) => 19 | { 20 | // Log any leaked exception from the application. 21 | logger.LogError(exception, $"[OnTurnError] unhandled error : {exception.Message}"); 22 | 23 | // Send a message to the user 24 | await turnContext.SendActivityAsync("The bot encountered an error or bug."); 25 | await turnContext.SendActivityAsync("To continue to run this bot, please fix the bot source code."); 26 | 27 | // Send a trace activity, which will be displayed in the Bot Framework Emulator 28 | await turnContext.TraceActivityAsync("OnTurnError Trace", exception.Message, "https://www.botframework.com/schemas/error", "TurnError"); 29 | }; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /BotFramework4/BugDialogBot/Bots/MainBot.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | // 4 | // Generated with Bot Builder V4 SDK Template for Visual Studio EchoBot v4.6.2 5 | 6 | using System.Collections.Generic; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | using Microsoft.Bot.Builder; 10 | using Microsoft.Bot.Builder.Dialogs; 11 | using Microsoft.Bot.Schema; 12 | using Microsoft.Extensions.Logging; 13 | 14 | namespace BugDialogBot.Bots 15 | { 16 | public class MainBot : ActivityHandler 17 | where T : Dialog 18 | { 19 | readonly ConversationState conversationState; 20 | readonly UserState userState; 21 | readonly T dialog; 22 | ILogger> logger; 23 | 24 | public MainBot(ConversationState conversationState, UserState userState, T dialog, ILogger> logger) 25 | { 26 | this.dialog = dialog; 27 | this.conversationState = conversationState; 28 | this.userState = userState; 29 | this.logger = logger; 30 | } 31 | protected override async Task OnMessageActivityAsync(ITurnContext turnContext, CancellationToken cancellationToken) 32 | { 33 | await dialog.RunAsync(turnContext, conversationState.CreateProperty(nameof(DialogState)), cancellationToken); 34 | } 35 | 36 | protected override async Task OnMembersAddedAsync(IList membersAdded, ITurnContext turnContext, CancellationToken cancellationToken) 37 | { 38 | foreach (var member in membersAdded) 39 | { 40 | if (member.Id != turnContext.Activity.Recipient.Id) 41 | { 42 | string welcomeText = 43 | $"Hi, I'm Bug Dialog Bot. " + 44 | $"I simulate a bot that can help write bug reports."; 45 | await turnContext.SendActivityAsync(MessageFactory.Text(welcomeText), cancellationToken); 46 | await dialog.RunAsync(turnContext, conversationState.CreateProperty(nameof(DialogState)), cancellationToken); 47 | } 48 | } 49 | } 50 | 51 | public override async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken)) 52 | { 53 | await base.OnTurnAsync(turnContext, cancellationToken); 54 | 55 | // Save any state changes that might have occured during the turn. 56 | await conversationState.SaveChangesAsync(turnContext, false, cancellationToken); 57 | await userState.SaveChangesAsync(turnContext, false, cancellationToken); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /BotFramework4/BugDialogBot/BugDialogBot.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp2.1 5 | latest 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Always 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /BotFramework4/BugDialogBot/Controllers/BotController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | // 4 | // Generated with Bot Builder V4 SDK Template for Visual Studio EchoBot v4.6.2 5 | 6 | using System.Threading.Tasks; 7 | using Microsoft.AspNetCore.Mvc; 8 | using Microsoft.Bot.Builder; 9 | using Microsoft.Bot.Builder.Integration.AspNet.Core; 10 | 11 | namespace BugDialogBot.Controllers 12 | { 13 | // This ASP Controller is created to handle a request. Dependency Injection will provide the Adapter and IBot 14 | // implementation at runtime. Multiple different IBot implementations running at different endpoints can be 15 | // achieved by specifying a more specific type for the bot constructor argument. 16 | [Route("api/messages")] 17 | [ApiController] 18 | public class BotController : ControllerBase 19 | { 20 | private readonly IBotFrameworkHttpAdapter Adapter; 21 | private readonly IBot Bot; 22 | 23 | public BotController(IBotFrameworkHttpAdapter adapter, IBot bot) 24 | { 25 | Adapter = adapter; 26 | Bot = bot; 27 | } 28 | 29 | [HttpPost, HttpGet] 30 | public async Task PostAsync() 31 | { 32 | // Delegate the processing of the HTTP POST to the adapter. 33 | // The adapter will invoke the bot. 34 | await Adapter.ProcessAsync(Request, Response, Bot); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /BotFramework4/BugDialogBot/DeploymentTemplates/new-rg-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "groupLocation": { 6 | "value": "" 7 | }, 8 | "groupName": { 9 | "value": "" 10 | }, 11 | "appId": { 12 | "value": "" 13 | }, 14 | "appSecret": { 15 | "value": "" 16 | }, 17 | "botId": { 18 | "value": "" 19 | }, 20 | "botSku": { 21 | "value": "" 22 | }, 23 | "newAppServicePlanName": { 24 | "value": "" 25 | }, 26 | "newAppServicePlanSku": { 27 | "value": { 28 | "name": "S1", 29 | "tier": "Standard", 30 | "size": "S1", 31 | "family": "S", 32 | "capacity": 1 33 | } 34 | }, 35 | "newAppServicePlanLocation": { 36 | "value": "" 37 | }, 38 | "newWebAppName": { 39 | "value": "" 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /BotFramework4/BugDialogBot/DeploymentTemplates/preexisting-rg-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "appId": { 6 | "value": "" 7 | }, 8 | "appSecret": { 9 | "value": "" 10 | }, 11 | "botId": { 12 | "value": "" 13 | }, 14 | "botSku": { 15 | "value": "" 16 | }, 17 | "newAppServicePlanName": { 18 | "value": "" 19 | }, 20 | "newAppServicePlanSku": { 21 | "value": { 22 | "name": "S1", 23 | "tier": "Standard", 24 | "size": "S1", 25 | "family": "S", 26 | "capacity": 1 27 | } 28 | }, 29 | "appServicePlanLocation": { 30 | "value": "" 31 | }, 32 | "existingAppServicePlan": { 33 | "value": "" 34 | }, 35 | "newWebAppName": { 36 | "value": "" 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /BotFramework4/BugDialogBot/Dialogs/MainDialog.cs: -------------------------------------------------------------------------------- 1 | using BugDialogBot.Models; 2 | using Microsoft.Bot.Builder; 3 | using Microsoft.Bot.Builder.Dialogs; 4 | using Microsoft.Bot.Schema; 5 | using Microsoft.Extensions.Logging; 6 | using System.Collections.Generic; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | 10 | namespace BugDialogBot.Dialogs 11 | { 12 | public class MainDialog : ComponentDialog 13 | { 14 | readonly ILogger logger; 15 | 16 | List reportWords = new List { "NEW REPORT", "NEW", "REPORT", "BUG" }; 17 | 18 | public MainDialog(ReportDialog reportDialog, ILogger logger) 19 | : base(nameof(MainDialog)) 20 | { 21 | this.logger = logger; 22 | 23 | AddDialog(new TextPrompt(nameof(TextPrompt))); 24 | AddDialog(reportDialog); 25 | AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[] 26 | { 27 | IntroStepAsync, 28 | ActStepAsync, 29 | FinalStepAsync, 30 | })); 31 | 32 | InitialDialogId = nameof(WaterfallDialog); 33 | } 34 | 35 | async Task IntroStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) 36 | { 37 | var messageText = $"You can type 'New Report' to submit a new bug report."; 38 | var promptMessage = MessageFactory.Text(messageText, messageText, InputHints.ExpectingInput); 39 | return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = promptMessage }, cancellationToken); 40 | } 41 | 42 | async Task ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) 43 | { 44 | string userResponse = (stepContext.Result as string)?.ToUpper() ?? string.Empty; 45 | if (reportWords.Contains(userResponse)) 46 | { 47 | return await stepContext.BeginDialogAsync(nameof(ReportDialog), null, cancellationToken); 48 | } 49 | else 50 | { 51 | string unrecognizedResponse = 52 | "I can't do anything other than bug reports. " + 53 | "Just type 'New Report' to start a new bug report."; 54 | await stepContext.Context.SendActivityAsync(MessageFactory.Text(unrecognizedResponse), cancellationToken); 55 | return await stepContext.ReplaceDialogAsync(InitialDialogId, null, cancellationToken); 56 | } 57 | } 58 | 59 | async Task FinalStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) 60 | { 61 | if (stepContext.Result is BugReport rpt) 62 | { 63 | await stepContext.Context.SendActivityAsync( 64 | MessageFactory.Text( 65 | $"Your bug report with the following values has been submitted:\n" + 66 | $"\n" + 67 | $"* **Platform:** {rpt.Platform}\n" + 68 | $"* **Product:** {rpt.Product}\n" + 69 | $"* **Description:** {rpt.Description}\n" + 70 | $"\n" + 71 | $"Thanks for the feedback!")); 72 | } 73 | else 74 | { 75 | await stepContext.Context.SendActivityAsync(MessageFactory.Text("Not submitted - you're welcome to submit another bug report any time.")); 76 | } 77 | 78 | return await stepContext.ReplaceDialogAsync(InitialDialogId, null, cancellationToken); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /BotFramework4/BugDialogBot/Models/BugReport.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace BugDialogBot.Models 4 | { 5 | public class BugReport 6 | { 7 | public ProductOptions Product { get; set; } 8 | 9 | public PlatformOptions Platform { get; set; } 10 | 11 | public string Description { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /BotFramework4/BugDialogBot/Models/PlatformOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace BugDialogBot.Models 7 | { 8 | public enum PlatformOptions 9 | { 10 | Linux, 11 | Mac, 12 | Windows 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /BotFramework4/BugDialogBot/Models/ProductOptions.cs: -------------------------------------------------------------------------------- 1 | namespace BugDialogBot.Models 2 | { 3 | public enum ProductOptions 4 | { 5 | Office, 6 | SQLServer, 7 | VisualStudio 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /BotFramework4/BugDialogBot/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | // 4 | // Generated with Bot Builder V4 SDK Template for Visual Studio EchoBot v4.6.2 5 | 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | 9 | namespace BugDialogBot 10 | { 11 | public class Program 12 | { 13 | public static void Main(string[] args) 14 | { 15 | CreateWebHostBuilder(args).Build().Run(); 16 | } 17 | 18 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 19 | WebHost.CreateDefaultBuilder(args) 20 | .UseStartup(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /BotFramework4/BugDialogBot/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:3978", 8 | "sslPort": 0 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | }, 19 | "EchoBot": { 20 | "commandName": "Project", 21 | "launchBrowser": true, 22 | "applicationUrl": "https://localhost:3979;http://localhost:3978", 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BotFramework4/BugDialogBot/README.md: -------------------------------------------------------------------------------- 1 | # BugDialogBot 2 | 3 | Bot Framework v4 echo bot sample. 4 | 5 | This bot has been created using [Bot Framework](https://dev.botframework.com), it shows how to create a simple bot that accepts input from the user and echoes it back. 6 | 7 | ## Prerequisites 8 | 9 | - [.NET Core SDK](https://dotnet.microsoft.com/download) version 2.1 10 | 11 | ```bash 12 | # determine dotnet version 13 | dotnet --version 14 | ``` 15 | 16 | ## To try this sample 17 | 18 | - In a terminal, navigate to `BugDialogBot` 19 | 20 | ```bash 21 | # change into project folder 22 | cd # BugDialogBot 23 | ``` 24 | 25 | - Run the bot from a terminal or from Visual Studio, choose option A or B. 26 | 27 | A) From a terminal 28 | 29 | ```bash 30 | # run the bot 31 | dotnet run 32 | ``` 33 | 34 | B) Or from Visual Studio 35 | 36 | - Launch Visual Studio 37 | - File -> Open -> Project/Solution 38 | - Navigate to `BugDialogBot` folder 39 | - Select `BugDialogBot.csproj` file 40 | - Press `F5` to run the project 41 | 42 | ## Testing the bot using Bot Framework Emulator 43 | 44 | [Bot Framework Emulator](https://github.com/microsoft/botframework-emulator) is a desktop application that allows bot developers to test and debug their bots on localhost or running remotely through a tunnel. 45 | 46 | - Install the Bot Framework Emulator version 4.5.0 or greater from [here](https://github.com/Microsoft/BotFramework-Emulator/releases) 47 | 48 | ### Connect to the bot using Bot Framework Emulator 49 | 50 | - Launch Bot Framework Emulator 51 | - File -> Open Bot 52 | - Enter a Bot URL of `http://localhost:3978/api/messages` 53 | 54 | ## Deploy the bot to Azure 55 | 56 | To learn more about deploying a bot to Azure, see [Deploy your bot to Azure](https://aka.ms/azuredeployment) for a complete list of deployment instructions. 57 | 58 | ## Further reading 59 | 60 | - [Bot Framework Documentation](https://docs.botframework.com) 61 | - [Bot Basics](https://docs.microsoft.com/azure/bot-service/bot-builder-basics?view=azure-bot-service-4.0) 62 | - [Activity processing](https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-concept-activity-processing?view=azure-bot-service-4.0) 63 | - [Azure Bot Service Introduction](https://docs.microsoft.com/azure/bot-service/bot-service-overview-introduction?view=azure-bot-service-4.0) 64 | - [Azure Bot Service Documentation](https://docs.microsoft.com/azure/bot-service/?view=azure-bot-service-4.0) 65 | - [.NET Core CLI tools](https://docs.microsoft.com/en-us/dotnet/core/tools/?tabs=netcore2x) 66 | - [Azure CLI](https://docs.microsoft.com/cli/azure/?view=azure-cli-latest) 67 | - [Azure Portal](https://portal.azure.com) 68 | - [Language Understanding using LUIS](https://docs.microsoft.com/en-us/azure/cognitive-services/luis/) 69 | - [Channels and Bot Connector Service](https://docs.microsoft.com/en-us/azure/bot-service/bot-concepts?view=azure-bot-service-4.0) 70 | -------------------------------------------------------------------------------- /BotFramework4/BugDialogBot/Startup.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | // 4 | // Generated with Bot Builder V4 SDK Template for Visual Studio EchoBot v4.6.2 5 | 6 | using Microsoft.AspNetCore.Builder; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.AspNetCore.Mvc; 9 | using Microsoft.Bot.Builder; 10 | using Microsoft.Bot.Builder.Integration.AspNet.Core; 11 | using Microsoft.Extensions.Configuration; 12 | using Microsoft.Extensions.DependencyInjection; 13 | 14 | using BugDialogBot.Bots; 15 | using BugDialogBot.Dialogs; 16 | 17 | namespace BugDialogBot 18 | { 19 | public class Startup 20 | { 21 | public Startup(IConfiguration configuration) 22 | { 23 | Configuration = configuration; 24 | } 25 | 26 | public IConfiguration Configuration { get; } 27 | 28 | // This method gets called by the runtime. Use this method to add services to the container. 29 | public void ConfigureServices(IServiceCollection services) 30 | { 31 | services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); 32 | 33 | // Create the Bot Framework Adapter with error handling enabled. 34 | services.AddSingleton(); 35 | 36 | services.AddSingleton(); 37 | services.AddSingleton(); 38 | services.AddSingleton(); 39 | 40 | services.AddSingleton(); 41 | services.AddSingleton(); 42 | 43 | // Create the bot as a transient. In this case the ASP Controller is expecting an IBot. 44 | services.AddTransient>(); 45 | } 46 | 47 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 48 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 49 | { 50 | if (env.IsDevelopment()) 51 | { 52 | app.UseDeveloperExceptionPage(); 53 | } 54 | else 55 | { 56 | app.UseHsts(); 57 | } 58 | 59 | app.UseDefaultFiles(); 60 | app.UseStaticFiles(); 61 | app.UseWebSockets(); 62 | //app.UseHttpsRedirection(); 63 | app.UseMvc(); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /BotFramework4/BugDialogBot/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /BotFramework4/BugDialogBot/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "MicrosoftAppId": "", 3 | "MicrosoftAppPassword": "" 4 | } 5 | -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/AdapterWithErrorHandler.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | // 4 | // Generated with Bot Builder V4 SDK Template for Visual Studio CoreBot v4.6.2 5 | 6 | using System; 7 | using Microsoft.Bot.Builder; 8 | using Microsoft.Bot.Builder.Integration.AspNet.Core; 9 | using Microsoft.Bot.Builder.TraceExtensions; 10 | using Microsoft.Bot.Schema; 11 | using Microsoft.Extensions.Configuration; 12 | using Microsoft.Extensions.Logging; 13 | 14 | namespace ContactInfoBot 15 | { 16 | public class AdapterWithErrorHandler : BotFrameworkHttpAdapter 17 | { 18 | public AdapterWithErrorHandler(IConfiguration configuration, ILogger logger, ConversationState conversationState = null) 19 | : base(configuration, logger) 20 | { 21 | OnTurnError = async (turnContext, exception) => 22 | { 23 | // Log any leaked exception from the application. 24 | logger.LogError(exception, $"[OnTurnError] unhandled error : {exception.Message}"); 25 | 26 | // Send a message to the user 27 | var errorMessageText = "The bot encountered an error or bug."; 28 | var errorMessage = MessageFactory.Text(errorMessageText, errorMessageText, InputHints.ExpectingInput); 29 | await turnContext.SendActivityAsync(errorMessage); 30 | 31 | errorMessageText = "To continue to run this bot, please fix the bot source code."; 32 | errorMessage = MessageFactory.Text(errorMessageText, errorMessageText, InputHints.ExpectingInput); 33 | await turnContext.SendActivityAsync(errorMessage); 34 | 35 | if (conversationState != null) 36 | { 37 | try 38 | { 39 | // Delete the conversationState for the current conversation to prevent the 40 | // bot from getting stuck in a error-loop caused by being in a bad state. 41 | // ConversationState should be thought of as similar to "cookie-state" in a Web pages. 42 | await conversationState.DeleteAsync(turnContext); 43 | } 44 | catch (Exception e) 45 | { 46 | logger.LogError(e, $"Exception caught on attempting to Delete ConversationState : {e.Message}"); 47 | } 48 | } 49 | 50 | // Send a trace activity, which will be displayed in the Bot Framework Emulator 51 | await turnContext.TraceActivityAsync("OnTurnError Trace", exception.Message, "https://www.botframework.com/schemas/error", "TurnError"); 52 | }; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/BookingDetails.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | // 4 | // Generated with Bot Builder V4 SDK Template for Visual Studio CoreBot v4.6.2 5 | 6 | namespace ContactInfoBot 7 | { 8 | public class BookingDetails 9 | { 10 | public string Destination { get; set; } 11 | 12 | public string Origin { get; set; } 13 | 14 | public string TravelDate { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/Bots/DialogAndWelcomeBot.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | // 4 | // Generated with Bot Builder V4 SDK Template for Visual Studio CoreBot v4.6.2 5 | 6 | using System.Collections.Generic; 7 | using System.IO; 8 | using System.Threading; 9 | using System.Threading.Tasks; 10 | using Microsoft.Bot.Builder; 11 | using Microsoft.Bot.Builder.Dialogs; 12 | using Microsoft.Bot.Schema; 13 | using Microsoft.Extensions.Logging; 14 | using Newtonsoft.Json; 15 | 16 | namespace ContactInfoBot.Bots 17 | { 18 | public class DialogAndWelcomeBot : DialogBot 19 | where T : Dialog 20 | { 21 | public DialogAndWelcomeBot(ConversationState conversationState, UserState userState, T dialog, ILogger> logger) 22 | : base(conversationState, userState, dialog, logger) 23 | { 24 | } 25 | 26 | protected override async Task OnMembersAddedAsync(IList membersAdded, ITurnContext turnContext, CancellationToken cancellationToken) 27 | { 28 | foreach (var member in membersAdded) 29 | { 30 | // Greet anyone that was not the target (recipient) of this message. 31 | // To learn more about Adaptive Cards, see https://aka.ms/msbot-adaptivecards for more details. 32 | if (member.Id != turnContext.Activity.Recipient.Id) 33 | { 34 | var welcomeCard = CreateAdaptiveCardAttachment(); 35 | var response = MessageFactory.Attachment(welcomeCard); 36 | await turnContext.SendActivityAsync(response, cancellationToken); 37 | await Dialog.RunAsync(turnContext, ConversationState.CreateProperty("DialogState"), cancellationToken); 38 | } 39 | } 40 | } 41 | 42 | // Load attachment from embedded resource. 43 | private Attachment CreateAdaptiveCardAttachment() 44 | { 45 | var cardResourcePath = "ContactInfoBot.Cards.welcomeCard.json"; 46 | 47 | using (var stream = GetType().Assembly.GetManifestResourceStream(cardResourcePath)) 48 | { 49 | using (var reader = new StreamReader(stream)) 50 | { 51 | var adaptiveCard = reader.ReadToEnd(); 52 | return new Attachment() 53 | { 54 | ContentType = "application/vnd.microsoft.card.adaptive", 55 | Content = JsonConvert.DeserializeObject(adaptiveCard), 56 | }; 57 | } 58 | } 59 | } 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/Bots/DialogBot.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | // 4 | // Generated with Bot Builder V4 SDK Template for Visual Studio CoreBot v4.6.2 5 | 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | using Microsoft.Bot.Builder; 9 | using Microsoft.Bot.Builder.Dialogs; 10 | using Microsoft.Bot.Schema; 11 | using Microsoft.Extensions.Logging; 12 | 13 | namespace ContactInfoBot.Bots 14 | { 15 | // This IBot implementation can run any type of Dialog. The use of type parameterization is to allows multiple different bots 16 | // to be run at different endpoints within the same project. This can be achieved by defining distinct Controller types 17 | // each with dependency on distinct IBot types, this way ASP Dependency Injection can glue everything together without ambiguity. 18 | // The ConversationState is used by the Dialog system. The UserState isn't, however, it might have been used in a Dialog implementation, 19 | // and the requirement is that all BotState objects are saved at the end of a turn. 20 | public class DialogBot : ActivityHandler 21 | where T : Dialog 22 | { 23 | protected readonly Dialog Dialog; 24 | protected readonly BotState ConversationState; 25 | protected readonly BotState UserState; 26 | protected readonly ILogger Logger; 27 | 28 | public DialogBot(ConversationState conversationState, UserState userState, T dialog, ILogger> logger) 29 | { 30 | ConversationState = conversationState; 31 | UserState = userState; 32 | Dialog = dialog; 33 | Logger = logger; 34 | } 35 | 36 | public override async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken)) 37 | { 38 | await base.OnTurnAsync(turnContext, cancellationToken); 39 | 40 | // Save any state changes that might have occured during the turn. 41 | await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken); 42 | await UserState.SaveChangesAsync(turnContext, false, cancellationToken); 43 | } 44 | 45 | protected override async Task OnMessageActivityAsync(ITurnContext turnContext, CancellationToken cancellationToken) 46 | { 47 | Logger.LogInformation("Running dialog with Message Activity."); 48 | 49 | // Run the Dialog with the new message Activity. 50 | await Dialog.RunAsync(turnContext, ConversationState.CreateProperty("DialogState"), cancellationToken); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/Bots/MainBot.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | // 4 | // Generated with Bot Builder V4 SDK Template for Visual Studio EchoBot v4.6.2 5 | 6 | using System.Collections.Generic; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | using Microsoft.Bot.Builder; 10 | using Microsoft.Bot.Builder.Dialogs; 11 | using Microsoft.Bot.Schema; 12 | using Microsoft.Extensions.Logging; 13 | 14 | namespace ContactInfoBot.Bots 15 | { 16 | public class MainBot : ActivityHandler 17 | where T : Dialog 18 | { 19 | readonly ConversationState conversationState; 20 | readonly UserState userState; 21 | readonly T dialog; 22 | ILogger> logger; 23 | 24 | public MainBot(ConversationState conversationState, UserState userState, T dialog, ILogger> logger) 25 | { 26 | this.dialog = dialog; 27 | this.conversationState = conversationState; 28 | this.userState = userState; 29 | this.logger = logger; 30 | } 31 | protected override async Task OnMessageActivityAsync(ITurnContext turnContext, CancellationToken cancellationToken) 32 | { 33 | await dialog.RunAsync(turnContext, conversationState.CreateProperty(nameof(DialogState)), cancellationToken); 34 | } 35 | 36 | protected override async Task OnMembersAddedAsync(IList membersAdded, ITurnContext turnContext, CancellationToken cancellationToken) 37 | { 38 | foreach (var member in membersAdded) 39 | { 40 | if (member.Id != turnContext.Activity.Recipient.Id) 41 | { 42 | string welcomeText = 43 | $"Hi, I'm Bug Dialog Bot. " + 44 | $"I simulate a bot that can help write bug reports."; 45 | await turnContext.SendActivityAsync(MessageFactory.Text(welcomeText), cancellationToken); 46 | await dialog.RunAsync(turnContext, conversationState.CreateProperty(nameof(DialogState)), cancellationToken); 47 | } 48 | } 49 | } 50 | 51 | public override async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken)) 52 | { 53 | await base.OnTurnAsync(turnContext, cancellationToken); 54 | 55 | // Save any state changes that might have occured during the turn. 56 | await conversationState.SaveChangesAsync(turnContext, false, cancellationToken); 57 | await userState.SaveChangesAsync(turnContext, false, cancellationToken); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/Cards/welcomeCard.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", 3 | "type": "AdaptiveCard", 4 | "version": "1.0", 5 | "body": [ 6 | { 7 | "type": "Image", 8 | "url": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQtB3AwMUeNoq4gUBGe6Ocj8kyh3bXa9ZbV7u1fVKQoyKFHdkqU", 9 | "size": "stretch" 10 | }, 11 | { 12 | "type": "TextBlock", 13 | "spacing": "medium", 14 | "size": "default", 15 | "weight": "bolder", 16 | "text": "Welcome to Bot Framework!", 17 | "wrap": true, 18 | "maxLines": 0 19 | }, 20 | { 21 | "type": "TextBlock", 22 | "size": "default", 23 | "isSubtle": true, 24 | "text": "Now that you have successfully run your bot, follow the links in this Adaptive Card to expand your knowledge of Bot Framework.", 25 | "wrap": true, 26 | "maxLines": 0 27 | } 28 | ], 29 | "actions": [ 30 | { 31 | "type": "Action.OpenUrl", 32 | "title": "Get an overview", 33 | "url": "https://docs.microsoft.com/en-us/azure/bot-service/?view=azure-bot-service-4.0" 34 | }, 35 | { 36 | "type": "Action.OpenUrl", 37 | "title": "Ask a question", 38 | "url": "https://stackoverflow.com/questions/tagged/botframework" 39 | }, 40 | { 41 | "type": "Action.OpenUrl", 42 | "title": "Learn how to deploy", 43 | "url": "https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-howto-deploy-azure?view=azure-bot-service-4.0" 44 | } 45 | ] 46 | } -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/CognitiveModels/FlightBooking.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Code generated by LUISGen .\FlightBooking.json -cs Luis.FlightBooking -o . 3 | // Tool github: https://github.com/microsoft/botbuilder-tools 4 | // Changes may cause incorrect behavior and will be lost if the code is 5 | // regenerated. 6 | // 7 | using Newtonsoft.Json; 8 | using System.Collections.Generic; 9 | using Microsoft.Bot.Builder; 10 | using Microsoft.Bot.Builder.AI.Luis; 11 | 12 | namespace ContactInfoBot.CognitiveModels 13 | { 14 | public partial class FlightBooking : IRecognizerConvert 15 | { 16 | public string Text; 17 | public string AlteredText; 18 | public enum Intent 19 | { 20 | BookFlight, 21 | Cancel, 22 | GetWeather, 23 | None 24 | }; 25 | public Dictionary Intents; 26 | 27 | public class _Entities 28 | { 29 | 30 | // Built-in entities 31 | public DateTimeSpec[] datetime; 32 | 33 | // Lists 34 | public string[][] Airport; 35 | 36 | // Composites 37 | public class _InstanceFrom 38 | { 39 | public InstanceData[] Airport; 40 | } 41 | public class FromClass 42 | { 43 | public string[][] Airport; 44 | [JsonProperty("$instance")] 45 | public _InstanceFrom _instance; 46 | } 47 | public FromClass[] From; 48 | 49 | public class _InstanceTo 50 | { 51 | public InstanceData[] Airport; 52 | } 53 | public class ToClass 54 | { 55 | public string[][] Airport; 56 | [JsonProperty("$instance")] 57 | public _InstanceTo _instance; 58 | } 59 | public ToClass[] To; 60 | 61 | // Instance 62 | public class _Instance 63 | { 64 | public InstanceData[] datetime; 65 | public InstanceData[] Airport; 66 | public InstanceData[] From; 67 | public InstanceData[] To; 68 | } 69 | [JsonProperty("$instance")] 70 | public _Instance _instance; 71 | } 72 | public _Entities Entities; 73 | 74 | [JsonExtensionData(ReadData = true, WriteData = true)] 75 | public IDictionary Properties { get; set; } 76 | 77 | public void Convert(dynamic result) 78 | { 79 | var app = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(result, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); 80 | Text = app.Text; 81 | AlteredText = app.AlteredText; 82 | Intents = app.Intents; 83 | Entities = app.Entities; 84 | Properties = app.Properties; 85 | } 86 | 87 | public (Intent intent, double score) TopIntent() 88 | { 89 | Intent maxIntent = Intent.None; 90 | var max = 0.0; 91 | foreach (var entry in Intents) 92 | { 93 | if (entry.Value.Score > max) 94 | { 95 | maxIntent = entry.Key; 96 | max = entry.Value.Score.Value; 97 | } 98 | } 99 | return (maxIntent, max); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/CognitiveModels/FlightBookingEx.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | using System.Linq; 5 | 6 | namespace ContactInfoBot.CognitiveModels 7 | { 8 | // Extends the partial FlightBooking class with methods and properties that simplify accessing entities in the luis results 9 | public partial class FlightBooking 10 | { 11 | public (string From, string Airport) FromEntities 12 | { 13 | get 14 | { 15 | var fromValue = Entities?._instance?.From?.FirstOrDefault()?.Text; 16 | var fromAirportValue = Entities?.From?.FirstOrDefault()?.Airport?.FirstOrDefault()?.FirstOrDefault(); 17 | return (fromValue, fromAirportValue); 18 | } 19 | } 20 | 21 | public (string To, string Airport) ToEntities 22 | { 23 | get 24 | { 25 | var toValue = Entities?._instance?.To?.FirstOrDefault()?.Text; 26 | var toAirportValue = Entities?.To?.FirstOrDefault()?.Airport?.FirstOrDefault()?.FirstOrDefault(); 27 | return (toValue, toAirportValue); 28 | } 29 | } 30 | 31 | // This value will be a TIMEX. And we are only interested in a Date so grab the first result and drop the Time part. 32 | // TIMEX is a format that represents DateTime expressions that include some ambiguity. e.g. missing a Year. 33 | public string TravelDate 34 | => Entities.datetime?.FirstOrDefault()?.Expressions.FirstOrDefault()?.Split('T')[0]; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/ContactInfoBot.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp2.1 5 | latest 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | Always 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/Controllers/BotController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | // 4 | // Generated with Bot Builder V4 SDK Template for Visual Studio CoreBot v4.6.2 5 | 6 | using System.Threading.Tasks; 7 | using Microsoft.AspNetCore.Mvc; 8 | using Microsoft.Bot.Builder; 9 | using Microsoft.Bot.Builder.Integration.AspNet.Core; 10 | 11 | namespace ContactInfoBot.Controllers 12 | { 13 | // This ASP Controller is created to handle a request. Dependency Injection will provide the Adapter and IBot 14 | // implementation at runtime. Multiple different IBot implementations running at different endpoints can be 15 | // achieved by specifying a more specific type for the bot constructor argument. 16 | [Route("api/messages")] 17 | [ApiController] 18 | public class BotController : ControllerBase 19 | { 20 | private readonly IBotFrameworkHttpAdapter Adapter; 21 | private readonly IBot Bot; 22 | 23 | public BotController(IBotFrameworkHttpAdapter adapter, IBot bot) 24 | { 25 | Adapter = adapter; 26 | Bot = bot; 27 | } 28 | 29 | [HttpPost, HttpGet] 30 | public async Task PostAsync() 31 | { 32 | // Delegate the processing of the HTTP POST to the adapter. 33 | // The adapter will invoke the bot. 34 | await Adapter.ProcessAsync(Request, Response, Bot); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/DeploymentTemplates/new-rg-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "groupLocation": { 6 | "value": "" 7 | }, 8 | "groupName": { 9 | "value": "" 10 | }, 11 | "appId": { 12 | "value": "" 13 | }, 14 | "appSecret": { 15 | "value": "" 16 | }, 17 | "botId": { 18 | "value": "" 19 | }, 20 | "botSku": { 21 | "value": "" 22 | }, 23 | "newAppServicePlanName": { 24 | "value": "" 25 | }, 26 | "newAppServicePlanSku": { 27 | "value": { 28 | "name": "S1", 29 | "tier": "Standard", 30 | "size": "S1", 31 | "family": "S", 32 | "capacity": 1 33 | } 34 | }, 35 | "newAppServicePlanLocation": { 36 | "value": "" 37 | }, 38 | "newWebAppName": { 39 | "value": "" 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/DeploymentTemplates/preexisting-rg-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "appId": { 6 | "value": "" 7 | }, 8 | "appSecret": { 9 | "value": "" 10 | }, 11 | "botId": { 12 | "value": "" 13 | }, 14 | "botSku": { 15 | "value": "" 16 | }, 17 | "newAppServicePlanName": { 18 | "value": "" 19 | }, 20 | "newAppServicePlanSku": { 21 | "value": { 22 | "name": "S1", 23 | "tier": "Standard", 24 | "size": "S1", 25 | "family": "S", 26 | "capacity": 1 27 | } 28 | }, 29 | "appServicePlanLocation": { 30 | "value": "" 31 | }, 32 | "existingAppServicePlan": { 33 | "value": "" 34 | }, 35 | "newWebAppName": { 36 | "value": "" 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/Dialogs/CancelAndHelpDialog.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | // 4 | // Generated with Bot Builder V4 SDK Template for Visual Studio CoreBot v4.6.2 5 | 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | using Microsoft.Bot.Builder; 9 | using Microsoft.Bot.Builder.Dialogs; 10 | using Microsoft.Bot.Schema; 11 | 12 | namespace ContactInfoBot.Dialogs 13 | { 14 | public class CancelAndHelpDialog : ComponentDialog 15 | { 16 | private const string HelpMsgText = "Show help here"; 17 | private const string CancelMsgText = "Cancelling..."; 18 | 19 | public CancelAndHelpDialog(string id) 20 | : base(id) 21 | { 22 | } 23 | 24 | protected override async Task OnContinueDialogAsync(DialogContext innerDc, CancellationToken cancellationToken = default) 25 | { 26 | var result = await InterruptAsync(innerDc, cancellationToken); 27 | if (result != null) 28 | { 29 | return result; 30 | } 31 | 32 | return await base.OnContinueDialogAsync(innerDc, cancellationToken); 33 | } 34 | 35 | private async Task InterruptAsync(DialogContext innerDc, CancellationToken cancellationToken) 36 | { 37 | if (innerDc.Context.Activity.Type == ActivityTypes.Message) 38 | { 39 | var text = innerDc.Context.Activity.Text.ToLowerInvariant(); 40 | 41 | switch (text) 42 | { 43 | case "help": 44 | case "?": 45 | var helpMessage = MessageFactory.Text(HelpMsgText, HelpMsgText, InputHints.ExpectingInput); 46 | await innerDc.Context.SendActivityAsync(helpMessage, cancellationToken); 47 | return new DialogTurnResult(DialogTurnStatus.Waiting); 48 | 49 | case "cancel": 50 | case "quit": 51 | var cancelMessage = MessageFactory.Text(CancelMsgText, CancelMsgText, InputHints.IgnoringInput); 52 | await innerDc.Context.SendActivityAsync(cancelMessage, cancellationToken); 53 | return await innerDc.CancelAllDialogsAsync(cancellationToken); 54 | } 55 | } 56 | 57 | return null; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/Dialogs/DateResolverDialog.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | // 4 | // Generated with Bot Builder V4 SDK Template for Visual Studio CoreBot v4.6.2 5 | 6 | using System.Collections.Generic; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | using Microsoft.Bot.Builder; 10 | using Microsoft.Bot.Builder.Dialogs; 11 | using Microsoft.Bot.Schema; 12 | using Microsoft.Recognizers.Text.DataTypes.TimexExpression; 13 | 14 | namespace ContactInfoBot.Dialogs 15 | { 16 | public class DateResolverDialog : CancelAndHelpDialog 17 | { 18 | private const string PromptMsgText = "When would you like to travel?"; 19 | private const string RepromptMsgText = "I'm sorry, to make your booking please enter a full travel date including Day Month and Year."; 20 | 21 | public DateResolverDialog(string id = null) 22 | : base(id ?? nameof(DateResolverDialog)) 23 | { 24 | AddDialog(new DateTimePrompt(nameof(DateTimePrompt), DateTimePromptValidator)); 25 | AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[] 26 | { 27 | InitialStepAsync, 28 | FinalStepAsync, 29 | })); 30 | 31 | // The initial child Dialog to run. 32 | InitialDialogId = nameof(WaterfallDialog); 33 | } 34 | 35 | private async Task InitialStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) 36 | { 37 | var timex = (string)stepContext.Options; 38 | 39 | var promptMessage = MessageFactory.Text(PromptMsgText, PromptMsgText, InputHints.ExpectingInput); 40 | var repromptMessage = MessageFactory.Text(RepromptMsgText, RepromptMsgText, InputHints.ExpectingInput); 41 | 42 | if (timex == null) 43 | { 44 | // We were not given any date at all so prompt the user. 45 | return await stepContext.PromptAsync(nameof(DateTimePrompt), 46 | new PromptOptions 47 | { 48 | Prompt = promptMessage, 49 | RetryPrompt = repromptMessage, 50 | }, cancellationToken); 51 | } 52 | 53 | // We have a Date we just need to check it is unambiguous. 54 | var timexProperty = new TimexProperty(timex); 55 | if (!timexProperty.Types.Contains(Constants.TimexTypes.Definite)) 56 | { 57 | // This is essentially a "reprompt" of the data we were given up front. 58 | return await stepContext.PromptAsync(nameof(DateTimePrompt), 59 | new PromptOptions 60 | { 61 | Prompt = repromptMessage, 62 | }, cancellationToken); 63 | } 64 | 65 | return await stepContext.NextAsync(new List { new DateTimeResolution { Timex = timex } }, cancellationToken); 66 | } 67 | 68 | private async Task FinalStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) 69 | { 70 | var timex = ((List)stepContext.Result)[0].Timex; 71 | return await stepContext.EndDialogAsync(timex, cancellationToken); 72 | } 73 | 74 | private static Task DateTimePromptValidator(PromptValidatorContext> promptContext, CancellationToken cancellationToken) 75 | { 76 | if (promptContext.Recognized.Succeeded) 77 | { 78 | // This value will be a TIMEX. And we are only interested in a Date so grab the first result and drop the Time part. 79 | // TIMEX is a format that represents DateTime expressions that include some ambiguity. e.g. missing a Year. 80 | var timex = promptContext.Recognized.Value[0].Timex.Split('T')[0]; 81 | 82 | // If this is a definite Date including year, month and day we are good otherwise reprompt. 83 | // A better solution might be to let the user know what part is actually missing. 84 | var isDefinite = new TimexProperty(timex).Types.Contains(Constants.TimexTypes.Definite); 85 | 86 | return Task.FromResult(isDefinite); 87 | } 88 | 89 | return Task.FromResult(false); 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/FlightBookingRecognizer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using Microsoft.Bot.Builder; 7 | using Microsoft.Bot.Builder.AI.Luis; 8 | using Microsoft.Extensions.Configuration; 9 | 10 | namespace ContactInfoBot 11 | { 12 | public class FlightBookingRecognizer : IRecognizer 13 | { 14 | private readonly LuisRecognizer _recognizer; 15 | 16 | public FlightBookingRecognizer(IConfiguration configuration) 17 | { 18 | var luisIsConfigured = !string.IsNullOrEmpty(configuration["LuisAppId"]) && !string.IsNullOrEmpty(configuration["LuisAPIKey"]) && !string.IsNullOrEmpty(configuration["LuisAPIHostName"]); 19 | if (luisIsConfigured) 20 | { 21 | var luisApplication = new LuisApplication( 22 | configuration["LuisAppId"], 23 | configuration["LuisAPIKey"], 24 | "https://" + configuration["LuisAPIHostName"]); 25 | // Set the recognizer options depending on which endpoint version you want to use. 26 | // More details can be found in https://docs.microsoft.com/en-gb/azure/cognitive-services/luis/luis-migration-api-v3 27 | var recognizerOptions = new LuisRecognizerOptionsV3(luisApplication) 28 | { 29 | PredictionOptions = new Microsoft.Bot.Builder.AI.LuisV3.LuisPredictionOptions 30 | { 31 | IncludeInstanceData = true, 32 | } 33 | }; 34 | 35 | _recognizer = new LuisRecognizer(recognizerOptions); 36 | } 37 | } 38 | 39 | // Returns true if luis is configured in the appsettings.json and initialized. 40 | public virtual bool IsConfigured => _recognizer != null; 41 | 42 | public virtual async Task RecognizeAsync(ITurnContext turnContext, CancellationToken cancellationToken) 43 | => await _recognizer.RecognizeAsync(turnContext, cancellationToken); 44 | 45 | public virtual async Task RecognizeAsync(ITurnContext turnContext, CancellationToken cancellationToken) 46 | where T : IRecognizerConvert, new() 47 | => await _recognizer.RecognizeAsync(turnContext, cancellationToken); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | // 4 | // Generated with Bot Builder V4 SDK Template for Visual Studio CoreBot v4.6.2 5 | 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace ContactInfoBot 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateWebHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 20 | WebHost.CreateDefaultBuilder(args) 21 | .ConfigureLogging((logging) => 22 | { 23 | logging.AddDebug(); 24 | logging.AddConsole(); 25 | }) 26 | .UseStartup(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:3978/", 8 | "sslPort": 0 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | }, 19 | "CoreBot": { 20 | "commandName": "Project", 21 | "launchBrowser": true, 22 | "applicationUrl": "http://localhost:3978", 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/README.md: -------------------------------------------------------------------------------- 1 | # ContactInfoBot 2 | 3 | Bot Framework v4 core bot sample. 4 | 5 | This bot has been created using [Bot Framework](https://dev.botframework.com), it shows how to: 6 | 7 | - Use [LUIS](https://www.luis.ai) to implement core AI capabilities 8 | - Implement a multi-turn conversation using Dialogs 9 | - Handle user interruptions for such things as `Help` or `Cancel` 10 | - Prompt for and validate requests for information from the user 11 | 12 | ## Prerequisites 13 | 14 | This sample **requires** prerequisites in order to run. 15 | 16 | ### Overview 17 | 18 | This bot uses [LUIS](https://www.luis.ai), an AI based cognitive service, to implement language understanding. 19 | 20 | ### Install .NET Core CLI 21 | 22 | - [.NET Core SDK](https://dotnet.microsoft.com/download) version 2.1 23 | 24 | ```bash 25 | # determine dotnet version 26 | dotnet --version 27 | ``` 28 | 29 | - If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/). 30 | - Install the latest version of the [Azure CLI](https://docs.microsoft.com/cli/azure/install-azure-cli?view=azure-cli-latest) tool. Version 2.0.54 or higher. 31 | 32 | ### Create a LUIS Application to enable language understanding 33 | 34 | The LUIS model for this example can be found under `CognitiveModels/FlightBooking.json` and the LUIS language model setup, training, and application configuration steps can be found [here](https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-howto-v4-luis?view=azure-bot-service-4.0&tabs=cs). 35 | 36 | Once you created the LUIS model, update `appsettings.json` with your `LuisAppId`, `LuisAPIKey` and `LuisAPIHostName`. 37 | 38 | ```json 39 | "LuisAppId": "Your LUIS App Id", 40 | "LuisAPIKey": "Your LUIS Subscription key here", 41 | "LuisAPIHostName": "Your LUIS App region here (i.e: westus.api.cognitive.microsoft.com)" 42 | ``` 43 | 44 | ## To try this sample 45 | 46 | - In a terminal, navigate to `ContactInfoBot` 47 | 48 | ```bash 49 | # change into project folder 50 | cd ContactInfoBot 51 | ``` 52 | 53 | - Run the bot from a terminal or from Visual Studio, choose option A or B. 54 | 55 | A) From a terminal 56 | 57 | ```bash 58 | # run the bot 59 | dotnet run 60 | ``` 61 | 62 | B) Or from Visual Studio 63 | 64 | - Launch Visual Studio 65 | - File -> Open -> Project/Solution 66 | - Navigate to `ContactInfoBot` folder 67 | - Select `ContactInfoBot.csproj` file 68 | - Press `F5` to run the project 69 | 70 | ## Testing the bot using Bot Framework Emulator 71 | 72 | [Bot Framework Emulator](https://github.com/microsoft/botframework-emulator) is a desktop application that allows bot developers to test and debug their bots on localhost or running remotely through a tunnel. 73 | 74 | - Install the Bot Framework Emulator version 4.5.0 or greater from [here](https://github.com/Microsoft/BotFramework-Emulator/releases) 75 | 76 | ### Connect to the bot using Bot Framework Emulator 77 | 78 | - Launch Bot Framework Emulator 79 | - File -> Open Bot 80 | - Enter a Bot URL of `http://localhost:3978/api/messages` 81 | 82 | ## Deploy the bot to Azure 83 | 84 | To learn more about deploying a bot to Azure, see [Deploy your bot to Azure](https://aka.ms/azuredeployment) for a complete list of deployment instructions. 85 | 86 | ## Further reading 87 | 88 | - [Bot Framework Documentation](https://docs.botframework.com) 89 | - [Bot Basics](https://docs.microsoft.com/azure/bot-service/bot-builder-basics?view=azure-bot-service-4.0) 90 | - [Dialogs](https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-concept-dialog?view=azure-bot-service-4.0) 91 | - [Gathering Input Using Prompts](https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-prompts?view=azure-bot-service-4.0&tabs=csharp) 92 | - [Activity processing](https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-concept-activity-processing?view=azure-bot-service-4.0) 93 | - [Azure Bot Service Introduction](https://docs.microsoft.com/azure/bot-service/bot-service-overview-introduction?view=azure-bot-service-4.0) 94 | - [Azure Bot Service Documentation](https://docs.microsoft.com/azure/bot-service/?view=azure-bot-service-4.0) 95 | - [.NET Core CLI tools](https://docs.microsoft.com/en-us/dotnet/core/tools/?tabs=netcore2x) 96 | - [Azure CLI](https://docs.microsoft.com/cli/azure/?view=azure-cli-latest) 97 | - [Azure Portal](https://portal.azure.com) 98 | - [Language Understanding using LUIS](https://docs.microsoft.com/en-us/azure/cognitive-services/luis/) 99 | - [Channels and Bot Connector Service](https://docs.microsoft.com/en-us/azure/bot-service/bot-concepts?view=azure-bot-service-4.0) 100 | -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/Startup.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | // 4 | // Generated with Bot Builder V4 SDK Template for Visual Studio CoreBot v4.6.2 5 | 6 | using Microsoft.AspNetCore.Builder; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.AspNetCore.Mvc; 9 | using Microsoft.Bot.Builder; 10 | using Microsoft.Bot.Builder.Integration.AspNet.Core; 11 | using Microsoft.Extensions.DependencyInjection; 12 | 13 | using ContactInfoBot.Bots; 14 | using ContactInfoBot.Dialogs; 15 | using Microsoft.Bot.Builder.AI.Luis; 16 | using Microsoft.Extensions.Configuration; 17 | 18 | namespace ContactInfoBot 19 | { 20 | public class Startup 21 | { 22 | IConfiguration configuration; 23 | 24 | public Startup(IConfiguration configuration) 25 | { 26 | this.configuration = configuration; 27 | } 28 | 29 | // This method gets called by the runtime. Use this method to add services to the container. 30 | public void ConfigureServices(IServiceCollection services) 31 | { 32 | var luisApplication = new LuisApplication( 33 | configuration["LuisAppId"], 34 | configuration["LuisAPIKey"], 35 | configuration["LuisAPIHostName"]); 36 | var recognizerOptions = new LuisRecognizerOptionsV3(luisApplication) 37 | { 38 | PredictionOptions = new Microsoft.Bot.Builder.AI.LuisV3.LuisPredictionOptions 39 | { 40 | IncludeInstanceData = true, 41 | } 42 | }; 43 | 44 | var recognizer = new LuisRecognizer(recognizerOptions); 45 | services.AddSingleton(recognizer); 46 | 47 | services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); 48 | 49 | // Create the Bot Framework Adapter with error handling enabled. 50 | services.AddSingleton(); 51 | 52 | // Create the storage we'll be using for User and Conversation state. (Memory is great for testing purposes.) 53 | services.AddSingleton(); 54 | 55 | // Create the User state. (Used in this bot's Dialog implementation.) 56 | services.AddSingleton(); 57 | 58 | // Create the Conversation state. (Used by the Dialog system itself.) 59 | services.AddSingleton(); 60 | 61 | // Register LUIS recognizer 62 | services.AddSingleton(); 63 | 64 | // Register the BookingDialog. 65 | services.AddSingleton(); 66 | 67 | // The MainDialog that will be run by the bot. 68 | services.AddSingleton(); 69 | 70 | // Create the bot as a transient. In this case the ASP Controller is expecting an IBot. 71 | services.AddTransient>(); 72 | } 73 | 74 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 75 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 76 | { 77 | if (env.IsDevelopment()) 78 | { 79 | app.UseDeveloperExceptionPage(); 80 | } 81 | else 82 | { 83 | app.UseHsts(); 84 | } 85 | 86 | app.UseDefaultFiles(); 87 | app.UseStaticFiles(); 88 | app.UseWebSockets(); 89 | app.UseMvc(); 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /BotFramework4/ContactInfoBot/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "MicrosoftAppId": "", 3 | "MicrosoftAppPassword": "", 4 | "LuisAppId": "", 5 | "LuisAPIKey": "", 6 | "LuisAPIHostName": "" 7 | } 8 | -------------------------------------------------------------------------------- /BotFramework4/PigLatinBot/AdapterWithErrorHandler.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | // 4 | // Generated with Bot Builder V4 SDK Template for Visual Studio CoreBot v4.6.2 5 | 6 | using Microsoft.Bot.Builder.Integration.AspNet.Core; 7 | using Microsoft.Bot.Builder.TraceExtensions; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace PigLatinBot 12 | { 13 | public class AdapterWithErrorHandler : BotFrameworkHttpAdapter 14 | { 15 | public AdapterWithErrorHandler(IConfiguration configuration, ILogger logger) 16 | : base(configuration, logger) 17 | { 18 | OnTurnError = async (turnContext, exception) => 19 | { 20 | // Log any leaked exception from the application. 21 | logger.LogError(exception, $"[OnTurnError] unhandled error : {exception.Message}"); 22 | 23 | // Send a message to the user 24 | await turnContext.SendActivityAsync("The bot encountered an error or bug."); 25 | await turnContext.SendActivityAsync("To continue to run this bot, please fix the bot source code."); 26 | 27 | // Send a trace activity, which will be displayed in the Bot Framework Emulator 28 | await turnContext.TraceActivityAsync("OnTurnError Trace", exception.Message, "https://www.botframework.com/schemas/error", "TurnError"); 29 | }; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /BotFramework4/PigLatinBot/Controllers/BotController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | // 4 | // Generated with Bot Builder V4 SDK Template for Visual Studio EmptyBot v4.6.2 5 | 6 | using System.Threading.Tasks; 7 | using Microsoft.AspNetCore.Mvc; 8 | using Microsoft.Bot.Builder; 9 | using Microsoft.Bot.Builder.Integration.AspNet.Core; 10 | 11 | namespace PigLatinBot.Controllers 12 | { 13 | // This ASP Controller is created to handle a request. Dependency Injection will provide the Adapter and IBot 14 | // implementation at runtime. Multiple different IBot implementations running at different endpoints can be 15 | // achieved by specifying a more specific type for the bot constructor argument. 16 | [Route("api/messages")] 17 | [ApiController] 18 | public class BotController : ControllerBase 19 | { 20 | private readonly IBotFrameworkHttpAdapter Adapter; 21 | private readonly IBot Bot; 22 | 23 | public BotController(IBotFrameworkHttpAdapter adapter, IBot bot) 24 | { 25 | Adapter = adapter; 26 | Bot = bot; 27 | } 28 | 29 | [HttpPost, HttpGet] 30 | public async Task PostAsync() 31 | { 32 | // Delegate the processing of the HTTP POST to the adapter. 33 | // The adapter will invoke the bot. 34 | await Adapter.ProcessAsync(Request, Response, Bot); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /BotFramework4/PigLatinBot/DeploymentTemplates/new-rg-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "groupLocation": { 6 | "value": "" 7 | }, 8 | "groupName": { 9 | "value": "" 10 | }, 11 | "appId": { 12 | "value": "" 13 | }, 14 | "appSecret": { 15 | "value": "" 16 | }, 17 | "botId": { 18 | "value": "" 19 | }, 20 | "botSku": { 21 | "value": "" 22 | }, 23 | "newAppServicePlanName": { 24 | "value": "" 25 | }, 26 | "newAppServicePlanSku": { 27 | "value": { 28 | "name": "S1", 29 | "tier": "Standard", 30 | "size": "S1", 31 | "family": "S", 32 | "capacity": 1 33 | } 34 | }, 35 | "newAppServicePlanLocation": { 36 | "value": "" 37 | }, 38 | "newWebAppName": { 39 | "value": "" 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /BotFramework4/PigLatinBot/DeploymentTemplates/preexisting-rg-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "appId": { 6 | "value": "" 7 | }, 8 | "appSecret": { 9 | "value": "" 10 | }, 11 | "botId": { 12 | "value": "" 13 | }, 14 | "botSku": { 15 | "value": "" 16 | }, 17 | "newAppServicePlanName": { 18 | "value": "" 19 | }, 20 | "newAppServicePlanSku": { 21 | "value": { 22 | "name": "S1", 23 | "tier": "Standard", 24 | "size": "S1", 25 | "family": "S", 26 | "capacity": 1 27 | } 28 | }, 29 | "appServicePlanLocation": { 30 | "value": "" 31 | }, 32 | "existingAppServicePlan": { 33 | "value": "" 34 | }, 35 | "newWebAppName": { 36 | "value": "" 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /BotFramework4/PigLatinBot/IPigLatin.cs: -------------------------------------------------------------------------------- 1 | namespace PigLatinBot 2 | { 3 | public interface IPigLatin 4 | { 5 | string FromEnglish(string text); 6 | } 7 | } -------------------------------------------------------------------------------- /BotFramework4/PigLatinBot/MainBot.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using Microsoft.Bot.Builder; 5 | using Microsoft.Bot.Schema; 6 | 7 | namespace PigLatinBot 8 | { 9 | public class MainBot : ActivityHandler 10 | { 11 | readonly IPigLatin pigLatin; 12 | 13 | public MainBot(IPigLatin pigLatin) 14 | { 15 | this.pigLatin = pigLatin; 16 | } 17 | 18 | protected override async Task OnMembersAddedAsync( 19 | IList membersAdded, ITurnContext turnContext, CancellationToken cancellationToken) 20 | { 21 | foreach (var member in membersAdded) 22 | { 23 | if (member.Id != turnContext.Activity.Recipient.Id) 24 | { 25 | string welcomeText = 26 | $"Hi, I'm Pig Latin Bot. I translate everything " + 27 | $"you say to me into Pig Latin. Check out " + 28 | $"[How to Speak Pig Latin](https://www.wikihow.com/Speak-Pig-Latin) " + 29 | $"for more info."; 30 | await turnContext.SendActivityAsync(MessageFactory.Text(welcomeText), cancellationToken); 31 | } 32 | } 33 | } 34 | 35 | protected override async Task OnMessageActivityAsync( 36 | ITurnContext turnContext, CancellationToken cancellationToken) 37 | { 38 | string translation = pigLatin.FromEnglish(turnContext.Activity.Text); 39 | await turnContext.SendActivityAsync(MessageFactory.Text(translation), cancellationToken); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /BotFramework4/PigLatinBot/PigLatin.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace PigLatinBot 6 | { 7 | public class PigLatin : IPigLatin 8 | { 9 | readonly char[] alphas = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".ToCharArray(); 10 | readonly char[] vowels = "AEIOUaeiou".ToCharArray(); 11 | const string VowelSuffix = "yay"; 12 | const string ConsonantSuffix = "ay"; 13 | 14 | public string FromEnglish(string text) 15 | { 16 | string[] rawWords = text.Split(' '); 17 | 18 | List cleanedWords = 19 | (from word in rawWords 20 | let wordChars = word.ToLower().ToCharArray() 21 | let cleanChars = 22 | (from ch in wordChars 23 | where alphas.Contains(ch) 24 | select ch) 25 | .ToArray() 26 | select new string(cleanChars)) 27 | .ToList(); 28 | 29 | List cookedWords = 30 | (from word in cleanedWords 31 | select ConvertWord(word)) 32 | .ToList(); 33 | 34 | return string.Join(" ", cookedWords); 35 | } 36 | 37 | string ConvertWord(string text) 38 | { 39 | if (string.IsNullOrWhiteSpace(text)) 40 | return string.Empty; 41 | 42 | char[] textChars = text.ToCharArray(); 43 | char firstChar = textChars[0]; 44 | 45 | if (vowels.Contains(firstChar)) 46 | { 47 | return text + VowelSuffix; 48 | } 49 | else 50 | { 51 | int newPrefixSize = textChars.Length > 0 ? textChars.Length - 1 : 0; 52 | var newPrefix = new char[newPrefixSize]; 53 | Array.Copy(textChars, 1, newPrefix, 0, newPrefixSize); 54 | 55 | return new string(newPrefix) + firstChar + ConsonantSuffix; 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /BotFramework4/PigLatinBot/PigLatinBot.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp2.1 5 | latest 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | Always 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /BotFramework4/PigLatinBot/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | // 4 | // Generated with Bot Builder V4 SDK Template for Visual Studio EmptyBot v4.6.2 5 | 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | 9 | namespace PigLatinBot 10 | { 11 | public class Program 12 | { 13 | public static void Main(string[] args) 14 | { 15 | CreateWebHostBuilder(args).Build().Run(); 16 | } 17 | 18 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 19 | WebHost.CreateDefaultBuilder(args) 20 | .UseStartup(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /BotFramework4/PigLatinBot/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:3978", 8 | "sslPort": 0 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | }, 19 | "$safeprojectname$": { 20 | "commandName": "Project", 21 | "launchBrowser": true, 22 | "applicationUrl": "https://localhost:3979;http://localhost:3978", 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BotFramework4/PigLatinBot/README.md: -------------------------------------------------------------------------------- 1 | # PigLatinBot 2 | 3 | Bot Framework v4 empty bot sample. 4 | 5 | This bot has been created using [Bot Framework](https://dev.botframework.com), it shows the minimum code required to build a bot. 6 | 7 | ## Prerequisites 8 | 9 | - [.NET Core SDK](https://dotnet.microsoft.com/download) version 2.1 10 | 11 | ```bash 12 | # determine dotnet version 13 | dotnet --version 14 | ``` 15 | 16 | ## To try this sample 17 | 18 | - In a terminal, navigate to `PigLatinBot` 19 | 20 | ```bash 21 | # change into project folder 22 | cd PigLatinBot 23 | ``` 24 | 25 | - Run the bot from a terminal or from Visual Studio, choose option A or B. 26 | 27 | A) From a terminal 28 | 29 | ```bash 30 | # run the bot 31 | dotnet run 32 | ``` 33 | 34 | B) Or from Visual Studio 35 | 36 | - Launch Visual Studio 37 | - File -> Open -> Project/Solution 38 | - Navigate to `PigLatinBot` folder 39 | - Select `PigLatinBot.csproj` file 40 | - Press `F5` to run the project 41 | 42 | ## Testing the bot using Bot Framework Emulator 43 | 44 | [Bot Framework Emulator](https://github.com/microsoft/botframework-emulator) is a desktop application that allows bot developers to test and debug their bots on localhost or running remotely through a tunnel. 45 | 46 | - Install the Bot Framework Emulator version 4.3.0 or greater from [here](https://github.com/Microsoft/BotFramework-Emulator/releases) 47 | 48 | ### Connect to the bot using Bot Framework Emulator 49 | 50 | - Launch Bot Framework Emulator 51 | - File -> Open Bot 52 | - Enter a Bot URL of `http://localhost:3978/api/messages` 53 | 54 | ## Deploy the bot to Azure 55 | 56 | To learn more about deploying a bot to Azure, see [Deploy your bot to Azure](https://aka.ms/azuredeployment) for a complete list of deployment instructions. 57 | 58 | ## Further reading 59 | 60 | - [Bot Framework Documentation](https://docs.botframework.com) 61 | - [Bot Basics](https://docs.microsoft.com/azure/bot-service/bot-builder-basics?view=azure-bot-service-4.0) 62 | - [Activity processing](https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-concept-activity-processing?view=azure-bot-service-4.0) 63 | - [Azure Bot Service Introduction](https://docs.microsoft.com/azure/bot-service/bot-service-overview-introduction?view=azure-bot-service-4.0) 64 | - [Azure Bot Service Documentation](https://docs.microsoft.com/azure/bot-service/?view=azure-bot-service-4.0) 65 | - [.NET Core CLI tools](https://docs.microsoft.com/en-us/dotnet/core/tools/?tabs=netcore2x) 66 | - [Azure CLI](https://docs.microsoft.com/cli/azure/?view=azure-cli-latest) 67 | - [Azure Portal](https://portal.azure.com) 68 | - [Language Understanding using LUIS](https://docs.microsoft.com/en-us/azure/cognitive-services/luis/) 69 | - [Channels and Bot Connector Service](https://docs.microsoft.com/en-us/azure/bot-service/bot-concepts?view=azure-bot-service-4.0) 70 | -------------------------------------------------------------------------------- /BotFramework4/PigLatinBot/Startup.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | // 4 | // Generated with Bot Builder V4 SDK Template for Visual Studio EmptyBot v4.6.2 5 | 6 | using Microsoft.AspNetCore.Builder; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.AspNetCore.Mvc; 9 | using Microsoft.Bot.Builder; 10 | using Microsoft.Bot.Builder.Integration.AspNet.Core; 11 | using Microsoft.Extensions.Configuration; 12 | using Microsoft.Extensions.DependencyInjection; 13 | 14 | namespace PigLatinBot 15 | { 16 | public class Startup 17 | { 18 | public Startup(IConfiguration configuration) 19 | { 20 | Configuration = configuration; 21 | } 22 | 23 | public IConfiguration Configuration { get; } 24 | 25 | // This method gets called by the runtime. Use this method to add services to the container. 26 | public void ConfigureServices(IServiceCollection services) 27 | { 28 | services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); 29 | 30 | // Create the Bot Framework Adapter with error handling enabled. 31 | services.AddSingleton(); 32 | 33 | // Create the bot as a transient. In this case the ASP Controller is expecting an IBot. 34 | services.AddTransient(); 35 | 36 | services.AddTransient(); 37 | } 38 | 39 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 40 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 41 | { 42 | if (env.IsDevelopment()) 43 | { 44 | app.UseDeveloperExceptionPage(); 45 | } 46 | else 47 | { 48 | app.UseHsts(); 49 | } 50 | 51 | app.UseDefaultFiles(); 52 | app.UseStaticFiles(); 53 | app.UseWebSockets(); 54 | app.UseMvc(); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /BotFramework4/PigLatinBot/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /BotFramework4/PigLatinBot/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "MicrosoftAppId": "", 3 | "MicrosoftAppPassword": "" 4 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BotDemos 2 | 3 | This is where I'm putting any demo code for bots created via the [Microsoft Bot Framework](https://dev.botframework.com/). 4 | 5 | ## Pig Latin Bot 6 | 7 | This is a bare-bones bot that translates English to Pig Latin. The bot will reply with whatever you type, translated to Pig Latin. 8 | 9 | > Note: Also contains an example of how to use the WebChat control. 10 | 11 | ## PC Bot 12 | 13 | Demonstrates how to handle various Bot Framework Activities. 14 | 15 | ## Bug Dialog Bot 16 | 17 | Shows how to use Bot Builder dialogs. 18 | 19 | ## Bug FormFlow Bot #1 20 | 21 | Has a very basic FormFlow example. 22 | 23 | ## Bug FormFlow Bot #2 24 | 25 | Implements dynamic fields in FormFlow (e.g. selection based on updatable data). Several other FormFlow customizations with attributes and more. 26 | 27 | ## Contact Info Bot 28 | 29 | Uses LUIS for natural language understanding. 30 | 31 | ## LINQ to Twitter FAQ 32 | 33 | Shows how to use QnA Maker --------------------------------------------------------------------------------