mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage-server
synced 2026-05-18 20:08:19 +00:00
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:
@@ -231,7 +231,7 @@ ${callerContext ? `\n${callerContext}` : ''}`;
|
|||||||
if (!deptDocs.length) return { sent: false, message: `No doctors found in ${department}.` };
|
if (!deptDocs.length) return { sent: false, message: `No doctors found in ${department}.` };
|
||||||
|
|
||||||
const sections: ListSection[] = [{
|
const sections: ListSection[] = [{
|
||||||
title: department,
|
title: department.substring(0, 24),
|
||||||
rows: deptDocs.slice(0, 10).map((d: any) => {
|
rows: deptDocs.slice(0, 10).map((d: any) => {
|
||||||
const docName = `Dr. ${d.fullName?.firstName ?? ''} ${d.fullName?.lastName ?? ''}`.trim();
|
const docName = `Dr. ${d.fullName?.firstName ?? ''} ${d.fullName?.lastName ?? ''}`.trim();
|
||||||
const fee = d.consultationFeeNew?.amountMicros
|
const fee = d.consultationFeeNew?.amountMicros
|
||||||
@@ -299,11 +299,11 @@ ${callerContext ? `\n${callerContext}` : ''}`;
|
|||||||
}
|
}
|
||||||
|
|
||||||
const sections: ListSection[] = [{
|
const sections: ListSection[] = [{
|
||||||
title: `${doctorName} — ${targetDate}`,
|
title: targetDate, // section title max 24 chars
|
||||||
rows: timeSlots.map((s) => ({
|
rows: timeSlots.map((s) => ({
|
||||||
id: `slot:${doctorId}:${targetDate}T${s.time}:00`,
|
id: `slot:${doctorId}:${targetDate}T${s.time}:00`,
|
||||||
title: s.time,
|
title: s.time, // row title max 24 chars
|
||||||
description: s.clinic,
|
description: s.clinic || undefined,
|
||||||
})),
|
})),
|
||||||
}];
|
}];
|
||||||
await provider.sendList(phone, `Available slots for ${doctorName}:`, 'View Slots', sections);
|
await provider.sendList(phone, `Available slots for ${doctorName}:`, 'View Slots', sections);
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ export class GupshupProvider extends MessagingProvider {
|
|||||||
params.append('message', message);
|
params.append('message', message);
|
||||||
params.append('src.name', this.appId);
|
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, {
|
const resp = await fetch(this.apiUrl, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
Reference in New Issue
Block a user