コード例 #1
0
 public async Task ListOrders(IDialogContext context, IAwaitable <IMessageActivity> message, LuisResult result)
 {
     if (!await CheckForWelcome(context, message))
     {
         var messageToForward = await message;
         await context.Forward(new ListOrdersDialog(), AfterDialog, messageToForward, CancellationToken.None);
     }
 }
コード例 #2
0
        public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            var message = await result;

            if (message.Text.ToLower().Contains("register"))
            {
                await context.Forward(new UserDialog(), this.ResumeAfterUserDialog, message, CancellationToken.None);
            }
            else if (message.Text.ToLower().Contains("statistic"))
            {
                context.Call(new LuisDialogClass(), this.ResumeAfterStatisticDialog);
            }
            else
            {
                await context.Forward(new HelpDialog(), this.ResumeAfterHelpDialog, message, CancellationToken.None);
            }
        }
コード例 #3
0
        public async Task NoneIntent(IDialogContext context, IAwaitable <IMessageActivity> message, LuisResult result)
        {
            var activity       = await message as IMessageActivity;
            var translatedText = await Translation.TranslateToEnglish(activity.Text);

            activity.Text = translatedText;
            await context.Forward(new CustomQnADialog(), ResumeAfterQnADialog, activity, CancellationToken.None);
        }
コード例 #4
0
        /// <summary>
        /// Takes the users technology selection and forwards it to the QnA dialog to answer a question
        /// </summary>
        /// <param name="context"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        private async Task AfterTechnologySelectedAsync(IDialogContext context, IAwaitable <string> result)
        {
            var selection = await result;
            IMessageActivity messageActivity = Activity.CreateMessageActivity();

            messageActivity.Text = selection;
            await context.Forward(new QnADialog(), AfterChildDialogFinished, messageActivity);
        }
コード例 #5
0
        private async Task QnaMakerTask(IDialogContext context, bool ask)
        {
            var qnadialog        = new QnaIscoSistemas(ask);
            var messageToForward = context.Activity;
            var cts = new CancellationTokenSource();

            await context.Forward(qnadialog, AfterQnADialog, messageToForward, cts.Token);
        }
コード例 #6
0
        public async Task BookRoom(IDialogContext context, LuisResult result)
        {
            await context.Forward(new RootDialog(), this.ResumeAfterBookingDialog, "đặt phòng", CancellationToken.None);

            await context.PostAsync("Vui lòng gõ \"đặt phòng\" lần nữa");

            //context.Call(reservationDialog, );
        }
コード例 #7
0
        public async Task ProcessChoiceAsync(IDialogContext context, IAwaitable <IMessageActivity> argument)
        {
            var chosenUser = await argument;

            var user = await CVPartnerService.Instance.GetUser(chosenUser.Text);

            await context.Forward(new ContactDialog(), ResumeAfterDialog, user, CancellationToken.None);
        }
コード例 #8
0
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var baseInterfaceType = typeof(ITool);
            var botCommands       = Assembly.GetAssembly(baseInterfaceType)
                                    .GetTypes()
                                    .Where(types => types.IsClass && !types.IsAbstract && types.GetInterface("ITool") != null);

            foreach (var botCommand in botCommands)
            {
                _tools.Add((ITool)Activator.CreateInstance(botCommand));
            }

            var activity = await result as Activity;
            var user     = DataModel.RememberUser(activity);

            if (!String.IsNullOrEmpty(activity?.Text))
            {
                var str          = activity.Text.Trim();
                var indexOfSpace = str.IndexOf(" ", StringComparison.Ordinal);
                var command      = indexOfSpace != -1 ? str.Substring(0, indexOfSpace).ToLower() : str.ToLower();
                if (command[0] != '/')
                {
                    command = "/" + command;
                }

                var tool = _tools.FirstOrDefault(x => x.CommandsName.Any(y => y.Equals(command)));
                if (tool != null)
                {
                    activity.Text = indexOfSpace >= 0 ? activity.Text.Substring(indexOfSpace, str.Length - indexOfSpace) : String.Empty;
                    var typeOfDialog = tool.GetType();
                    var newTool      = Activator.CreateInstance(typeOfDialog);
                    if (user == null || (!user.IsAdmin && ((ITool)newTool).IsAdmin))
                    {
                        await context.Forward(new Help(), ResumeAfterNewOrderDialog, activity, CancellationToken.None);

                        return;
                    }
                    await context.Forward((IDialog <object>) newTool, ResumeAfterNewOrderDialog, activity, CancellationToken.None);
                }
                else
                {
                    await context.Forward(new Help(), ResumeAfterNewOrderDialog, activity, CancellationToken.None);
                }
            }
        }
コード例 #9
0
        private async Task ResumeAfterSurveyTypePrompt(IDialogContext context, IAwaitable <string> result)
        {
            var msg = context.MakeMessage();

            msg.Type = ActivityTypes.Typing;

            var choice = await result;
            await context.Forward(new SurveyDialog(), this.SurveyDialogResumeAfter, choice, CancellationToken.None);
        }
コード例 #10
0
        public async Task ResumeAfterSelectRootDialog(IDialogContext context, IAwaitable <object> result)
        {
            // Store the value that DiscoverSomethingDialog returned.
            // (At this point, new order dialog has finished and returned some value to use within the root dialog.)
            var resultFromSelectInterestsDialog = await result as Activity;

            // Chama o diálogo para selecionar o diálogo inicial novamente, pois foi solicitado um cancelar
            await context.Forward(new RootDialog(), null, resultFromSelectInterestsDialog, CancellationToken.None);
        }
コード例 #11
0
        /// <summary>
        /// Forwards to BotAuth login dialog.
        /// </summary>
        /// <param name="tenantUrl">The tenant URL.</param>
        /// <param name="context">The context.</param>
        /// <param name="message">The message.</param>
        /// <param name="loginCallBack">The login call back.</param>
        /// <returns></returns>
        public async Task ForwardToBotAuthLoginDialog(string tenantUrl, IDialogContext context, IMessageActivity message, ResumeAfter <AuthResult> loginCallBack)
        {
            var options = GetDefaultOffice365Options();

            options.RedirectUrl = ConfigurationManager.AppSettings["aad:Callback"];
            options.ResourceId  = tenantUrl;

            await context.Forward(new AuthDialog(new ADALAuthProvider(), options), loginCallBack, message, CancellationToken.None);
        }
コード例 #12
0
        public async Task Joke(IDialogContext context, LuisResult result)
        {
            // confirm we hit joke intent
            string message = $"Let's see...I know a good joke...";

            await context.PostAsync(message);

            await context.Forward(new JokeDialog(), ResumeAfterJokeDialog, context.Activity, CancellationToken.None);
        }
コード例 #13
0
        public async Task TeamOverTimes(IDialogContext context, IActivity activity)
        {
            var response = await this.authenticateUser.GetUserInfo(context);

            if (!string.IsNullOrWhiteSpace(response?.JsessionID) && !string.IsNullOrWhiteSpace(response?.PersonNumber))
            {
                await context.Forward(this.dialogFactory.CreateLogonResponseDialog <TeamOvertimesDialog>(response), this.Complete, ((Activity)activity).Name, default(CancellationToken));
            }
        }
コード例 #14
0
        public virtual async Task Run(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            var activity = await result as Activity;

            if (activity?.Conversation != null)
            {
                await context.Forward(MakeInterviewDialog(), ResumeAfterNewDialog, activity, CancellationToken.None);
            }
        }
コード例 #15
0
        private async Task CasaSelection(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            var casaId = await result;

            StateHelper.SetUserCasa(context, casaId.Text);

            var casaDialog = new CasaDialog();
            await context.Forward(casaDialog, Resume, new Activity { Text = "CasaDialog" }, CancellationToken.None);
        }
コード例 #16
0
ファイル: BasicLuisDialog.cs プロジェクト: shijov4c/Bot
        public async Task QnAIntent(IDialogContext context, IAwaitable <IMessageActivity> message, LuisResult result)
        {
            var msg              = await message;
            var faqDialog        = new BasicQnAMakerDialog();
            var messageToForward = await message;
            await context.Forward(faqDialog, AfterFAQDialog, messageToForward, CancellationToken.None);

            context.Wait(MessageReceived);
        }
コード例 #17
0
ファイル: BasicLuisDialog.cs プロジェクト: shijov4c/Bot
        public async Task NoneIntent(IDialogContext context, IAwaitable <IMessageActivity> message, LuisResult result)
        {
            var msg = await message;

            //await context.PostAsync(context.);
            await context.Forward(new SearchDialog(), ResumeAfterSearchDialog, msg, CancellationToken.None);

            context.Wait(MessageReceived);
        }
コード例 #18
0
        private async Task ProcessNeedOrFeatureAsync(IDialogContext context, LuisResult luisResult)
        {
            EKeywords keywords = CheckForKeywords(luisResult);
            var       msg      = context.MakeMessage();
            string    text     = luisResult.AlteredQuery != null ? luisResult.AlteredQuery : luisResult.Query;

            if (CommonDialog.debugMessages)
            {
                await context.PostAsync("DEBUG : Beginning of ProcessNeedOrFeatureAsync() method");
            }
            if (CommonDialog.debugMessages)
            {
                await context.PostAsync("DEBUG : Text received = " + text);
            }
            context.ConversationData.RemoveValue(BotConstants.SELECTED_BRANDS_KEY);
            if (EKeywords.ShowMeAll == keywords)
            {
                if (CommonDialog.debugMessages)
                {
                    await context.PostAsync("DEBUG : found one keyword, it is " + "Show Me All");
                }
                decoder.FeatureOrNeedDesc = "Show Me All";
                context.Done(decoder);
                return;
            }
            else if (EKeywords.StartAgain == keywords)
            {
                if (CommonDialog.debugMessages)
                {
                    await context.PostAsync("DEBUG : Found one keyword, it is " + "Start Again");
                }
                decoder.FeatureOrNeedDesc = "Start Again";
                context.Done(decoder);
                return;
            }
            res      = luisResult;
            msg.Text = text;
            if (CommonDialog.debugMessages)
            {
                await context.PostAsync("DEBUG : Forwarding it to Luis needs...");
            }
            try
            {
                await context.Forward(new NodeLuisSubsNeeds(), ProcessLuisNeedsResult, msg, CancellationToken.None);
            }
            catch (Exception xception)
            {
                if (CommonDialog.debugMessages)
                {
                    await context.PostAsync("DEBUG : Error...failure to forward to LUIS Subscriber needs node, xception message = " + xception.Message);
                }
            }
            if (CommonDialog.debugMessages)
            {
                await context.PostAsync("DEBUG : End of ProcessNeedOrFeatureAsync()");
            }
        }
コード例 #19
0
        public async Task NextVacation(IDialogContext context, IActivity activity)
        {
            var response = await this.authenticateUser.GetUserInfo(context);

            if (!string.IsNullOrWhiteSpace(response.JsessionID) && !string.IsNullOrWhiteSpace(response.PersonNumber))
            {
                await context.Forward(this.dialogFactory.CreateLogonResponseDialog <ViewTimeOffRequestsDialog>(response), this.Complete, response.JsessionID, default(CancellationToken));
            }
        }
コード例 #20
0
        public async Task QnA(IDialogContext context, LuisResult result)
        {
            // confirm we hit QnA
            string message = $"Routing to QnA... ";
            await context.PostAsync(message);

            var userQuestion = (context.Activity as Activity).Text;
            await context.Forward(new QnaDialog(), ResumeAfterQnA, context.Activity, CancellationToken.None);
        }
コード例 #21
0
        public async Task SupervisorViewTimeOffRequests(IDialogContext context, LuisResult result)
        {
            var response = await this.authenticateUser.GetUserInfo(context);

            if (!string.IsNullOrWhiteSpace(response?.JsessionID) && !string.IsNullOrWhiteSpace(response?.PersonNumber))
            {
                await context.Forward(this.dialogFactory.CreateLogonResponseDialog <SupervisorViewTimeoff.SupervisorViewTimeOffDialog>(response), this.Complete, response.JsessionID, default(CancellationToken));
            }
        }
コード例 #22
0
        public async Task SelectDialog(IDialogContext context, IAwaitable <IMessageActivity> messageActivity, LuisResult result)
        {
            var message = await messageActivity;

            if (result.TryFindEntity(EntityProducts, out var _))
            {
                await context.Forward(new ProductDialog(), ResumeAfterProductDialog, message, CancellationToken.None);
            }
            else if (result.TryFindEntity(EntityBasket, out var _))
            {
                await context.Forward(new ManageBasketDialog(), ResumeAfterManageBasketDialog, message,
                                      CancellationToken.None);
            }
            else if (result.TryFindEntity(EntityCheckout, out var _))
            {
                await context.Forward(new CheckoutDialog(), ResumeAfterCheckoutDialog, message, CancellationToken.None);
            }
        }
コード例 #23
0
        public async Task None(IDialogContext context, LuisResult result)
        {
            //You COULD put a message in here... but we handle it in QnA maker
            //string message = $"Sorry, I did not understand '{result.Query}'. Type 'help' if you need assistance.";
            //await context.PostAsync(message);

            // You can forward to QnA Dialog, and let Qna Maker handle the user's query if no intent is found
            await context.Forward(new BotQnaDialog(), ResumeAfterQnaDialog, context.Activity, CancellationToken.None);
        }
コード例 #24
0
ファイル: ProcessCommands.cs プロジェクト: branc116/OQPY
        internal async static Task <IEnumerable <Attachment> > BaseSignIn(IDialogContext context, string arg2)
        {
            var mess = context.MakeMessage();

            mess.Text = "login";
            await context.Forward(SimpleFacebookAuthDialog.dialog, ProcessSignIn, mess, default(CancellationToken));

            return(null);
        }
コード例 #25
0
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            IMessageActivity message = await result;

            await context.Forward(Helper.CreateGetTokenDialog(_connectionName),
                                  AfterGetToken,
                                  message,
                                  CancellationToken.None);
        }
コード例 #26
0
 public async Task None(IDialogContext context, IAwaitable <IMessageActivity> activity, LuisResult result)
 {
     //Récupération du message
     var messageToForward = await activity;
     var cts = new CancellationTokenSource();
     var faq = new QnaDialog();
     //Transfert du message une fois réponse retournée => AfterFAQDialog
     await context.Forward(faq, AfterFAQDialog, messageToForward, CancellationToken.None);
 }
コード例 #27
0
        /// <summary>
        ///     This is the default handler for any message recieved from the user, we will start by using QnAMaker
        /// </summary>
        /// <param name="context">The current chat context</param>
        /// <param name="result">The IAwaitable result</param>
        /// <returns></returns>
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var activity = await result as Activity;

            try
            {
                // if the activity has a Value populated then it is the json from our adaptive card
                if (activity.Value != null)
                {
                    // parse the value field from our activity, this will be populated with the "data" field from our
                    // adaptive card json if the user clicked the card's button, it will be an empty {{}}
                    // if our json did not define a "data" field
                    JToken valueToken  = JObject.Parse(activity.Value.ToString());
                    string actionValue = valueToken.SelectToken("action") != null?valueToken.SelectToken("action").ToString() : string.Empty;

                    if (!string.IsNullOrEmpty(actionValue))
                    {
                        switch (valueToken.SelectToken("action").ToString())
                        {
                        case "jokes":
                            context.Call(new KnockKnockJokeDialog(), AfterJokeOrTrivia);
                            break;

                        case "trivia":
                            context.Call(new TriviaRichCardDialog(), AfterJokeOrTrivia);
                            break;

                        default:
                            await context.PostAsync($"I don't know how to handle the action \"{actionValue}\"");

                            context.Wait(MessageReceivedAsync);
                            break;
                        }
                    }
                    else
                    {
                        await context.PostAsync("It looks like no \"data\" was defined for this. Check your adaptive cards json definition.");

                        context.Wait(MessageReceivedAsync);
                    }
                }
                else
                {
                    // try QnAMaker first with a tolerance of 50% match to try to catch a lot of different phrasings
                    // the higher the tolerance the more closely the users text must match the questions in QnAMaker
                    await context.Forward(new QnADialog(50), AfterQnA, activity, CancellationToken.None);
                }
            }
            catch (Exception e)
            {
                // if an error occured with QnAMaker post it out to the user
                await context.PostAsync(e.Message);

                // wait for the next message
                context.Wait(MessageReceivedAsync);
            }
        }
コード例 #28
0
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var activity = await result as Activity;

            QnADialog dialog = new QnADialog();

            dialog.originalQuestion = activity.Text;
            await context.Forward(dialog, AfterQnADialog, activity, CancellationToken.None);
        }
コード例 #29
0
        public async Task ResumeAfterInfosBasicDialog(IDialogContext context, IAwaitable <object> result)
        {
            // Store the value that DiscoverSomethingDialog returned.
            // (At this point, new order dialog has finished and returned some value to use within the root dialog.)
            var resultFromSelectInterestsDialog = await result as Activity;

            // Chama o diálogo de Informações Básicas novamente, pois foi solicitado um cancelar
            await context.Forward(new InfosBasicDialog(loginUser), this.ResumeAfterInfosBasicDialog, resultFromSelectInterestsDialog, CancellationToken.None);
        }
コード例 #30
0
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var activity = await result as IMessageActivity;

            // TODO: Put logic for handling user message here
            await context.Forward(new LuisDialog(), ResumeAftelLuisDialog, activity, CancellationToken.None);

            context.Wait(MessageReceivedAsync);
        }