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