Skip to content

feat(whatsapp): Phase 3 advanced features — templates, SMS, interactive, voice (WHATSAPP-001 Phase 3, #299 follow-up) #468

Open
1 of 2 issues completed

Description

@vybe

Summary

Umbrella tracking issue for WHATSAPP-001 Phase 3. Phase 1 (#299) shipped direct-message chat. Phase 2 (#467) wires access control. Phase 3 unlocks advanced Twilio capabilities: outbound-first messaging, SMS, interactive UX, voice transcription.

Each bullet below can be split into its own issue when picked up — kept together here so we can evaluate scope and sequencing as one conversation.

Context

Phase 1 operates inside Twilio's 24-hour customer-service window (an inbound message opens the window; freeform outbound is free within it). This is fine for reactive agents but blocks:

  • Scheduled/proactive notifications to WhatsApp users
  • Initiating conversations from the agent side
  • Rich UX beyond plain text

Phase 3 addresses each with targeted Twilio primitives. No single item here is urgent — ship only if demand appears.

Acceptance Criteria (checklist of sub-features)

3a — Message templates (outbound-first / post-24h messaging)

  • Twilio Content Builder integration: register + reference pre-approved templates
  • Template storage: whatsapp_templates table (template_sid, name, category, placeholders schema, approval status)
  • Outbound send helper accepts template_name + variables → builds payload → routes via Content API
  • Error 63016 ("outside window") now falls back to template send if one is configured
  • UI: list registered templates per agent, show approval status
  • Unit tests for template payload construction

3b — SMS on same Twilio binding

  • Reuse whatsapp_bindings row (drop whatsapp: prefix for SMS routes)
  • New SmsAdapter subclassing ChannelAdapter OR extend WhatsAppAdapter with a medium flag — pick whichever is cleaner after review
  • Router logic: From: +E164 (no prefix) vs From: whatsapp:+E164 dispatches to appropriate adapter
  • Rate limiting keyed on twilio_sms:{binding_id}:{phone}
  • UI: checkbox on Sharing panel "Also accept SMS to this number"
  • Session identity: decide whether SMS + WhatsApp from the same phone share a session (likely yes — same verified_email)

3c — Interactive messages (buttons, list pickers)

  • Twilio Content API quick-reply buttons and list messages
  • Agent response parser: detect structured markup (e.g., custom fenced block) → convert to interactive payload
  • Inbound: ButtonPayload field arrives as Body with button ID — map to a deterministic agent prompt ("User selected: ")
  • Template approval considerations (interactive templates need separate Meta approval)

3d — Voice-note transcription

  • Twilio sends audio/ogg (WhatsApp voice notes) in MediaUrl0
  • Extend message_router.py:212 voice-transcription branch to include channel == "whatsapp" — today Telegram-only
  • Reuse services/telegram_media.py::process_voice if MIME-agnostic, else add whatsapp_media helper
  • Download via existing SSRF-gated WhatsAppAdapter.download_file → Whisper API → replace placeholder in prompt
  • Unit tests for voice transcription path

Technical Notes

Related

Sub-issues

Sub-issues

1 of 2 Issues completed
Loading 2 sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-highpriority-p3status-incubatingtheme-channelstype-feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions