From d857a0b270fecd3945a78a150e0179c9efa541ec Mon Sep 17 00:00:00 2001 From: saridsa2 Date: Mon, 20 Apr 2026 15:37:30 +0530 Subject: [PATCH] fix(messaging): truncate WhatsApp list section titles to 24 char limit WhatsApp list messages have strict limits: section title max 24 chars, row title max 24 chars. Long doctor names + dates in section titles caused Gupshup to silently drop the list options. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/messaging/messaging.service.ts | 8 ++++---- src/messaging/providers/gupshup.provider.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/messaging/messaging.service.ts b/src/messaging/messaging.service.ts index 2e68e0e..8101e82 100644 --- a/src/messaging/messaging.service.ts +++ b/src/messaging/messaging.service.ts @@ -231,7 +231,7 @@ ${callerContext ? `\n${callerContext}` : ''}`; if (!deptDocs.length) return { sent: false, message: `No doctors found in ${department}.` }; const sections: ListSection[] = [{ - title: department, + title: department.substring(0, 24), rows: deptDocs.slice(0, 10).map((d: any) => { const docName = `Dr. ${d.fullName?.firstName ?? ''} ${d.fullName?.lastName ?? ''}`.trim(); const fee = d.consultationFeeNew?.amountMicros @@ -299,11 +299,11 @@ ${callerContext ? `\n${callerContext}` : ''}`; } const sections: ListSection[] = [{ - title: `${doctorName} — ${targetDate}`, + title: targetDate, // section title max 24 chars rows: timeSlots.map((s) => ({ id: `slot:${doctorId}:${targetDate}T${s.time}:00`, - title: s.time, - description: s.clinic, + title: s.time, // row title max 24 chars + description: s.clinic || undefined, })), }]; await provider.sendList(phone, `Available slots for ${doctorName}:`, 'View Slots', sections); diff --git a/src/messaging/providers/gupshup.provider.ts b/src/messaging/providers/gupshup.provider.ts index a8020ac..279887a 100644 --- a/src/messaging/providers/gupshup.provider.ts +++ b/src/messaging/providers/gupshup.provider.ts @@ -123,7 +123,7 @@ export class GupshupProvider extends MessagingProvider { params.append('message', message); params.append('src.name', this.appId); - this.logger.log(`[GUPSHUP] Sending to ${to}: ${message.substring(0, 100)}...`); + this.logger.log(`[GUPSHUP] Sending to ${to}: ${message.substring(0, 500)}`); const resp = await fetch(this.apiUrl, { method: 'POST',