fix(vk-gateway): prevent bridge 500 drops and improve error resilience
This commit is contained in:
@@ -182,6 +182,11 @@ async function sendTelegramHumanLead(lead) {
|
||||
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
body,
|
||||
});
|
||||
if (res.ok) {
|
||||
console.log(`[vk-endpoint] human lead sent user=${lead.user_id || '-'} email=${lead.email || '-'} phone=${lead.phone || '-'}`);
|
||||
} else {
|
||||
console.log(`[vk-endpoint] human lead send failed user=${lead.user_id || '-'} status=${res.status}`);
|
||||
}
|
||||
return res.ok;
|
||||
}
|
||||
|
||||
@@ -353,6 +358,9 @@ async function askOpenClaw(payload) {
|
||||
}
|
||||
|
||||
return payloadOut;
|
||||
} catch (e) {
|
||||
console.error(`[vk-endpoint] askOpenClaw error user=${userKey}: ${e.message}`);
|
||||
return { reply: 'Я ИИ-агент по бронированию «Парадиз». Сейчас есть техническая задержка, но я на связи. Напишите, пожалуйста, даты и состав гостей — продолжу подбор.' };
|
||||
} finally {
|
||||
clearTimeout(t);
|
||||
}
|
||||
@@ -378,8 +386,9 @@ const server = http.createServer(async (req, res) => {
|
||||
res.writeHead(200, { 'content-type': 'application/json' });
|
||||
res.end(JSON.stringify(out));
|
||||
} catch (e) {
|
||||
res.writeHead(500, { 'content-type': 'application/json' });
|
||||
res.end(JSON.stringify({ error: 'bridge_failed', detail: e.message }));
|
||||
console.error(`[vk-endpoint] inbound error: ${e.message}`);
|
||||
res.writeHead(200, { 'content-type': 'application/json' });
|
||||
res.end(JSON.stringify({ reply: 'Я ИИ-агент по бронированию «Парадиз». Произошла техническая ошибка. Напишите, пожалуйста, ещё раз одним сообщением: даты, гости и контакт для связи.' }));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user