feat: appointment QR code — generated and sent via WhatsApp after booking

- QrService: generates QR PNG from appointment data, cached in-memory
- GET /api/messaging/qr/:appointmentId serves the image (Gupshup needs URL)
- sendImage added to MessagingProvider + GupshupProvider
- send_appointment_qr tool registered in ToolRegistry
- Flow JSON updated: QR sent after booking confirmation
- Variable interpolation now supports dot notation ({{result.field}})
- SIDECAR_PUBLIC_URL env var for the QR image URL

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-20 20:23:06 +05:30
parent 300fff25c1
commit d819888351
11 changed files with 313 additions and 18 deletions

View File

@@ -4,9 +4,15 @@ import { Injectable } from '@nestjs/common';
export class FlowVariableService {
// Replace {{variableName}} with values from session variables
interpolate(template: string, variables: Record<string, any>): string {
return template.replace(/\{\{(\w+)\}\}/g, (match, name) => {
const value = variables[name];
if (value === undefined || value === null) return match; // keep placeholder if unresolved
return template.replace(/\{\{([\w.]+)\}\}/g, (match, path) => {
// Support dot notation: {{bookingResult.appointmentId}}
const parts = path.split('.');
let value: any = variables;
for (const part of parts) {
value = value?.[part];
if (value === undefined) return match;
}
if (value === null) return match;
if (typeof value === 'object') return JSON.stringify(value);
return String(value);
});