diff --git a/whatsapp-router/src/chatHandlers.ts b/whatsapp-router/src/chatHandlers.ts index 4238bcd..623aa07 100644 --- a/whatsapp-router/src/chatHandlers.ts +++ b/whatsapp-router/src/chatHandlers.ts @@ -10,6 +10,7 @@ export const chatHandlers: Record = { }; export function getHandler(chatId: string | undefined, defaultUrl?: string): Handler | undefined { + if (!chatId) return defaultUrl; return chatHandlers[chatId] || defaultUrl; } diff --git a/whatsapp-router/src/index.ts b/whatsapp-router/src/index.ts index be48408..8d6b2b8 100644 --- a/whatsapp-router/src/index.ts +++ b/whatsapp-router/src/index.ts @@ -3,6 +3,7 @@ import axios from 'axios'; import { WhatsAppMessage } from './types'; import { getHandler, Handler } from './chatHandlers'; + const app = express(); const port = Number(process.env.PORT) || 3001; @@ -116,6 +117,7 @@ app.post('/webhook', async (req: express.Request, res: express.Response) => { text?: string; from?: string; }; + const incoming = message || text; try { if (!incoming) return res.sendStatus(200);