This commit is contained in:
2026-02-26 10:11:26 +01:00
parent 110f937eba
commit 9df0d5d78d

View File

@@ -254,9 +254,9 @@ function showFallback() {
// ─── n8n Webhook (#5.2, #6) ────────────────────────────────── // ─── n8n Webhook (#5.2, #6) ──────────────────────────────────
async function postWebhook(path, body) { async function postWebhook(body) {
const base = (CFG.webhook_base || '').replace(/\/$/, ''); const url = (CFG.webhook_base || '').replace(/\/$/, '');
const res = await fetch(`${base}${path}`, { const res = await fetch(url, {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body), body: JSON.stringify(body),
@@ -268,6 +268,7 @@ async function postWebhook(path, body) {
async function startSession(entry) { async function startSession(entry) {
const payload = { const payload = {
action: 'start',
entry, entry,
sponsor: window.FESTIVAL.sponsor, sponsor: window.FESTIVAL.sponsor,
session_id: window.FESTIVAL.session_id, session_id: window.FESTIVAL.session_id,
@@ -277,7 +278,7 @@ async function startSession(entry) {
}; };
const typing = showTyping(); const typing = showTyping();
try { try {
const data = await postWebhook('/festival/start', payload); const data = await postWebhook(payload);
if (typing) typing.remove(); if (typing) typing.remove();
const reply = (data?.reply && typeof data.reply === 'string') const reply = (data?.reply && typeof data.reply === 'string')
? data.reply ? data.reply
@@ -304,6 +305,7 @@ async function sendMessage(text) {
appendBubble('user', text); appendBubble('user', text);
const payload = { const payload = {
action: 'message',
session_id: window.FESTIVAL.session_id, session_id: window.FESTIVAL.session_id,
entry: window.FESTIVAL.entry, entry: window.FESTIVAL.entry,
sponsor: window.FESTIVAL.sponsor, sponsor: window.FESTIVAL.sponsor,
@@ -313,7 +315,7 @@ async function sendMessage(text) {
const typing = showTyping(); const typing = showTyping();
try { try {
const data = await postWebhook('/festival/message', payload); const data = await postWebhook(payload);
if (typing) typing.remove(); if (typing) typing.remove();
const reply = (data?.reply && typeof data.reply === 'string' && data.reply.trim()) const reply = (data?.reply && typeof data.reply === 'string' && data.reply.trim())
? data.reply : '…'; ? data.reply : '…';