diff --git a/gmail-agent/index.js b/gmail-agent/index.js index cc1499a..8c464ed 100644 --- a/gmail-agent/index.js +++ b/gmail-agent/index.js @@ -2,7 +2,6 @@ require('dotenv').config(); const fs = require('fs'); const path = require('path'); const cron = require('node-cron'); -const axios = require('axios'); const { google } = require('googleapis'); const TOKENS_DIR = path.join(__dirname, 'tokens'); @@ -111,13 +110,18 @@ SUMMARY: `; try { - const res = await axios.post(OLLAMA_URL, { - model: OLLAMA_MODEL, - prompt: prompt, - stream: false + const res = await fetch(OLLAMA_URL, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + model: OLLAMA_MODEL, + prompt: prompt, + stream: false + }) }); - const responseText = res.data.response || ''; + const data = await res.json(); + const responseText = data.response || ''; const isImportant = responseText.includes('IMPORTANT: YES'); const summaryMatch = responseText.match(/SUMMARY:\s*(.*)/); const summary = summaryMatch ? summaryMatch[1].trim() : ''; @@ -133,11 +137,16 @@ async function sendWhatsAppNotification(email, summary) { const message = `šŸ“§ *[${email.accountName}] Important Email*\n*From:* ${email.from}\n*Subject:* ${email.subject}\n\nšŸ¤– *Summary:* ${summary}`; try { - await axios.post(WHATSAPP_GATEWAY_URL, { - to: WHATSAPP_TO, - message: message - }, { - headers: { 'x-app-name': 'Gmail Agent' } + await fetch(WHATSAPP_GATEWAY_URL, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'x-app-name': 'Gmail Agent' + }, + body: JSON.stringify({ + to: WHATSAPP_TO, + message: message + }) }); console.log(`Notification sent for: [${email.accountName}] ${email.subject}`); } catch (err) { diff --git a/gmail-agent/package.json b/gmail-agent/package.json index c7731d5..211ff07 100644 --- a/gmail-agent/package.json +++ b/gmail-agent/package.json @@ -11,7 +11,6 @@ "license": "ISC", "type": "commonjs", "dependencies": { - "axios": "^1.17.0", "cors": "^2.8.6", "dotenv": "^17.4.2", "express": "^5.2.1",