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

@@ -1,6 +1,8 @@
import { Controller, Post, Body, Logger } from '@nestjs/common';
import { Controller, Post, Get, Body, Param, Res, Logger } from '@nestjs/common';
import type { Response } from 'express';
import { MessagingProvider } from './providers/messaging-provider.interface';
import { MessagingService } from './messaging.service';
import { QrService } from './qr.service';
@Controller('api/messaging')
export class MessagingController {
@@ -9,6 +11,7 @@ export class MessagingController {
constructor(
private readonly provider: MessagingProvider,
private readonly messaging: MessagingService,
private readonly qr: QrService,
) {}
@Post('webhook')
@@ -33,4 +36,17 @@ export class MessagingController {
return { status: 'ok' };
}
// Serve QR code images — Gupshup needs a public URL to send images
@Get('qr/:appointmentId')
async serveQr(@Param('appointmentId') appointmentId: string, @Res() res: Response) {
const png = this.qr.get(appointmentId);
if (!png) {
res.status(404).json({ error: 'QR code not found or expired' });
return;
}
res.set('Content-Type', 'image/png');
res.set('Cache-Control', 'public, max-age=86400');
res.send(png);
}
}