const express = require('express'); const axios = require('axios'); const app = express(); app.use(express.json()); const API_KEY = "sk_live_xxxxxxxxxxxxxxxxxxxxxx"; app.post('/api/v1/webhooks/whatsapp', async (req, res) => { console.log("Incoming:", req.body); const from = req.body?.data?.from; const text = req.body?.data?.message?.text?.toLowerCase(); if (!from || !text) { return res.sendStatus(200); } let reply = "You said: " + text; if (text === "hi" || text === "hello") { reply = "Hello 👋 Welcome to Naavigo Events WhatsApp Bot!"; } await axios.post( "https://api.trigr.io/v1/send-message", { phoneNumber: from, message: reply }, { headers: { Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json" } } ); res.sendStatus(200); }); app.listen(3000, () => console.log("Server running"));