feat: probe 30s, no [] wrapper, show webhook reply in chat + auto-open panel

This commit is contained in:
oliver
2026-04-24 13:50:54 -03:00
parent 08798cdeb5
commit d4f81c03cd
+38 -7
View File
@@ -2025,6 +2025,17 @@
return wrap;
}
/* ── public API for probe script ────────────────────────── */
window._mbs = {
appendMsg: appendMsg,
openSilent: function () {
greeted = true; /* suppress default welcome message */
panel.classList.add("open");
panel.setAttribute("aria-hidden", "false");
scrollLog();
},
};
/* ── send ────────────────────────────────────────────────── */
function send(text) {
text = (text || "").trim();
@@ -2331,17 +2342,37 @@
fetch(CHAT_URL, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify([
{
body: JSON.stringify({
action: "sendMessage",
chatid: chatId,
chatInput: buildMsg(geo),
},
]),
}).catch(function () {}); /* silently ignore errors */
}),
})
.then(function (res) {
var ct = res.headers.get("content-type") || "";
if (ct.indexOf("json") !== -1) return res.json();
return res.text().then(function (t) {
return { output: t };
});
})
.then(function (d) {
var item = Array.isArray(d) ? d[0] : d;
var reply =
(item &&
(item.output ||
item.text ||
item.message ||
item.reply)) ||
(typeof d === "string" ? d : null);
if (reply && window._mbs) {
window._mbs.appendMsg("agent", reply);
window._mbs.openSilent();
}
})
.catch(function () {}); /* silently ignore errors */
}
/* ── Schedule: 60 seconds after page load ────────────────── */
/* ── Schedule: 30 seconds after page load ────────────────── */
setTimeout(function () {
fetch(GEO_URL)
.then(function (res) {
@@ -2353,7 +2384,7 @@
.catch(function () {
fire(null);
});
}, 60000);
}, 30000);
})();
</script>