procesar bien el primer mensaje de voz ya no enreda al proceso de manejo de la conversacion. probablemente necesitemos refactorizar todo este codigo eventualmente
This commit is contained in:
@@ -86,7 +86,7 @@ export async function buildConversation(
|
||||
}
|
||||
}
|
||||
|
||||
const messages: Msg[] = rawMessages.slice(-20).map(mapWhatsAppMessageToMsg);
|
||||
const messages: Msg[] = rawMessages.map(mapWhatsAppMessageToMsg);
|
||||
messages.sort((a, b) => a.ts - b.ts);
|
||||
|
||||
const conv: Conversation = {
|
||||
@@ -113,6 +113,7 @@ export async function addMessageToConversation(
|
||||
msg: WhatsAppMessage,
|
||||
openWaUrl: string
|
||||
): Promise<Conversation> {
|
||||
console.log(`[conversationStore] Adding message to ${chatId}`);
|
||||
const conv = await getConversation(chatId, openWaUrl, msg);
|
||||
|
||||
// Delegate message processing to the new function
|
||||
|
||||
@@ -62,6 +62,8 @@ export function registerWebhookRoutes(
|
||||
if (chatId) {
|
||||
try {
|
||||
conv = await addMessageToConversation(chatId, message, openWaUrl);
|
||||
console.log(`🔄 Updated conversation for ${chatId}`, conv);
|
||||
|
||||
} catch (err: any) {
|
||||
console.warn('Failed updating conversation:', err.message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user