Commit graph

9 commits

Author SHA1 Message Date
81e09a4e2b feat: add business hours, media handling, and DSGVO consent
- BusinessHoursChecker: loads schedule from CMS site-settings,
  sends auto-away messages outside business hours with next-open time
- Media handling: image+caption forwarded to LLM, image-only/doc/audio/
  video get appropriate responses, stickers ignored, location acknowledged
- DSGVO ConsentManager: interactive buttons for consent, revocation
  keywords, consent logging via API key to consent-logs collection
- ConversationManager: consent fields (consentGiven, consentTimestamp)
  with grantConsent/revokeConsent methods
- InteractionWriter: media attachments stored as whatsapp-media references
- MessageRouter: integrates all features in order:
  business hours → consent → media → escalation → rules → LLM

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 16:17:30 +00:00
4b8fabc204 feat: make WhatsApp platform/account IDs configurable via env vars
WHATSAPP_PLATFORM_ID and WHATSAPP_ACCOUNT_ID can now be set in .env
to match CMS entity IDs on different environments (dev vs production).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 16:12:04 +00:00
c471e42592 fix: use nested objects for Payload group fields in InteractionWriter
Payload REST API expects group fields as nested objects (e.g.
`author: { name: "...", handle: "..." }`), not dot-notation or flat
field names. Also adds platform/socialAccount relationship IDs and
proper flags/analysis/response group fields.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 15:40:17 +00:00
CCS WhatsApp Bot
f098cca1bd fix: update Claude model, add JWT auth, fix CMS integration
- Update Claude model from claude-3-5-haiku-20241022 to claude-haiku-4-5-20251001
- Replace static API key auth with JWT login (auto-refresh before 2h expiry)
- Fix TemplateResolver: use 'template' field (not 'content'), remove non-existent tenant filter
- Fix RulesLoader: remove non-existent tenant filter from community-rules queries
- Update config: PAYLOAD_BOT_EMAIL/PASSWORD replace PAYLOAD_API_KEY

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 15:18:35 +00:00
22eb3d3e5c fix: health check uses isReachable() instead of authenticated find()
Payload API returns 403 without auth, which is fine for health checks.
New isReachable() method accepts any non-5xx response as healthy.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 14:15:20 +00:00
aefb566414 fix: remove colons from BullMQ queue names
BullMQ doesn't allow colons in queue names. Changed
'whatsapp:incoming' → 'whatsapp-incoming'.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 14:14:21 +00:00
1b0fafda24 fix: add --env-file=.env to PM2 node_args
Node.js doesn't load .env files automatically. Using Node 22's
native --env-file flag instead of adding dotenv dependency.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 14:13:23 +00:00
4b665f8909 refactor: switch InteractionWriter from direct DB to Payload REST API
Direct DB (pg Pool) not reachable from sv-whatsapp LXC to sv-postgres.
Using Payload REST API via PayloadClient as interim solution.
DATABASE_URL is now optional in config.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 14:12:30 +00:00
8847358507 feat: initial WhatsApp Business Bot scaffold
Phase 1 implementation with all core modules:
- Fastify webhook server with Meta signature validation
- WhatsApp Cloud API client (send text/template/interactive, mark as read)
- LLM abstraction layer with Claude provider (Haiku for speed)
- BullMQ message processing pipeline (dedup, rate limiting)
- Bot routing (MessageRouter, ConversationManager, EscalationManager)
- Payload CMS integration (InteractionWriter via direct DB, RulesLoader, TemplateResolver)
- Healthcare-safe system prompt with medical keyword detection
- PM2 ecosystem config

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 10:58:51 +00:00