protected override async Task OnMessageActivityAsync()

in ChatBot/Bots/ChatBot.cs [25:45]


        protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
        {
            var customerQuestion = turnContext.Activity.Text;
            _logger.LogInformation("Received customer question: {Message}", customerQuestion);

            try
            {
                // Call Semantic Kernel Service to get AI-generated response
                var responseStr = await _semanticKernelService.GetResponseAsync(customerQuestion);

                _logger.LogInformation("Received Semantic Kernel Response: {Message}", responseStr);

                // Send response back to the user
                await turnContext.SendActivityAsync(MessageFactory.Text(responseStr), cancellationToken);
            }    
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error processing message: {Message}", customerQuestion);
                await turnContext.SendActivityAsync(MessageFactory.Text("Sorry, something went wrong."), cancellationToken);
            }
        }