private async Task LaunchWelcomeAsync(ITurnContext turnContext) { var message = string.Empty; DateTime currentDateTime = DateTimeHelper.GetCustomTimeZone(); if (currentDateTime.Hour >= 6) { message = "Hello, good morning!"; } if (currentDateTime.Hour >= 12) { message = "Hello, good afternoon!"; } if ((currentDateTime.Hour >= 0 && currentDateTime.Hour < 6) || currentDateTime.Hour >= 18) { message = "Hello, good evening!"; } await turnContext.SendCustomResponseAsync(message); message = $"In Microsoft we believe in what people make possible, our mission is to empower every person and every organization on the planet to achieve more"; await turnContext.SendCustomResponseAsync(message); message = $"I am a trained digital assistant from Microsoft trained to demonstrate how to work with LUIS and QnA simultaneously"; await turnContext.SendCustomResponseAsync(message); }
private async Task LaunchWelcomeAsync(ITurnContext turnContext) { var message = string.Empty; message = $"Hello stranger!, in Microsoft we believe in what people make possible, our mission is to empower every person and every organization on the planet to achieve more"; await turnContext.SendCustomResponseAsync(message); message = $"I am a digital assistant from Microsoft, trained to demonstrate how to work with intelligent experiences with Bot Builder V4"; await turnContext.SendCustomResponseAsync(message); }
private async Task LaunchWelcomeAsync(ITurnContext turnContext) { var message = string.Empty; message = QNABotSettings.welcomemessage; await turnContext.SendCustomResponseAsync(message); await turnContext.SendActivityAsync($"Hi there user ID - {turnContext.Activity.From.Id}. Name - {turnContext.Activity.From.Name}. "); }
public override async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken) { if (turnContext == null) { throw new ArgumentNullException(nameof(turnContext)); } var dialogContext = await dialogs.CreateContextAsync(turnContext, cancellationToken : cancellationToken); switch (turnContext.Activity.Type) { case ActivityTypes.ConversationUpdate: if (turnContext.Activity.MembersAdded.FirstOrDefault()?.Id == turnContext.Activity.Recipient.Id) { // begin: token validation bool hasPermission = true; //await activeDirectoryService.ValidateTokenAsync(turnContext, activeDirectoryService.GetConfiguration().ValidAudience, activeDirectoryService.GetConfiguration().ValidIssuer, true); if (!hasPermission) { var message = string.Empty; message = $"Ooops!! it seems you don't have permission to talk with me"; await turnContext.SendCustomResponseAsync(message); return; } // end: token validation await LaunchWelcomeAsync(turnContext); await dialogContext.BeginDialogAsync(nameof(MainDialog), null, cancellationToken : cancellationToken); } break; case ActivityTypes.Message: var results = await dialogContext.ContinueDialogAsync(cancellationToken); var text = turnContext.Activity.Text; if (text == "/start") { await this.accessor.AskForExamplePreference.DeleteAsync(turnContext); await this.accessor.ConversationDialogState.DeleteAsync(turnContext); await this.accessor.IsAuthenticatedPreference.DeleteAsync(turnContext); await this.luisRouterService.TokenPreference.DeleteAsync(turnContext); await dialogContext.EndDialogAsync(); await dialogContext.BeginDialogAsync(nameof(MainDialog), null, cancellationToken); } else { if (!dialogContext.Context.Responded) { bool isAuthenticated = await this.accessor.IsAuthenticatedPreference.GetAsync(turnContext, () => { return(false); }); if (!isAuthenticated) { await dialogContext.BeginDialogAsync(nameof(MainDialog), null, cancellationToken); } else { await dialogContext.BeginDialogAsync(nameof(LuisQnADialog), null, cancellationToken); } } } break; } // Save any state changes that might have occured during the turn. await this.conversationState.SaveChangesAsync(turnContext, false, cancellationToken); await this.userState.SaveChangesAsync(turnContext, false, cancellationToken); }