Add WABA outreach automation (Z-PRO integration)

Per-product message templates, official/não-oficial channel selection,
manual per-number sending, and a 20-minute internal scheduler for the
existing automatic outreach batch — all pre-existing local work being
committed as-is.
This commit is contained in:
Gustavo
2026-08-03 13:14:09 -03:00
parent 0894ab68b3
commit eaaf7af659
32 changed files with 3522 additions and 342 deletions
+30 -1
View File
@@ -367,11 +367,40 @@ const Tratamento = (() => {
const tbody = document.querySelector('#tabela-leads tbody');
if (!data.rows.length) {
tbody.replaceChildren(h('tr', {}, h('td', { colspan: '9', class: 'muted' }, 'Nenhum lead com este filtro.')));
tbody.replaceChildren(h('tr', {}, h('td', { colspan: '10', class: 'muted' }, 'Nenhum lead com este filtro.')));
return;
}
const abrirWhatsAppLead = async (event, lead) => {
event.stopPropagation();
if (!lead.whatsapp) {
toast('Este lead não tem WhatsApp cadastrado');
return;
}
let leadCompleto = lead;
try {
leadCompleto = await API.get(`/api/leads/${lead.id}`);
} catch {
leadCompleto = lead;
}
const settingsButton = el('btn-settings');
settingsButton.click();
setTimeout(() => {
window.GTISelecionarLeadManual?.(leadCompleto);
el('manual-numero').value = leadCompleto.whatsapp || lead.whatsapp;
el('manual-canal-naooficial').checked = true;
el('manual-canal-naooficial').dispatchEvent(new Event('change'));
el('manual-mensagem').value = `Olá ${leadCompleto.empresa || lead.empresa}! Somos do Grupo GTI. Podemos conversar?`;
el('manual-status').textContent = '';
}, 250);
};
tbody.replaceChildren(...data.rows.map((lead) => h('tr', { onclick: () => abrirLead(lead.id) },
h('td', { class: 'acao-col' }, h('button', {
class: 'whatsapp-action',
title: 'Enviar WhatsApp para este lead',
onclick: (event) => abrirWhatsAppLead(event, lead)
}, '☎')),
h('td', { class: 'empresa-cell', title: lead.legal_name || lead.empresa }, lead.empresa),
h('td', {}, lead.whatsapp || '—'),
h('td', {}, lead.cidade),