Add custom whatsapp command for utility scraper

This commit is contained in:
Deep Koluguri 2026-06-27 17:25:45 -04:00
parent ad0df70117
commit 8d615a9966
1 changed files with 19 additions and 0 deletions

View File

@ -110,6 +110,25 @@ client.on('message_create', async msg => {
// Target Jid is where the bot should reply.
const targetJid = msg.fromMe ? msg.to : msg.from;
// Custom command for utility scraper
if (text.toLowerCase().includes('run scraper') || text.toLowerCase().includes('check utility')) {
client.sendMessage(targetJid, '⚡ Triggering utility scraper in background... You will receive the report shortly!');
try {
const http = require('http');
const req = http.request({
hostname: 'utility-agent.ai-agents.svc.cluster.local',
port: 5005,
path: '/api/run',
method: 'POST'
});
req.on('error', err => console.error('[WhatsApp Bot] Failed to trigger scraper:', err));
req.end();
} catch (err) {
console.error(err);
}
return;
}
try {
const data = JSON.stringify({
text: text,