Merge branch 'main' into codex/change-repo-to-typescript-and-create-type-for-onmessage-even
This commit is contained in:
@@ -10,6 +10,7 @@ export const chatHandlers: Record<string, Handler> = {
|
||||
};
|
||||
|
||||
export function getHandler(chatId: string | undefined, defaultUrl?: string): Handler | undefined {
|
||||
|
||||
if (!chatId) return defaultUrl;
|
||||
return chatHandlers[chatId] || defaultUrl;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user