public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var profiles     = ProfileService.GetProfiles();
            var patternCards = ProfileService.GetAllPatternCards();
            var profileCards = ProfileService.GetAllProfileCards();

            var patternParents = patternCards.Select(a => a.Paths.ParentPath).Distinct().Count();
            var profileParents = profileCards.Select(a => a.Paths.ParentPath).Distinct().Count();

            var profilesWithoutPatterns = profiles.Count - patternParents;
            var profilesWithoutProfiles = profiles.Count - profileParents;

            var itemList = new List <ListItem>
            {
                new ListItem(string.Format(Translator.Text("Chat.Intents.SetupPersonalization.CreateProfile"))),     // profile
                new ListItem(string.Format(Translator.Text("Chat.Intents.SetupPersonalization.CreatePatternCard"))), // pattern card
                new ListItem(string.Format(Translator.Text("Chat.Intents.SetupPersonalization.CreateProfileCard"))), // profile card
                new ListItem(Translator.Text("Chat.Intents.SetupPersonalization.AssignProfileCard")),                // add profile card to page or search action
                new ListItem(string.Format(Translator.Text("Chat.Intents.SetupPersonalization.CreateGoal"))),
                new ListItem(Translator.Text("Chat.Intents.SetupPersonalization.AssignGoal"))
            };
            var intentList = IntentInputFactory.Create(IntentInputType.LinkList, itemList);

            return(ConversationResponseFactory.Create(KeyName, Translator.Text("Chat.Intents.SetupPersonalization.ToSetup"), true, intentList));
        }
Ejemplo n.º 2
0
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var name   = (string)conversation.Data[NameKey].Value;
            var points = (int)conversation.Data[PointsKey].Value;
            //var isFailure = (bool) conversation.Data[IsFailureKey];

            var fields = new Dictionary <ID, string>
            {
                { new ID("{AC3BC9B6-46A2-4EAD-AF5E-6BDB532EB832}"), "1" },                      // IsGoal
                // { new ID("{BD5D2A52-027F-4CC8-9606-C5CE6CBBF437}"), isFailure ? "1" : "" },  // IsFailure
                // { new ID("{71EBDEBD-9560-48C6-A66F-E17FC018232C}"), "" },                    // Rule
                { new ID("{AC6BA888-4213-43BD-B787-D8DA2B6B881F}"), name },                     // Name
                { new ID("{33AE0E84-74A0-437F-AB2B-859DFA96F6C9}"), points.ToString() },        // Points
                { Sitecore.FieldIDs.WorkflowState, "{EDCBB550-BED3-490F-82B8-7B2F14CCD26E}" },  // workflow state
                { Sitecore.FieldIDs.Workflow, "{689E2994-4656-4C58-9112-7826CB46EE69}" }        // workflow
            };

            //create goal and folder if needed
            var fromDb      = "master";
            var toDb        = DataWrapper.GetDatabase("web");
            var goalItem    = DataWrapper.GetItemById(Constants.ItemIds.GoalNodeId, fromDb);
            var newGoalItem = DataWrapper.CreateItem(goalItem.ID, Constants.TemplateIds.GoalTemplateId, fromDb, name, fields);

            PublishWrapper.PublishItem(goalItem, new[] { toDb }, new[] { DataWrapper.ContentLanguage }, true, false, false);

            return(ConversationResponseFactory.Create(KeyName, string.Format(Translator.Text("Chat.Intents.CreateGoal.Response"), name)));
        }
Ejemplo n.º 3
0
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var toDb      = (Database)conversation.Data[DBKey].Value;
            var rootItem  = (Item)conversation.Data[ItemKey].Value;
            var langItem  = (Language)conversation.Data[LangKey].Value;
            var recursion = (bool)conversation.Data[RecursionKey].Value;
            var related   = (bool)conversation.Data[RelatedKey].Value;

            PublishWrapper.PublishItem(rootItem, new[] { toDb }, new[] { langItem }, recursion, false, related);

            var recursionMessage = recursion
                ? Translator.Text("Chat.Intents.Publish.ResponseRecursion")
                : string.Empty;

            var relatedMessage = related
                ? Translator.Text("Chat.Intents.Publish.ResponseRelated")
                : string.Empty;

            return(ConversationResponseFactory.Create(KeyName, string.Format(
                                                          Translator.Text("Chat.Intents.Publish.Response"),
                                                          rootItem.DisplayName,
                                                          toDb.Name,
                                                          LanguageManager.GetLanguageItem(langItem, toDb).DisplayName,
                                                          recursionMessage,
                                                          relatedMessage)));
        }
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var name           = (string)conversation.Data[NameKey].Value;
            var profileItem    = (Item)conversation.Data[ProfileItemKey].Value;
            var profileKeyData = (Dictionary <string, string>)conversation.Data[ProfileKeyValuesKey].Value;
            var keys           = ProfileService.GetProfileKeys(profileItem);

            // profile card value field
            var profileCardValue = ProfileService.GetTrackingFieldValue(profileItem, profileKeyData);

            var fields = new Dictionary <ID, string>
            {
                { Constants.FieldIds.PatternCard.NameFieldId, name },
                { Constants.FieldIds.ProfileCard.ProfileCardValueFieldId, profileCardValue }
            };

            //create pattern card
            var profileCardFolder = profileItem.Axes.GetChild("Profile Cards");
            var newProfileItem    = DataWrapper.CreateItem(profileCardFolder.ID, Constants.TemplateIds.ProfileCardTemplateId, parameters.Database, name, fields);

            var toDb = DataWrapper.GetDatabase("web");

            PublishWrapper.PublishItem(newProfileItem, new[] { toDb }, new[] { DataWrapper.ContentLanguage }, true, false, false);

            return(ConversationResponseFactory.Create(KeyName, string.Format(
                                                          Translator.Text("Chat.Intents.CreateProfileCard.Response"),
                                                          profileItem.DisplayName)));
        }
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var message = "Hmmm. I'm not sure so I've looked up some possible answers for you";

            var path = Context.Server.MapPath("~/sitecore/shell/sitecore.version.xml");

            if (!File.Exists(path))
            {
                return(ConversationResponseFactory.Create(KeyName, string.Empty));
            }

            string    xmlText = File.ReadAllText(path);
            XDocument xdoc    = XDocument.Parse(xmlText);

            var version = xdoc.Descendants("version").First();
            var major   = version.Descendants("major").First().Value;
            var minor   = version.Descendants("minor").First().Value;

            var searchItems = WebSearchRepository
                              .WebSearch($"{result.Query} in Sitecore {major}.{minor}");

            var options = searchItems.WebPages.Value
                          .Take(3)
                          .Select(a => new ListItem(a.Name, a.Url))
                          .ToList();

            var intentInput = IntentInputFactory.Create(IntentInputType.ExternalLinks, options);

            return(ConversationResponseFactory.Create(KeyName, message, true, intentInput));
        }
Ejemplo n.º 6
0
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var username = (string)conversation.Data[UsernameKey].Value;
            var password = (string)conversation.Data[PasswordKey].Value;

            //CreateUser(Sitecore.Context.Domain, username, password);

            return(ConversationResponseFactory.Create(KeyName, Translator.Text("SearchForm.Intents.Registration.Success")));
        }
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var sessions     = AuthenticationWrapper.GetDomainAccessSessions().OrderByDescending(s => s.LastRequest);
            var sessionCount = sessions.Count();
            var userNames    = sessions.Select(a => a.UserName);
            var conjunction  = (sessionCount != 1) ? Translator.Text("Chat.Intents.LoggedInUsers.PluralConjunction") : Translator.Text("Chat.Intents.LoggedInUsers.SingularConjuntion");
            var plurality    = (sessionCount != 1) ? Translator.Text("Chat.Intents.LoggedInUsers.PluralLetter") : "";

            return(ConversationResponseFactory.Create(KeyName, $"{string.Format(Translator.Text("Chat.Intents.LoggedInUsers.Response"), conjunction, sessionCount, plurality)} <br/><ul><li>{string.Join("</li><li>", userNames)}</li></ul>"));
        }
Ejemplo n.º 8
0
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var name    = (string)conversation.Data[NameKey].Value;
            var email   = (string)conversation.Data[EmailKey].Value;
            var message = (string)conversation.Data[MessageKey].Value;

            //send email

            return(ConversationResponseFactory.Create(KeyName, Translator.Text("SearchForm.Intents.Contact.Success")));
        }
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var goals    = ProfileService.GetGoals();
            var response = new StringBuilder();
            var goalList = string.Join("", goals.Select(a => $"<li>{a.DisplayName}</li>"));

            response.AppendFormat(Translator.Text("Chat.Intents.ListGoals.Response"), goals.Count(), $"<ul>{goalList}</ul>");

            return(ConversationResponseFactory.Create(KeyName, response.ToString()));
        }
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var sessions     = AuthenticationWrapper.GetDomainAccessSessions().OrderByDescending(s => s.LastRequest);
            var sessionCount = sessions.Count();
            var userNames    = sessions.Select(a => a.UserName);
            var conjunction  = (sessionCount != 1) ? "are" : "is";
            var plurality    = (sessionCount != 1) ? "s" : "";

            return(ConversationResponseFactory.Create($"There {conjunction} {sessionCount} user{plurality}. <br/><ul><li>{string.Join("</li><li>", userNames)}</li></ul>"));
        }
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var intents = Provider.GetServices <IIntent>()
                          .Where(g => g.ApplicationId.Equals(ApplicationId) && !g.DisplayName.Equals(""))
                          .OrderBy(b => b.DisplayName)
                          .Select(i => $"<li>{i.DisplayName}</li>");

            var str = string.Join("", intents);

            return(ConversationResponseFactory.Create(KeyName, $"{Translator.Text("Chat.Intents.About.Response")}: <br/><ul>{str}</ul>"));
        }
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var intents = Provider.GetServices <IOleIntent>()
                          .Where(g => g.ApplicationId.Equals(ApplicationId) && !g.Description.Equals(""));

            var list = intents.Select(i => $"<li>{i.Description}</li>");

            var str = string.Join("", list);

            return(ConversationResponseFactory.Create($"{Translator.Text("Chat.Intents.About.Response")}: <br/><ul>{str}</ul>"));
        }
Ejemplo n.º 13
0
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var toDb      = (Database)conversation.Data[DBKey];
            var rootItem  = (Item)conversation.Data[ItemKey];
            var langItem  = (Language)conversation.Data[LangKey];
            var recursion = (string)conversation.Data[RecursionKey];

            PublishWrapper.PublishItem(rootItem, new[] { toDb }, new[] { langItem }, recursion.Equals("y"), false);

            return(ConversationResponseFactory.Create($"I've published {rootItem.DisplayName} to the {toDb.Name} database in {rootItem.Language.Name.ToUpper()} {(recursion.Equals("y") ? " with it's children" : string.Empty)}"));
        }
Ejemplo n.º 14
0
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var profileItem = (Item)conversation.Data[ItemKey].Value;
            var profileKeys = ProfileService.GetProfileKeys(profileItem);

            var response       = new StringBuilder();
            var profileKeyList = string.Join("", profileKeys.Select(a => $"<li>{a.DisplayName}</li>"));

            response.AppendFormat(Translator.Text("Chat.Intents.ListProfileKeys.Response"), profileKeys.Count(), profileItem.DisplayName, $"<ul>{profileKeyList}</ul>");

            return(ConversationResponseFactory.Create(KeyName, response.ToString()));
        }
Ejemplo n.º 15
0
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var intents = Provider.GetServices <IIntentFactory <IIntent> >()
                          .Select(a => a.Create())
                          .Where(g => g.ApplicationId.Equals(ApplicationId) && !g.Description.Equals(""));

            var list = intents.Select(i => $"<li>{i.Description}</li>");

            var str = string.Join("", list);

            return(ConversationResponseFactory.Create($"Here's the list of things I can do: <br/><ul>{str}</ul>"));
        }
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            List <string> responses = new List <string>()
            {
                Translator.Text("Chat.Intents.Frustrated.1"),
                Translator.Text("Chat.Intents.Frustrated.2"),
                Translator.Text("Chat.Intents.Frustrated.3"),
                Translator.Text("Chat.Intents.Frustrated.4"),
                Translator.Text("Chat.Intents.Frustrated.5"),
                Translator.Text("Chat.Intents.Frustrated.6")
            };

            return(ConversationResponseFactory.Create(KeyName, responses[new Random().Next(0, responses.Count)]));
        }
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            if (!AuthenticationWrapper.IsCurrentUserAdministrator())
            {
                return(ConversationResponseFactory.Create(KeyName, Translator.Text("Chat.Intents.KickUser.MustBeAdminMessage")));
            }

            var userSession = (DomainAccessGuard.Session)conversation.Data[UserKey].Value;
            var name        = userSession.UserName;

            AuthenticationWrapper.Kick(userSession.SessionID);

            return(ConversationResponseFactory.Create(KeyName, string.Format(Translator.Text("Chat.Intents.KickUser.Response"), name)));
        }
Ejemplo n.º 18
0
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            if (!AuthenticationWrapper.IsCurrentUserAdministrator())
            {
                return(ConversationResponseFactory.Create("Sorry, you can only perform this action if you're an admin"));
            }

            var userSession = (DomainAccessGuard.Session)conversation.Data[UserKey];
            var name        = userSession.UserName;

            AuthenticationWrapper.Kick(userSession.SessionID);

            return(ConversationResponseFactory.Create($"The user {name} has been kicked out."));
        }
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var item    = (Item)conversation.Data[ItemKey].Value;
            var version = (string)conversation.Data[VersionKey].Value;
            var date    = (string)conversation.Data[DateKey].Value;
            var dbs     = (List <Database>)conversation.Data[DBKey].Value;

            var fields = new Dictionary <ID, string>();
            int versionInt;

            //set item settings
            if (version.Equals("0"))
            {
                fields = (string.IsNullOrWhiteSpace(date))
                    ? GetFields("", "1", "", "")
                    : GetFields(date, "", "", "");
            } //version settings
            else if (int.TryParse(version, out versionInt))
            {
                fields = (string.IsNullOrWhiteSpace(date))
                    ? GetFields("", "", "", "1")
                    : GetFields("", "", date, "");
            }

            if (fields.Any())
            {
                DataWrapper.UpdateFields(item, fields);

                var db    = Sitecore.Configuration.Factory.GetDatabase(parameters.Database);
                var langs = DataWrapper.GetLanguages(db)
                            .Where(a => a.Name.Equals(parameters.Language))
                            .ToArray();
                PublishWrapper.PublishItem(item, dbs.ToArray(), langs, false, false, false);
            }

            var dateResponse = "";

            if (!string.IsNullOrWhiteSpace(date))
            {
                var dateTime = DateUtil.IsoDateToDateTime(date);
                dateResponse = (dateTime.Hour > 0)
                    ? dateTime.ToString("MMMM d, yyyy h:mmtt")
                    : dateTime.ToString("MMMM d, yyyy ");

                var at = Translator.Text("Chat.Intents.Unpublish.At");
                dateResponse = $" {at} {dateResponse}";
            }
            return(ConversationResponseFactory.Create(KeyName, string.Format(Translator.Text("Chat.Intents.Unpublish.Response"), item.Paths.Path, string.Join(", ", dbs.Select(a => a.Name)), dateResponse)));
        }
Ejemplo n.º 20
0
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            List <string> responses = new List <string>()
            {
                "You're welcome!",
                "It's what I do.",
                "I'm happy to help.",
                "You're too kind.",
                "I aim to please",
                "Anything for you.",
                "If I had a heart, it'd be touched."
            };

            return(ConversationResponseFactory.Create(responses[new Random().Next(0, responses.Count)]));
        }
Ejemplo n.º 21
0
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var toDb      = (Database)conversation.Data[DBKey];
            var rootItem  = (Item)conversation.Data[ItemKey];
            var langItem  = (Language)conversation.Data[LangKey];
            var recursion = (string)conversation.Data[RecursionKey];

            PublishWrapper.PublishItem(rootItem, new[] { toDb }, new[] { langItem }, recursion.Equals("y"), false);

            var recursionMessage = recursion.Equals("y")
                ? Translator.Text("Chat.Intents.Publish.ResponseRecursion")
                : string.Empty;

            return(ConversationResponseFactory.Create(string.Format(Translator.Text("Chat.Intents.Publish.Response"), rootItem.DisplayName, toDb.Name, rootItem.Language.Name.ToUpper(), recursionMessage)));
        }
Ejemplo n.º 22
0
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            string fullName = AuthenticationWrapper.GetCurrentUser().Profile.FullName;

            List <string> responses = new List <string>()
            {
                $"Hi {fullName}, how can I help you?",
                "What's up?",
                "What can I do for you?",
                "Hey.",
                "Hi.",
                "Can I help you with something?"
            };

            return(ConversationResponseFactory.Create(responses[new Random().Next(0, responses.Count)]));
        }
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            string fullName = AuthenticationWrapper.GetCurrentUser().Profile.FullName;

            List<string> responses = new List<string>()
            {
                string.Format(Translator.Text("Chat.Intents.Greet.1"), fullName),
                Translator.Text("Chat.Intents.Greet.2"),
                Translator.Text("Chat.Intents.Greet.3"),
                Translator.Text("Chat.Intents.Greet.4"),
                Translator.Text("Chat.Intents.Greet.5"),
                Translator.Text("Chat.Intents.Greet.6")
            };

            return ConversationResponseFactory.Create(KeyName, responses[new Random().Next(0, responses.Count)]);
        }
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var items = GetCurrentUserUnlockedItems(parameters.Database);

            foreach (SearchResultItem sri in items)
            {
                Item i = sri.GetItem();
                using (new SecurityDisabler()) {
                    using (new EditContext(i, false, true))
                    {
                        i.Locking.Unlock();
                    }
                }
            }

            return(ConversationResponseFactory.Create($"I've unlocked {items.Count} for you"));
        }
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var items = GetCurrentUserUnlockedItems(parameters.Database);

            foreach (SearchResultItem sri in items)
            {
                Item i = sri.GetItem();
                using (new SecurityDisabler()) {
                    using (new EditContext(i, false, true))
                    {
                        i.Locking.Unlock();
                    }
                }
            }

            return(ConversationResponseFactory.Create(KeyName, string.Format(Translator.Text("Chat.Intents.UnlockItems.Response"), items.Count)));
        }
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            List <string> responses = new List <string>()
            {
                "I can sense you're getting frustrated. Please have patience with me. I'm still learning.",
                "Let's take a break and try to relax a little.",
                "Before you're fed up with me, let's just slow down and try again.",
                "I know I'm not perfect but I'm not that bad am I?",
                "I'm trying to help but it looks like I'm making you mad.",
                "That type of language is really uncalled for.",
                "Do you really want to talk to me like that.",
                "I don't like you're disrespectful tone.",
                "How rude!",
                "I'm here to help so let's try to stay calm"
            };

            return(ConversationResponseFactory.Create(responses[new Random().Next(0, responses.Count)]));
        }
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var path = Context.Server.MapPath("~/sitecore/shell/sitecore.version.xml");

            if (!File.Exists(path))
            {
                return(ConversationResponseFactory.Create(KeyName, string.Empty));
            }

            string    xmlText = File.ReadAllText(path);
            XDocument xdoc    = XDocument.Parse(xmlText);

            var version  = xdoc.Descendants("version").First();
            var major    = version.Descendants("major").First().Value;
            var minor    = version.Descendants("minor").First().Value;
            var revision = version.Descendants("revision").First().Value;

            return(ConversationResponseFactory.Create(KeyName, string.Format(Translator.Text("Chat.Intents.Version.Response"), major, minor, revision)));
        }
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var path = Context.Server.MapPath("~/sitecore/shell/sitecore.version.xml");

            if (!File.Exists(path))
            {
                return(ConversationResponseFactory.Create(string.Empty));
            }

            string    xmlText = File.ReadAllText(path);
            XDocument xdoc    = XDocument.Parse(xmlText);

            var version  = xdoc.Descendants("version").First();
            var major    = version.Descendants("major").First().Value;
            var minor    = version.Descendants("minor").First().Value;
            var revision = version.Descendants("revision").First().Value;

            return(ConversationResponseFactory.Create($"My version is {major}.{minor} rev {revision}"));
        }
Ejemplo n.º 29
0
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var message = "";
            var index   = (string)conversation.Data[IndexKey];

            if (index == AllOption)
            {
                IndexCustodian.RebuildAll(new [] { IndexGroup.Experience });
                message = Translator.Text("Chat.Intents.RebuildIndex.AllRebuiltMessage");
            }
            else
            {
                var searchIndex = ContentSearchWrapper.GetIndex(index);
                IndexCustodian.FullRebuild(searchIndex);
                message = string.Format(Translator.Text("Chat.Intents.RebuildIndex.RebuildIndexMessage"), index);
            }

            return(ConversationResponseFactory.Create(message));
        }
        public override ConversationResponse Respond(LuisResult result, ItemContextParameters parameters, IConversation conversation)
        {
            var message = "";
            var index   = (string)conversation.Data[IndexKey];

            if (index == "All")
            {
                IndexCustodian.RebuildAll(new [] { IndexGroup.Experience });
                message = "All indexes are being rebuilt";
            }
            else
            {
                var searchIndex = ContentSearchWrapper.GetIndex(index);
                IndexCustodian.FullRebuild(searchIndex);
                message = $"The {index} index is being rebuilt";
            }

            return(ConversationResponseFactory.Create(message));
        }