From cfea478c2d78e5928c159dfa87a5f25ff1ede2d6 Mon Sep 17 00:00:00 2001 From: Eddy de Vink Date: Sun, 11 Oct 2026 23:11:43 +0200 Subject: [PATCH] Migreer naar WuzAPI (chat/send/text, Token-header) --- index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 0439b6c..01c4cc2 100755 --- a/index.js +++ b/index.js @@ -13,6 +13,7 @@ const CONFIG = { daLoginKey: process.env.DA_LOGIN_KEY, daDomain: process.env.DA_DOMAIN, whatsappApi: process.env.WHATSAPP_API_ENDPOINT || 'http://localhost:3001', + whatsappToken: process.env.WHATSAPP_TOKEN || '', whatsappSession: process.env.WHATSAPP_SESSION || 'EdGpt', adminPhone: process.env.ADMIN_PHONE, matrixApi: process.env.MATRIX_API_ENDPOINT || 'https://whatsed.eddydevink.nl', @@ -139,13 +140,13 @@ async function updateEuroDynDns(hostname, ip) { } async function sendWhatsApp(message) { - const url = `${CONFIG.whatsappApi}/client/sendMessage/${CONFIG.whatsappSession}`; - const chatId = `${CONFIG.adminPhone}@c.us`; + const url = `${CONFIG.whatsappApi}/chat/send/text`; + const phone = `${CONFIG.adminPhone}`.replace(/[^0-9]/g, ''); try { const resp = await fetchWithTimeout(url, { method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ chatId, content: message, contentType: 'string' }), + headers: { 'Content-Type': 'application/json', Token: CONFIG.whatsappToken }, + body: JSON.stringify({ Phone: phone, Body: message }), }, 10000); if (!resp.ok) { logError(`WhatsApp send failed: ${resp.status}`);