chore: remove hardcoded whatsapp urls and numbers
This commit is contained in:
parent
81d191a516
commit
884562a733
|
|
@ -52,7 +52,10 @@ spec:
|
||||||
- name: WHATSAPP_GATEWAY_URL
|
- name: WHATSAPP_GATEWAY_URL
|
||||||
value: http://whatsapp-gateway.ai-agents.svc.cluster.local:5001/api/send-message
|
value: http://whatsapp-gateway.ai-agents.svc.cluster.local:5001/api/send-message
|
||||||
- name: WHATSAPP_TO
|
- name: WHATSAPP_TO
|
||||||
value: "+14085505485"
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: whatsapp-config
|
||||||
|
key: personal-number
|
||||||
- name: OLLAMA_MODEL
|
- name: OLLAMA_MODEL
|
||||||
value: "qwen2.5:0.5b"
|
value: "qwen2.5:0.5b"
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,10 @@ spec:
|
||||||
- name: GATEWAY_URL
|
- name: GATEWAY_URL
|
||||||
value: http://whatsapp-gateway.ai-agents.svc.cluster.local:5001/send-message
|
value: http://whatsapp-gateway.ai-agents.svc.cluster.local:5001/send-message
|
||||||
- name: PERSONAL_NUM
|
- name: PERSONAL_NUM
|
||||||
value: "+14085505485"
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: whatsapp-config
|
||||||
|
key: personal-number
|
||||||
- name: GROUP_URL
|
- name: GROUP_URL
|
||||||
valueFrom:
|
valueFrom:
|
||||||
configMapKeyRef:
|
configMapKeyRef:
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,10 @@ spec:
|
||||||
- name: OLLAMA_URL
|
- name: OLLAMA_URL
|
||||||
value: http://ollama.ai-agents.svc.cluster.local:11434/api/generate
|
value: http://ollama.ai-agents.svc.cluster.local:11434/api/generate
|
||||||
- name: PERSONAL_NUM
|
- name: PERSONAL_NUM
|
||||||
value: "+14085505485"
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: whatsapp-config
|
||||||
|
key: personal-number
|
||||||
- name: GROUP_URL
|
- name: GROUP_URL
|
||||||
valueFrom:
|
valueFrom:
|
||||||
configMapKeyRef:
|
configMapKeyRef:
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,11 @@ spec:
|
||||||
configMapKeyRef:
|
configMapKeyRef:
|
||||||
name: whatsapp-config
|
name: whatsapp-config
|
||||||
key: default-group-url
|
key: default-group-url
|
||||||
|
- name: PERSONAL_NUMBER
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: whatsapp-config
|
||||||
|
key: personal-number
|
||||||
command:
|
command:
|
||||||
- "node"
|
- "node"
|
||||||
- "-e"
|
- "-e"
|
||||||
|
|
@ -35,7 +40,7 @@ spec:
|
||||||
const ZIP = '16046';
|
const ZIP = '16046';
|
||||||
const GATEWAY = 'http://whatsapp-gateway.ai-agents.svc.cluster.local:5001/send-message';
|
const GATEWAY = 'http://whatsapp-gateway.ai-agents.svc.cluster.local:5001/send-message';
|
||||||
const CONFIG_API = 'http://hq-dashboard.ai-agents.svc.cluster.local/api/config/whatsapp';
|
const CONFIG_API = 'http://hq-dashboard.ai-agents.svc.cluster.local/api/config/whatsapp';
|
||||||
const PERSONAL = '+14085505485';
|
const PERSONAL = process.env.PERSONAL_NUMBER;
|
||||||
|
|
||||||
function fetchConfig() {
|
function fetchConfig() {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
|
|
@ -50,9 +55,9 @@ spec:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
resolve('https://chat.whatsapp.com/0Txfg7iZBbvIuvTbTqqgAX');
|
resolve(process.env.GROUP_URL);
|
||||||
});
|
});
|
||||||
}).on('error', () => resolve('https://chat.whatsapp.com/0Txfg7iZBbvIuvTbTqqgAX'));
|
}).on('error', () => resolve(process.env.GROUP_URL));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -180,7 +185,7 @@ spec:
|
||||||
// Send to group then personal number
|
// Send to group then personal number
|
||||||
fetchConfig().then(GROUP => {
|
fetchConfig().then(GROUP => {
|
||||||
sendTo(GROUP, 'WhatsApp Group')
|
sendTo(GROUP, 'WhatsApp Group')
|
||||||
.then(() => sendTo(PERSONAL, 'Personal (+14085505485)'))
|
.then(() => sendTo(PERSONAL, 'Personal (' + PERSONAL + ')'))
|
||||||
.catch(e => { console.error('[WeatherBot] Fatal:', e.message); process.exit(1); });
|
.catch(e => { console.error('[WeatherBot] Fatal:', e.message); process.exit(1); });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,6 @@ metadata:
|
||||||
name: whatsapp-config
|
name: whatsapp-config
|
||||||
namespace: ai-agents
|
namespace: ai-agents
|
||||||
data:
|
data:
|
||||||
trip-group-url: "https://chat.whatsapp.com/HN2z93yhXPyEJPuoib3dws"
|
personal-number: "+14085505485"
|
||||||
default-group-url: "https://chat.whatsapp.com/0Txfg7iZBbvIuvTbTqqgAX"
|
trip-group-url: "https://chat.whatsapp.com/BbJdJrilnx40YAz9s9cApf"
|
||||||
|
default-group-url: "https://chat.whatsapp.com/BbJdJrilnx40YAz9s9cApf"
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ def proxmox_clean_disk(vmid: str) -> str:
|
||||||
|
|
||||||
def send_whatsapp_alert(message_body: str) -> str:
|
def send_whatsapp_alert(message_body: str) -> str:
|
||||||
"""Dispatches a WhatsApp alert using the local gateway (if running) or falls back to Twilio."""
|
"""Dispatches a WhatsApp alert using the local gateway (if running) or falls back to Twilio."""
|
||||||
admin_number = os.environ.get("ADMIN_WHATSAPP_NUMBER") or os.environ.get("PHYSICIAN_WHATSAPP_NUMBER", "whatsapp:+14085505485")
|
admin_number = os.environ.get("ADMIN_WHATSAPP_NUMBER") or os.environ.get("PHYSICIAN_WHATSAPP_NUMBER")
|
||||||
|
|
||||||
# 1. Attempt local WhatsApp Web Gateway first (if enabled/running)
|
# 1. Attempt local WhatsApp Web Gateway first (if enabled/running)
|
||||||
use_local = os.environ.get("USE_LOCAL_WHATSAPP", "true").lower() == "true"
|
use_local = os.environ.get("USE_LOCAL_WHATSAPP", "true").lower() == "true"
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ function getCredentials() {
|
||||||
|
|
||||||
const OLLAMA_URL = process.env.OLLAMA_URL || 'http://ollama.ai-agents.svc.cluster.local:11434/api/generate';
|
const OLLAMA_URL = process.env.OLLAMA_URL || 'http://ollama.ai-agents.svc.cluster.local:11434/api/generate';
|
||||||
const WHATSAPP_GATEWAY_URL = process.env.WHATSAPP_GATEWAY_URL || 'http://whatsapp-gateway.ai-agents.svc.cluster.local:5001/api/send-message';
|
const WHATSAPP_GATEWAY_URL = process.env.WHATSAPP_GATEWAY_URL || 'http://whatsapp-gateway.ai-agents.svc.cluster.local:5001/api/send-message';
|
||||||
const WHATSAPP_TO = process.env.WHATSAPP_TO || '+14085505485';
|
const WHATSAPP_TO = process.env.WHATSAPP_TO;
|
||||||
const OLLAMA_MODEL = process.env.OLLAMA_MODEL || 'qwen2.5:0.5b';
|
const OLLAMA_MODEL = process.env.OLLAMA_MODEL || 'qwen2.5:0.5b';
|
||||||
|
|
||||||
let baseOAuth2Client;
|
let baseOAuth2Client;
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,10 @@ spec:
|
||||||
- name: WHATSAPP_GATEWAY_URL
|
- name: WHATSAPP_GATEWAY_URL
|
||||||
value: http://whatsapp-gateway.ai-agents.svc.cluster.local:5001/api/send-message
|
value: http://whatsapp-gateway.ai-agents.svc.cluster.local:5001/api/send-message
|
||||||
- name: WHATSAPP_TO
|
- name: WHATSAPP_TO
|
||||||
value: "+14085505485"
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: whatsapp-config
|
||||||
|
key: personal-number
|
||||||
- name: OLLAMA_MODEL
|
- name: OLLAMA_MODEL
|
||||||
value: "qwen2.5:0.5b"
|
value: "qwen2.5:0.5b"
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
import { NextResponse } from 'next/server';
|
import { NextResponse } from 'next/server';
|
||||||
|
|
||||||
const GATEWAY = process.env.WHATSAPP_GATEWAY_URL ||
|
const GATEWAY = process.env.WHATSAPP_GATEWAY_URL;
|
||||||
'http://whatsapp-gateway.ai-agents.svc.cluster.local:5001/send-message';
|
const GROUP_URL = process.env.WHATSAPP_GROUP;
|
||||||
const DEFAULT_GROUP = process.env.WHATSAPP_GROUP ||
|
const PERSONAL_NUMBER = process.env.WHATSAPP_PERSONAL;
|
||||||
'https://chat.whatsapp.com/FXO0SCLA8DpJwClNNWdhhx';
|
|
||||||
const PERSONAL_NUMBER = process.env.WHATSAPP_PERSONAL || '+14085505485';
|
|
||||||
|
|
||||||
async function sendToRecipient(to, message) {
|
async function sendToRecipient(to, message) {
|
||||||
const res = await fetch(GATEWAY, {
|
const res = await fetch(GATEWAY, {
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ app.use(express.json());
|
||||||
|
|
||||||
const DATA_FILE = process.env.DATA_FILE || '/data/reminders.json';
|
const DATA_FILE = process.env.DATA_FILE || '/data/reminders.json';
|
||||||
const GATEWAY = process.env.GATEWAY_URL || 'http://whatsapp-gateway.ai-agents.svc.cluster.local:5001/send-message';
|
const GATEWAY = process.env.GATEWAY_URL || 'http://whatsapp-gateway.ai-agents.svc.cluster.local:5001/send-message';
|
||||||
const PERSONAL = process.env.PERSONAL_NUM || '+14085505485';
|
const PERSONAL = process.env.PERSONAL_NUM;
|
||||||
const GROUP = process.env.GROUP_URL || 'https://chat.whatsapp.com/FXO0SCLA8DpJwClNNWdhhx';
|
const GROUP = process.env.GROUP_URL;
|
||||||
const PORT = parseInt(process.env.PORT) || 6001;
|
const PORT = parseInt(process.env.PORT) || 6001;
|
||||||
|
|
||||||
// ── Persistence ──────────────────────────────────────────────────────────────
|
// ── Persistence ──────────────────────────────────────────────────────────────
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,9 @@ async function getGroupUrl(type = 'trip-group-url') {
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[Redis] Failed to fetch config:', e.message);
|
console.error('[Redis] Failed to fetch config:', e.message);
|
||||||
|
return process.env.GROUP_URL;
|
||||||
}
|
}
|
||||||
return process.env.GROUP_URL || 'https://chat.whatsapp.com/HN2z93yhXPyEJPuoib3dws';
|
return process.env.GROUP_URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
@ -29,8 +30,8 @@ app.use(express.json({ limit: '1mb' }));
|
||||||
const DATA_FILE = process.env.DATA_FILE || '/data/trips.json';
|
const DATA_FILE = process.env.DATA_FILE || '/data/trips.json';
|
||||||
const GATEWAY_URL = process.env.GATEWAY_URL || 'http://whatsapp-gateway.ai-agents.svc.cluster.local:5001/send-message';
|
const GATEWAY_URL = process.env.GATEWAY_URL || 'http://whatsapp-gateway.ai-agents.svc.cluster.local:5001/send-message';
|
||||||
const OLLAMA_URL = process.env.OLLAMA_URL || 'http://ollama.ai-agents.svc.cluster.local:11434/api/generate';
|
const OLLAMA_URL = process.env.OLLAMA_URL || 'http://ollama.ai-agents.svc.cluster.local:11434/api/generate';
|
||||||
const PERSONAL_NUM = process.env.PERSONAL_NUM || '+14085505485';
|
const PERSONAL_NUM = process.env.PERSONAL_NUM;
|
||||||
const GROUP_URL = process.env.GROUP_URL || 'https://chat.whatsapp.com/HN2z93yhXPyEJPuoib3dws';
|
const GROUP_URL = process.env.GROUP_URL;
|
||||||
const PORT = parseInt(process.env.PORT) || 6002;
|
const PORT = parseInt(process.env.PORT) || 6002;
|
||||||
|
|
||||||
// ── Persistence ──────────────────────────────────────────────────────────────
|
// ── Persistence ──────────────────────────────────────────────────────────────
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
"briefingTime": "07:00",
|
"briefingTime": "07:00",
|
||||||
"sendToGroup": true,
|
"sendToGroup": true,
|
||||||
"groupUrls": [
|
"groupUrls": [
|
||||||
"https://chat.whatsapp.com/FXO0SCLA8DpJwClNNWdhhx"
|
""
|
||||||
],
|
],
|
||||||
"npsParkCode": "grsm",
|
"npsParkCode": "grsm",
|
||||||
"days": [
|
"days": [
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue