feat(backend): add whatsapp messaging integration via twilio#19
feat(backend): add whatsapp messaging integration via twilio#19saad-gsoft wants to merge 12 commits into
Conversation
add complete whatsapp integration module with text, media, and template message support, conversation tracking, and webhook handling for incoming messages and status callbacks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tion # Conflicts: # pnpm-lock.yaml
|
|
Fixes broken lockfile missing scmp@2.1.0 entry. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
1 similar comment
|
|
Fixes Applied1. Orphaned inbound webhook data
2. Missing env varsAdded 3. Unit testsAdded Known: Mongoose direct usageSame as #17/#18 — uses Mongoose models directly. Should be migrated to repository pattern when rebasing onto a DB branch. |
|
…missing env vars - Look up user by phone number in handleIncomingMessage to associate inbound whatsapp records with a user, preventing orphaned data - Add TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, TWILIO_WHATSAPP_NUMBER, and TWILIO_WEBHOOK_BASE_URL to .env.example and Joi schema Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests cover: generateConversationId, sendTextMessage, handleIncomingMessage (with/without user association, text and media), getMessageById, getConversation, handleStatusCallback. Twilio client and Mongoose mocked. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move getUserRepository require to top-level import in whatsapp.service.js and remove unused httpStatus import from test file. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
88b909d to
30e2afa
Compare
|
|
This PR has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. |
Summary
services/backend/src/modules/v1/whatsapp/) with text, media, and template message support via Twilio WhatsApp APINew Files
services/backend/src/modules/v1/whatsapp/whatsapp.model.js— WhatsAppMessage Mongoose schemaservices/backend/src/modules/v1/whatsapp/whatsapp.service.js— All WhatsApp business logicservices/backend/src/modules/v1/whatsapp/whatsapp.controller.js— HTTP controllersservices/backend/src/modules/v1/whatsapp/whatsapp.validation.js— Joi schemas + E.164 validatorservices/backend/src/modules/v1/whatsapp/whatsapp.routes.js— Express routes + Swagger JSDocservices/backend/src/modules/v1/whatsapp/index.js— Barrel exportsservices/backend/src/middlewares/twilioWebhook.js— Twilio signature validation middlewareModified Files
services/backend/package.json— Addedtwilio: ^5.0.0services/backend/src/config/config.js— Added Twilio/WhatsApp env var validationservices/backend/src/config/roles.js— AddedsendWhatsappto user,sendWhatsapp+manageWhatsappto adminservices/backend/src/modules/v1/index.js— Mounted whatsapp routesservices/backend/src/middlewares/index.js— ExportvalidateTwilioSignatureservices/backend/.env.example— Added 4 Twilio/WhatsApp env varsservices/backend/docs/swagger/components.yml— Added WhatsAppMessage, Conversation schemasREADME.md— Added WhatsApp endpoints documentationEnv Vars
Test plan
pnpm install— twilio dependency installspnpm lint— no ESLint errorsPOST /v1/whatsapp/messageswith bodyPOST /v1/whatsapp/messageswith mediaUrlsPOST /v1/whatsapp/messageswith templateName🤖 Generated with Claude Code