Example #1
0
        public static OnTurnProperty FromLuisResults(RecognizerResult luisResults)
        {
            var(intent, score) = luisResults.GetTopScoringIntent();

            var onTurnProperties = new OnTurnProperty
            {
                Intent = intent,
                Score  = score,
                Type   = Luis
            };

            // Gather entity values if available. Uses a const list of LUIS entity names.
            foreach (var entity in luisEntities)
            {
                var value = luisResults.Entities.SelectTokens(entity).FirstOrDefault();
                if (value == null)
                {
                    continue;
                }

                onTurnProperties.Entities.Add(new EntityProperty(entity, value));
            }

            return(onTurnProperties);
        }
Example #2
0
        /// <summary>
        /// Static method to create an on turn property object from card input.
        /// </summary>
        /// <param name="cardValues">context.activity.value from a card interaction</param>
        /// <returns>OnTurnProperty.</returns>
        public static OnTurnProperty FromCardInput(Dictionary <string, string> cardValues)
        {
            // All cards used by this bot are adaptive cards with the card's 'data' property set to useful information.
            var onTurnProperties = new OnTurnProperty()
            {
                Type = Card
            };

            foreach (var entry in cardValues)
            {
                if (!string.IsNullOrWhiteSpace(entry.Key) && string.Compare(entry.Key.ToLower().Trim(), "intent") == 0)
                {
                    onTurnProperties.Intent = cardValues[entry.Key];
                }
                else
                {
                    onTurnProperties.Entities.Add(new EntityProperty(entry.Key, cardValues[entry.Key]));
                }
            }

            return(onTurnProperties);
        }