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) <noreply@anthropic.com>
This commit is contained in:
2026-04-20 15:37:30 +05:30
parent 214cc60917
commit d857a0b270
2 changed files with 5 additions and 5 deletions

View File

@@ -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);

View File

@@ -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',