fix: AI recall follow-up message repeats "Great" and buries office hours
When the AI rejects a requested time in the recall booking flow, it reused the same "Great, what time..." template used for a fresh ask, producing an awkward double-greeting right after a rejection, and appended office hours as a bare fragment instead of framing them as a sentence.
This commit is contained in:
@@ -328,6 +328,29 @@ const ASK_TIME_FALLBACKS: Record<string, (dateLabel: string) => string> = {
|
|||||||
"Haitian Creole": (d) => `Bon, ki lè nan ${d} ki bon pou ou?`,
|
"Haitian Creole": (d) => `Bon, ki lè nan ${d} ki bon pou ou?`,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Same follow-up question as ASK_TIME_FALLBACKS, without the leading "Great,"
|
||||||
|
// greeting — used when it directly follows a rejection sentence, where the
|
||||||
|
// greeting would read as redundant filler.
|
||||||
|
const ASK_TIME_PLAIN_FALLBACKS: Record<string, (dateLabel: string) => string> = {
|
||||||
|
English: (d) => `What time on ${d} works for you?`,
|
||||||
|
Spanish: (d) => `¿Qué hora le viene bien el ${d}?`,
|
||||||
|
Portuguese: (d) => `Que horário funciona para você em ${d}?`,
|
||||||
|
Mandarin: (d) => `您 ${d} 哪个时间方便?`,
|
||||||
|
Cantonese: (d) => `您 ${d} 邊個時間方便?`,
|
||||||
|
Arabic: (d) => `ما الوقت المناسب لك في ${d}؟`,
|
||||||
|
"Haitian Creole": (d) => `Ki lè nan ${d} ki bon pou ou?`,
|
||||||
|
};
|
||||||
|
|
||||||
|
const OFFICE_HOURS_ARE_FALLBACKS: Record<string, string> = {
|
||||||
|
English: "Our office hours are",
|
||||||
|
Spanish: "Nuestro horario de atención es",
|
||||||
|
Portuguese: "Nosso horário de atendimento é",
|
||||||
|
Mandarin: "我们的营业时间是",
|
||||||
|
Cantonese: "我們嘅營業時間係",
|
||||||
|
Arabic: "ساعات عملنا هي",
|
||||||
|
"Haitian Creole": "Orè biwo nou se",
|
||||||
|
};
|
||||||
|
|
||||||
const CLOSED_DAY_FALLBACKS: Record<string, (day: string) => string> = {
|
const CLOSED_DAY_FALLBACKS: Record<string, (day: string) => string> = {
|
||||||
English: (day) => `We're closed on ${day}s. What other day works for you?`,
|
English: (day) => `We're closed on ${day}s. What other day works for you?`,
|
||||||
Spanish: (day) => `Estamos cerrados los ${day}. ¿Qué otro día le viene bien?`,
|
Spanish: (day) => `Estamos cerrados los ${day}. ¿Qué otro día le viene bien?`,
|
||||||
@@ -450,8 +473,9 @@ async function resolveDateTime(
|
|||||||
Arabic: `نحن غير متاحين في ذلك الوقت يوم ${dateLabel}.`,
|
Arabic: `نحن غير متاحين في ذلك الوقت يوم ${dateLabel}.`,
|
||||||
"Haitian Creole": `Nou pa disponib nan lè sa a nan ${dateLabel}.`,
|
"Haitian Creole": `Nou pa disponib nan lè sa a nan ${dateLabel}.`,
|
||||||
};
|
};
|
||||||
const askTime = (ASK_TIME_FALLBACKS[lang] ?? ASK_TIME_FALLBACKS["English"]!)(dateLabel);
|
const askTime = (ASK_TIME_PLAIN_FALLBACKS[lang] ?? ASK_TIME_PLAIN_FALLBACKS["English"]!)(dateLabel);
|
||||||
const hours = hoursDisplay ? ` ${hoursDisplay}.` : "";
|
const officeHoursAre = OFFICE_HOURS_ARE_FALLBACKS[lang] ?? OFFICE_HOURS_ARE_FALLBACKS["English"]!;
|
||||||
|
const hours = hoursDisplay ? ` ${officeHoursAre} ${hoursDisplay}.` : "";
|
||||||
return { reply: `${base[lang] ?? base["English"]}${hours} ${askTime}`, nextStage: "recall_asked_time_for_date" };
|
return { reply: `${base[lang] ?? base["English"]}${hours} ${askTime}`, nextStage: "recall_asked_time_for_date" };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user