Building a WhatsApp chatbot in Haitian Creole with an LLM
poze 4 months ago120 gadeen
0
Most of our users in Haiti are on WhatsApp all day but rarely install new apps. I want a support bot in Kreyòl that answers questions about our service. What's the architecture?
Anviwònman:Node.js 20Express
Dyagnostik IA
Se IA ki fè l. Se pa yon repons — kominote a anba a konfime oswa korije l. Toujou verifye anvan ou fye l.
poze 4 months ago
Marie Louis 2.2k
1 Repons
3
✓✓ Repons yo aksepte
Use the official WhatsApp Business Platform (Cloud API). Unofficial libraries that drive WhatsApp Web get numbers banned.
User ──WhatsApp──► Meta ──webhook──► your server ──► LLM (+ your FAQ/docs)
│
User ◄──WhatsApp── Meta ◄──send message───┘
// 1. Webhook verification (one-time GET from Meta)
app.get("/whatsapp/webhook", (req, res) => {
if (req.query["hub.verify_token"] === process.env.WA_VERIFY_TOKEN) return res.send(req.query["hub.challenge"]);
res.sendStatus(403);
});
// 2. Incoming messages
app.post("/whatsapp/webhook", async (req, res) => {
res.sendStatus(200); // acknowledge fast; Meta retries slow webhooks
const msg = req.body.entry?.[0]?.changes?.[0]?.value?.messages?.[0];
if (!msg || msg.type !== "text") return;
const history = await loadRecentTurns(msg.from, 10); // short memory per phone number
const answer = await askModel({
system: "Ou se asistan sipò [Sèvis]. Reponn an kreyòl ayisyen, kout (maks 4 fraz). " +
"Sèvi sèlman ak enfòmasyon ki nan DOKIMAN yo. Si ou pa konnen, di sa epi bay nimewo sipò a.",
docs: await retrieveRelevantFaq(msg.text.body), // RAG over your FAQ
history,
user: msg.text.body,
});
await sendWhatsAppText(msg.from, answer);
await saveTurn(msg.from, msg.text.body, answer);
});
Practical points:
- Verify webhook signatures (the
X-Hub-Signature-256header) before processing. - 24-hour window: you can reply freely within 24 hours of the user's last message. Starting a conversation later requires pre-approved templates.
- Keep answers short. Long paragraphs are painful on small screens and cost more.
- Offer a "pale ak yon moun" (talk to a human) escape, and hand off when the model isn't confident.
- Rate-limit per phone number, so one user or a spam loop can't burn your AI budget.
Konekte pou di lòt moun si li te mache.
answered 4 months ago
David Charles 2.9k
Sign in and verify your email to post an answer.