private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var activity = await result as Activity;

            await context.PostAsync("You chose : " + activity.Text + ".\nJust a minute. ");

            responseObject.ToFind         = activity.Text;
            responseObject.RetreivedValue = "";

            AzureDataClient.GetAzureResponse(responseObject, "azuredialog");

            if (responseObject.RetreivedValue == "")
            {
                await context.PostAsync("The " + FormattedToFind + " of " + FormattedLob + " is not found. Please retry.");
            }
            else
            {
                int ValuePosition;
                FormattedToFind         = activity.Text;
                ValuePosition           = responseObject.RetreivedValue.IndexOf(':');
                FormattedRetreivedValue = responseObject.RetreivedValue.Substring(0, ValuePosition);

                await context.PostAsync("The " + FormattedToFind + " of " + FormattedLob + " is " + FormattedRetreivedValue);;


                foreach (string attributeToMail in RootDialog.AttributesToMail)
                {
                    if (activity.Text.Contains(attributeToMail))
                    {
                        context.Call(new SendMailDialog(responseObject), AfterMailDeciderAsync);
                        return;
                    }
                }
            }


            await AfterMailDeciderAsync(context, result);
        }
Esempio n. 2
0
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var activity = await result as Activity;

            responseObject.UserQuery = activity.Text;

            var RedirectTo = activity.Text.Split(' ').Skip(0).FirstOrDefault();
            var SecondWord = activity.Text.Split(' ').Skip(0).FirstOrDefault();
            var response   = "";

            RedirectTo = "Azure";


            foreach (string greet in Greetings)
            {
                if (activity.Text.ToLower().Contains(greet))
                {
                    response   = "Welcome! Ask me any question and I'll fetch it for you!\nExamples:\n* Get replytime of OEM systems.\n* Get responsetime of Health department.\n* Request Database Access\n* Use OEM system";
                    response  += "\nAt any time type HELP to access the guidelines in case you are stuck somewhere :)";
                    RedirectTo = "Greet";
                    break;
                }
            }

            if (activity.Text.ToLower().Contains("request") && activity.Text.ToLower().Contains("access"))
            {
                RedirectTo = "Request";
                context.Call <object>(new DatabaseRequestDialog(), MessageReceivedAsync2);
                return;
            }

            if (RedirectTo == Constants.QA)
            {
                QnAResponseObject QnAResponse = await QnADataClient.GetQnAResponse(responseObject.UserQuery);

                if (QnAResponse.answers[0].score < 50)
                {
                    RedirectTo = Constants.Azure;
                }
                else
                {
                    response = QnAResponse.answers[0].answer;
                }
            }

            else if (RedirectTo == Constants.Azure)
            {
                responseObject.SystemObject = AzureDataClient.GetSystemSelected(responseObject.UserQuery);
                if (responseObject.SystemObject == null)
                {
                    await context.PostAsync("nulll af");
                }

                if (SecondWord.ToLower().Equals("use"))
                {
                    context.Call <object>(new AzureSystemSelectedDialog(responseObject), MessageReceivedAsync2);
                    return;
                }
                else
                {
                    AzureDataClient.GetAzureResponse(responseObject, "RootDialog");
                    if (responseObject.RetreivedValue.Equals(""))
                    {
                        context.Call(new AzureSystemSelectedDialog(responseObject), MessageReceivedAsync2);
                        return;
                    }
                    else
                    {
                        int ValuePosition;
                        FormattedLob            = responseObject.SystemObject.Lob.Substring(0, responseObject.SystemObject.Lob.Length - 2);
                        FormattedToFind         = responseObject.ToFind;
                        ValuePosition           = responseObject.RetreivedValue.IndexOf(':');
                        FormattedRetreivedValue = responseObject.RetreivedValue.Substring(0, ValuePosition);

                        await context.PostAsync("The " + FormattedToFind + " of " + FormattedLob + " is " + FormattedRetreivedValue);

                        foreach (string attributeToMail in AttributesToMail)
                        {
                            if (activity.Text.Contains(attributeToMail))
                            {
                                context.Call <object>(new SendMailDialog(responseObject), MessageReceivedAsync2);
                                return;
                            }
                        }
                    }
                }
            }

            if (RedirectTo != Constants.QA && RedirectTo != Constants.Azure && RedirectTo != "Greet")
            {
                response = "Not able to retreive the information. Rephrase your question.\nAt any time type HELP to access the guidelines in case you are stuck somewhere :)";
            }

            if (RedirectTo == "Greet" || RedirectTo == Constants.QA)
            {
                await context.PostAsync(response);
            }
            context.Wait(MessageReceivedAsync);
        }