fix(bridge): 转人工提示只输出单一语言并补齐 es/tr
This commit is contained in:
@@ -17,17 +17,24 @@ function createEscalation({ client, handoffUserId = 1 }) {
|
|||||||
const text = String(reply || '').replace(/\s+$/, '');
|
const text = String(reply || '').replace(/\s+$/, '');
|
||||||
const hints = {
|
const hints = {
|
||||||
zh: '您想转人工客服吗?',
|
zh: '您想转人工客服吗?',
|
||||||
|
en: 'Would you like to speak to a human agent?',
|
||||||
de: 'Möchten Sie mit einem Mitarbeiter sprechen?',
|
de: 'Möchten Sie mit einem Mitarbeiter sprechen?',
|
||||||
fr: 'Souhaitez-vous parler à un conseiller ?',
|
fr: 'Souhaitez-vous parler à un conseiller ?',
|
||||||
it: 'Vuole parlare con un operatore?',
|
it: 'Vuole parlare con un operatore?',
|
||||||
nl: 'Wilt u met een medewerker spreken?',
|
nl: 'Wilt u met een medewerker spreken?',
|
||||||
|
es: '¿Desea hablar con un agente humano?',
|
||||||
|
tr: 'Bir insan temsilcisiyle görüşmek ister misiniz?',
|
||||||
};
|
};
|
||||||
|
// 只输出一种语言:按用户输入判断语言,识别不到时用英文;不再拼英文兜底。
|
||||||
let lang = null;
|
let lang = null;
|
||||||
if (/[\u4e00-\u9fff]/.test(query)) lang = 'zh';
|
if (/[\u4e00-\u9fff]/.test(query)) lang = 'zh';
|
||||||
|
else if (/[ğışç]/i.test(query) || /\b(merhaba|istiyorum|konuşmak|temsilci|fiyat|ürün|sipariş)\b/i.test(query)) lang = 'tr';
|
||||||
else if (/[äöüß]/i.test(query)) lang = 'de';
|
else if (/[äöüß]/i.test(query)) lang = 'de';
|
||||||
else if (/[éèêëàâùûîïôç]/i.test(query)) lang = 'fr';
|
else if (/[ñ¿¡]/i.test(query) || /\b(hola|quiero|hablar|agente|puedo|gracias|precio|pedido)\b/i.test(query)) lang = 'es';
|
||||||
|
else if (/\b(vorrei|parlare|operatore|desidera|posso|prezzo|ordine)\b/i.test(query)) lang = 'it';
|
||||||
|
else if (/[éèêëàâùûîïôç]/i.test(query) || /\b(bonjour|merci|conseiller|commande|livraison|prix|voudrais)\b/i.test(query)) lang = 'fr';
|
||||||
else if (/\b(hoe|voor|wilt|bent|geen|verzending|levering|bestelling)\b/i.test(query)) lang = 'nl';
|
else if (/\b(hoe|voor|wilt|bent|geen|verzending|levering|bestelling)\b/i.test(query)) lang = 'nl';
|
||||||
const option = lang ? `\n\n${hints[lang]} / Would you like to speak to a human agent?` : '\n\nWould you like to speak to a human agent?';
|
const option = `\n\n${hints[lang] || hints.en}`;
|
||||||
return text + option;
|
return text + option;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user