public static bool QueueEndsWithIntentsOfType(this PersistentQueue <CommandDefinition> queue, string requiredIntent, string[] validIntents)
        {
            var commands = queue.Entries().ToArray();

            int index = 0;

            int lastIndex = -1;

            foreach (var command in commands)
            {
                if (command.IntentName == requiredIntent)
                {
                    lastIndex = index;
                }

                index++;
            }

            if (lastIndex == -1)
            {
                return(false);
            }

            bool match = true;

            foreach (var remainingCommand in commands.Skip(lastIndex + 1))
            {
                if (!validIntents.Contains(remainingCommand.IntentName))
                {
                    match = false;
                }
            }

            return(match);
        }
        public static bool QueueEndsWith(this PersistentQueue <CommandDefinition> queue, string[] requiredIntents)
        {
            requiredIntents = requiredIntents.Reverse().ToArray();

            var commandQueue = queue.Entries().ToArray();

            var queueLength = commandQueue.Length;

            if (queueLength < requiredIntents.Length)
            {
                return(false);
            }

            for (int i = 0; i < requiredIntents.Length; i++)
            {
                var item = commandQueue.ElementAt(queueLength - (i + 1));

                if (item.IntentName != requiredIntents[i])
                {
                    return(false);
                }
            }

            return(true);
        }