w
This commit is contained in:
@@ -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 : '…';
|
||||
|
||||
Reference in New Issue
Block a user