curaflow/backend/server.js

33 lines
897 B
JavaScript

const express = require('express');
const path = require('path');
const botLogic = require('./botLogic');
const app = express();
const port = 3000;
app.use(express.json());
// Serve static files
app.use(express.static(path.join(__dirname, '../')));
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, '../login.html'));
});
// Mock WhatsApp Webhook
app.post('/whatsapp/webhook', async (req, res) => {
const { from, body } = req.body;
console.log(`Received message from ${from}: ${body}`);
const response = await botLogic.handleMessage(from, body);
// In a real app, you'd call Twilio/Meta API here to send the reply
res.json({
success: true,
reply: response.reply,
buttons: response.buttons || []
});
});
app.listen(port, () => {
console.log(`CuraFlow WhatsApp Mock Server running at http://localhost:${port}`);
});