/ Cases / Restaurants / Voice
It answers the landline and WhatsApp calls using the same data as the chat bot: hours, addresses and bookings come from the database, not from the model's memory.
0
made-up facts: everything comes from the database
2
lines: landline and WhatsApp
/ The problem
The phone rang at rush hour and nobody could pick up. The first AI version once made up a location landmark: a confident voice saying something false is worse than no answer.
/ What we built
/ How it works
/ Real code
const query = String(args.query ?? '').trim();
if (!query) {
return { ok: false as const, speech: '¿Sobre qué tema le puedo ayudar?' };
}
const res = await searchKnowledge({ query, brand: args.brand ? String(args.brand) : undefined });
if (!res.ok || res.results.length === 0) {
return {
ok: false as const,
speech:
'Ese dato no lo tengo a la mano. Si gusta lo comunico con una persona del equipo que se lo confirma.',
};
}
// Solo el mejor resultado y aplanado: los chunks del RAG traen markdown,
// listas y precios que leídos de corrido son incomprensibles por teléfono.
// Devolvemos `resumir: true` para que el prompt sepa que ESTO NO se lee
// literal — el modelo debe condensarlo en una o dos frases.
const texto = ventanaRelevante(aptoParaVoz(res.results[0].snippet), query, 700);
return {
ok: true as const,
resumir: true,
speech: texto,
data: { results: res.results.slice(0, 2) },
};
}
■ If the database lacks the answer, the voice offers a human instead of making it up; what it does find is flattened to be spoken over the phone.
/ Stack