diff --git a/server/src/routes/webhook-sms.ts b/server/src/routes/webhook-sms.ts index 3a4e718..2161cee 100644 --- a/server/src/routes/webhook-sms.ts +++ b/server/src/routes/webhook-sms.ts @@ -54,6 +54,24 @@ export function createWebhookSmsRouter(deps: WebhookSmsRouterDeps): Router { // Respond quickly — Vonage expects a 200 within a few seconds res.status(200).json({ status: 'received' }); + const body = (req.body ?? {}) as Record; + const rawText = typeof body.text === 'string' ? body.text : ''; + logger.info( + { + event: 'sms.webhook_inbound_payload', + contentType: req.headers['content-type'], + bodyKeys: Object.keys(body), + bodyRedacted: { + ...body, + from: typeof body.from === 'string' ? maskPhone(body.from) : body.from, + to: typeof body.to === 'string' ? maskPhone(body.to) : body.to, + msisdn: typeof body.msisdn === 'string' ? maskPhone(body.msisdn) : body.msisdn, + text: rawText ? `${rawText.slice(0, 80)}${rawText.length > 80 ? '…' : ''}` : body.text, + }, + }, + 'Inbound webhook payload (redacted)' + ); + // Process async handleInbound(req.body, deps).catch(err => { logger.error({ event: 'sms.handler_error', error: (err as Error).message }, 'SMS handler error');