예제 #1
0
        /// <summary>
        /// Populates the specified message with LUIS response data.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <returns>Returns new instance of <see cref="LuisMessage"/> that is populated with LUIS response data.</returns>
        /// <remarks>
        /// Access the LUIS response data through <see cref="LuisMessage.Luis"/> property.
        /// </remarks>
        private static async Task <LuisMessage> HandleMessageAsync(BotMessage message)
        {
            // Translate to LUIS message
            var luisMessage = BotMessage.Populate <BotMessage, LuisMessage>(message);

            // Populate LUIS data
            luisMessage.Luis = await GetLuisResponseAsync(message.Text);

            // Check if we need to debug the message
            if (luisMessage.IsDebug && luisMessage.DebugParam == "luis")
            {
                luisMessage.Response  = JsonConvert.SerializeObject(luisMessage.Luis);
                luisMessage.IsHandled = true;
            }

            return(luisMessage);
        }