/* * Copyright 2025 Google. This software is provided as-is, without warranty or representation for any use or purpose. * Your use of it is subject to your agreement with Google. */ package com.example.controller; import com.example.dto.dialogflow.base.DetectIntentResponseDTO; import com.example.dto.dialogflow.conversation.ExternalConvRequestDTO; import com.example.mapper.conversation.ExternalConvRequestMapper; import com.example.service.conversation.ConversationManagerService; import jakarta.validation.Valid; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import reactor.core.publisher.Mono; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @RestController @RequestMapping("/api/v1/dialogflow") public class ConversationController { private static final Logger logger = LoggerFactory.getLogger(ConversationController.class); private final ConversationManagerService conversationManagerService; public ConversationController(ConversationManagerService conversationManagerService, ExternalConvRequestMapper externalRequestToDialogflowMapper) { this.conversationManagerService = conversationManagerService; } @PostMapping("/detect-intent") public Mono detectIntent(@Valid @RequestBody ExternalConvRequestDTO request) { return conversationManagerService.manageConversation(request) .doOnSuccess(response -> logger.info("Successfully processed direct Dialogflow request")) .doOnError(error -> logger.error("Error processing direct Dialogflow request: {}", error.getMessage(), error)); } }