UPDATE code 20-Ago

This commit is contained in:
PAVEL PALMA
2025-08-21 00:24:21 -06:00
parent 82eee5f7c0
commit 404f152097
54 changed files with 1851 additions and 597 deletions

View File

@@ -8,7 +8,16 @@ package com.example.dto.dialogflow.base;
import com.example.dto.dialogflow.conversation.QueryResultDTO;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.example.dto.quickreplies.QuickReplyDTO;
import com.fasterxml.jackson.annotation.JsonInclude;
@JsonInclude(JsonInclude.Include.NON_NULL)
public record DetectIntentResponseDTO(
@JsonProperty("responseId") String responseId,
@JsonProperty("queryResult") QueryResultDTO queryResult
) {}
@JsonProperty("queryResult") QueryResultDTO queryResult,
@JsonProperty("quick_replies") QuickReplyDTO quickReplies
) {
public DetectIntentResponseDTO(String responseId, QueryResultDTO queryResult) {
this(responseId, queryResult, null);
}
}

View File

@@ -30,17 +30,29 @@ public record ConversationEntryDTO(
public static ConversationEntryDTO forAgent(QueryResultDTO agentQueryResult) {
String fulfillmentText = (agentQueryResult != null && agentQueryResult.responseText() != null) ? agentQueryResult.responseText() : "";
Map<String, Object> parameters = (agentQueryResult != null) ? agentQueryResult.parameters() : null;
return new ConversationEntryDTO(
ConversationEntryEntity.AGENTE,
ConversationEntryType.CONVERSACION,
Instant.now(),
fulfillmentText,
agentQueryResult.parameters(),
parameters,
null
);
}
public static ConversationEntryDTO forSystem(String text) {
public static ConversationEntryDTO forAgentWithMessage(String text) {
return new ConversationEntryDTO(
ConversationEntryEntity.AGENTE,
ConversationEntryType.CONVERSACION,
Instant.now(),
text,
null,
null
);
}
public static ConversationEntryDTO forSystem(String text) {
return new ConversationEntryDTO(
ConversationEntryEntity.SISTEMA,
ConversationEntryType.CONVERSACION,

View File

@@ -6,44 +6,53 @@
package com.example.dto.dialogflow.conversation;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(Include.NON_NULL)
public record ConversationSessionDTO(
String sessionId,
String userId,
String telefono,
Instant createdAt,
Instant lastModified,
List<ConversationEntryDTO> entries
List<ConversationEntryDTO> entries,
String pantallaContexto
) {
public ConversationSessionDTO(String sessionId, String userId, String telefono, Instant createdAt, Instant lastModified, List<ConversationEntryDTO> entries) {
public ConversationSessionDTO(String sessionId, String userId, String telefono, Instant createdAt, Instant lastModified, List<ConversationEntryDTO> entries, String pantallaContexto) {
this.sessionId = sessionId;
this.userId = userId;
this.telefono = telefono;
this.createdAt = createdAt;
this.lastModified = lastModified;
this.entries = Collections.unmodifiableList(new ArrayList<>(entries));
this.pantallaContexto = pantallaContexto;
}
public static ConversationSessionDTO create(String sessionId, String userId, String telefono) {
Instant now = Instant.now();
return new ConversationSessionDTO(sessionId, userId, telefono, now, now, Collections.emptyList());
return new ConversationSessionDTO(sessionId, userId, telefono, now, now, Collections.emptyList(), null);
}
public ConversationSessionDTO withAddedEntry(ConversationEntryDTO newEntry) {
List<ConversationEntryDTO> updatedEntries = new ArrayList<>(this.entries);
updatedEntries.add(newEntry);
return new ConversationSessionDTO(this.sessionId, this.userId, this.telefono, this.createdAt, Instant.now(), updatedEntries);
return new ConversationSessionDTO(this.sessionId, this.userId, this.telefono, this.createdAt, Instant.now(), updatedEntries, this.pantallaContexto);
}
public ConversationSessionDTO withTelefono(String newTelefono) {
if (newTelefono != null && !newTelefono.equals(this.telefono)) {
return new ConversationSessionDTO(this.sessionId, this.userId, newTelefono, this.createdAt, this.lastModified, this.entries);
return new ConversationSessionDTO(this.sessionId, this.userId, newTelefono, this.createdAt, this.lastModified, this.entries, this.pantallaContexto);
}
return this;
}
public ConversationSessionDTO withPantallaContexto(String pantallaContexto) {
return new ConversationSessionDTO(this.sessionId, this.userId, this.telefono, this.createdAt, this.lastModified, this.entries, pantallaContexto);
}
}

View File

@@ -13,7 +13,8 @@ public record ExternalConvRequestDTO(
@JsonProperty("mensaje") String message,
@JsonProperty("usuario") UsuarioDTO user,
@JsonProperty("canal") String channel,
@JsonProperty("tipo") ConversationEntryType tipo
@JsonProperty("tipo") ConversationEntryType tipo,
@JsonProperty("pantallaContexto") String pantallaContexto //optional field for quick-replies
) {
public ExternalConvRequestDTO {}
}

View File

@@ -21,7 +21,8 @@ public record NotificationDTO(
String texto, // 'texto' original de NotificationRequestDTO (si aplica)
String nombreEventoDialogflow, // Nombre del evento enviado a Dialogflow (ej. "tu Estado de cuenta listo")
String codigoIdiomaDialogflow, // Código de idioma usado para el evento
Map<String, Object> parametros // Parámetros de sesión finales después del procesamiento de// Dialogflow
Map<String, Object> parametros, // Parámetros de sesión finales después del procesamiento de// Dialogflow
String status
) {
public NotificationDTO {
Objects.requireNonNull(idNotificacion, "Notification ID cannot be null.");

View File

@@ -0,0 +1,8 @@
package com.example.dto.quickreplies;
import com.fasterxml.jackson.annotation.JsonProperty;
public record QuestionDTO(
@JsonProperty("titulo") String titulo,
@JsonProperty("descripcion") String descripcion
) {}

View File

@@ -0,0 +1,9 @@
package com.example.dto.quickreplies;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
public record QuickReplyDTO(
@JsonProperty("header") String header,
@JsonProperty("preguntas") List<QuestionDTO> preguntas
) {}

View File

@@ -0,0 +1,14 @@
package com.example.dto.quickreplies;
import com.example.dto.dialogflow.conversation.ConversationEntryType;
import com.example.dto.dialogflow.conversation.UsuarioDTO;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public record QuickReplyScreenRequestDTO(
@JsonProperty("usuario") UsuarioDTO user,
@JsonProperty("canal") String channel,
@JsonProperty("tipo") ConversationEntryType tipo,
@JsonProperty("pantallaContexto") String pantallaContexto
) {}