Revert "Merge branch 'main' of https://github.com/josedario87/conversation-layer"
This reverts commitb508bea3dd, reversing changes made to4c4052bb64.
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
import express, { Application } from 'express';
|
||||
import axios from 'axios';
|
||||
import { GoogleGenAI } from '@google/genai';
|
||||
import { getHandler } from './chatHandlers';
|
||||
import { addMessageToConversation } from './store/conversation';
|
||||
import { WhatsAppMessage, Conversation } from './types';
|
||||
import { transcribeAudioMessage } from './transcribeAudioMessage';
|
||||
|
||||
export interface WebhookConfig {
|
||||
API_URL: string;
|
||||
@@ -33,12 +31,6 @@ export function registerWebhookRoutes(
|
||||
|
||||
if (message) {
|
||||
const origen = from || message.chatId || 'desconocido';
|
||||
|
||||
if(origen == '50493849962@c.us') //si el mensajes es de un agente, no lo proceses
|
||||
{
|
||||
return res.sendStatus(200);
|
||||
}
|
||||
|
||||
console.log(`📩 Mensaje recibido (${message.text}) de ${origen}`);
|
||||
}
|
||||
|
||||
@@ -46,39 +38,6 @@ export function registerWebhookRoutes(
|
||||
if (!message) return res.sendStatus(200);
|
||||
if (!openWaUrl) throw new Error('Service URLs not configured');
|
||||
const chatId = message.chatId || from;
|
||||
|
||||
// Audio message handling
|
||||
// console.log(message);
|
||||
|
||||
if (
|
||||
message.type === 'ptt' &&
|
||||
message.mimetype === 'audio/ogg; codecs=opus'
|
||||
) {
|
||||
const audioUrl = message.clientUrl || message.deprecatedMms3Url;
|
||||
if (!audioUrl) {
|
||||
console.error('No audio URL found for PTT message');
|
||||
// Potentially send a message to user or just skip? For now, skip.
|
||||
return res.sendStatus(200);
|
||||
}
|
||||
console.log('🎤 Mensaje de audio detectado', audioUrl);
|
||||
try {
|
||||
const transcript = await transcribeAudioMessage(message);
|
||||
console.log('📝 Transcripción:', transcript);
|
||||
message.body = transcript || '';
|
||||
message.text = transcript || '';
|
||||
|
||||
|
||||
} catch (transcriptionError: any) {
|
||||
console.error('Error en la transcripción:', transcriptionError.message);
|
||||
const reply =
|
||||
"I received an audio message, but I couldn't transcribe it. Please send the transcript manually.";
|
||||
await axios.post(`${openWaUrl}/sendText`, { args: { to: from, content: reply } });
|
||||
// Stop processing this message as transcription failed and user has been notified.
|
||||
return res.sendStatus(200);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(message);
|
||||
let conv: Conversation | undefined;
|
||||
if (chatId) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user