diff --git a/main.wasp b/main.wasp index b082436..94c8494 100644 --- a/main.wasp +++ b/main.wasp @@ -233,6 +233,11 @@ action addNewConversationToChat { entities: [Chat, Conversation] } +action updateExistingConversation { + fn: import { updateExistingConversation } from "@server/actions.js", + entities: [Chat, Conversation] +} + action getAgentResponse { fn: import { getAgentResponse } from "@server/actions.js", entities: [Chat, Conversation] diff --git a/src/client/chatConversationHelper.tsx b/src/client/chatConversationHelper.tsx index 21388de..5f74f34 100644 --- a/src/client/chatConversationHelper.tsx +++ b/src/client/chatConversationHelper.tsx @@ -1,37 +1,48 @@ import getAgentResponse from "@wasp/actions/getAgentResponse"; import addNewConversationToChat from "@wasp/actions/addNewConversationToChat"; +import updateExistingConversation from "@wasp/actions/updateExistingConversation"; import { prepareOpenAIRequest } from "./helpers"; export async function addUserMessageToConversation( chat_id: number, - userQuery: string + userQuery: string, + conv_id?: number, + team_name?: string, + team_id?: number ) { + let userMessage = userQuery; + let isAnswerToAgentQuestion = false; + let user_answer_to_team_id = null; + if (team_id) { + const payload = { + chat_id: chat_id, + conv_id: conv_id, + type: null, + team_status: null, + }; + await updateExistingConversation(payload); + userMessage = `
Replying to ${team_name}: