fix(sms): send form confirmations to the lead number
Lead-only website forms had no person mobile, so the confirmation was marked sent without a number. Use the lead phone and send the full text. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -578,7 +578,7 @@ export class AutomationsService {
|
||||
const channel: AutomationNotifyChannel = config.notifyChannel ?? 'app';
|
||||
const wantApp = channel === 'app' || channel === 'both';
|
||||
const wantSms = channel === 'sms' || channel === 'both';
|
||||
const smsText = (config.body?.trim() || title).slice(0, 160);
|
||||
const smsText = (config.body?.trim() || title).trim();
|
||||
const link = entityLink(ctx);
|
||||
|
||||
if (config.notifyTarget === 'person') {
|
||||
@@ -592,9 +592,16 @@ export class AutomationsService {
|
||||
select: { mobile: true, phone: true },
|
||||
})
|
||||
: null;
|
||||
const leadId = ctx.leadId || (ctx.entityType === 'lead' ? ctx.entityId : null);
|
||||
const lead = !person?.mobile && !person?.phone && leadId
|
||||
? await this.prisma.lead.findFirst({
|
||||
where: { id: leadId, organizationId: ctx.organizationId },
|
||||
select: { mobile: true, phone: true },
|
||||
})
|
||||
: null;
|
||||
await this.sendAutomationSms(
|
||||
ctx.organizationId,
|
||||
person?.mobile || person?.phone,
|
||||
person?.mobile || person?.phone || lead?.mobile || lead?.phone || ctx.mobile,
|
||||
smsText,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user