Skip to content

fix(novu-bridge): channel-aware dispatch so SMS works - #44

Closed
ChakshuGautam wants to merge 1 commit into
nairobifrom
fix/novu-bridge-sms-channel
Closed

fix(novu-bridge): channel-aware dispatch so SMS works#44
ChakshuGautam wants to merge 1 commit into
nairobifrom
fix/novu-bridge-sms-channel

Conversation

@ChakshuGautam

Copy link
Copy Markdown
Owner

Summary

whatsapp was hardcoded in 4 places inside novu-bridge, so even with channel=sms configured in MDMS the dispatch path silently coerced everything into Twilio's WhatsApp pipeline. This is why OTP went out (override path was used directly) but Kafka-driven SMS notifications never worked.

What changed

  • NovuBridgeConfiguration / application.properties / compose — default channel flipped from WHATSAPPSMS. SMS works out-of-the-box with any Twilio sender; WhatsApp requires a pre-approved Programmable WhatsApp number we don't ship.
  • TwilioProviderStrategywhatsapp: prefix on sender number now keyed off ResolvedProvider.channel. For non-WhatsApp channels, also defensively strips any whatsapp: prefix that leaked in from MDMS data.
  • DispatchPipelineServiceformatWhatsappPhone() renamed to formatRecipientPhone() and made channel-aware. Only prepends whatsapp: on the recipient number when channel=whatsapp. (This was the load-bearing bug — Twilio was rejecting SMS triggers because the To address looked like a WhatsApp address.)
  • PreferenceServiceClientisWhatsAppAllowed() renamed to isChannelAllowed(channel); consent lookup is now consent.get(channel.toUpperCase()) instead of hardcoded "WHATSAPP". A user with SMS=GRANTED but no WHATSAPP entry would otherwise be silently denied.

Test plan

🤖 Generated with Claude Code

The bridge had `whatsapp` hardcoded in three places, so even with
`channel=sms` in TemplateBinding/ProviderDetail the dispatch path
silently coerced everything into Twilio's WhatsApp pipeline:

  1. NovuBridgeConfiguration / application.properties / compose all
     defaulted to NOVU_BRIDGE_CHANNEL=WHATSAPP. Flipped to SMS — works
     out of the box with any Twilio SMS sender; WhatsApp requires a
     pre-approved Programmable WhatsApp sender that we don't ship.

  2. TwilioProviderStrategy unconditionally prepended `whatsapp:` to
     the sender number. Now keys off ResolvedProvider.channel:
     whatsapp → adds prefix, sms/other → strips any stray prefix that
     leaked in from MDMS data.

  3. DispatchPipelineService.formatWhatsappPhone() unconditionally
     prepended `whatsapp:` to the *recipient* number too. Renamed to
     formatRecipientPhone(), now takes channel and only prefixes for
     whatsapp. This was the load-bearing bug — Twilio rejected SMS
     trigger requests because the To address looked like a WhatsApp
     address.

  4. PreferenceServiceClient.isWhatsAppAllowed() hard-coded
     consent.get("WHATSAPP"). Renamed to isChannelAllowed(channel)
     and looks up consent.get(channel.toUpperCase()). Without this,
     a user with SMS=GRANTED but no WHATSAPP entry would be denied.

Verified end-to-end SMS delivery via Kafka pipeline on subhashini
(NOVU_BRIDGE_CHANNEL=SMS, Twilio account in trial mode, recipient
verified in Twilio console).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ec2beb79-ba53-4f26-a86a-cca78855c5e4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/novu-bridge-sms-channel

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@KDwevedi

Copy link
Copy Markdown
Collaborator

Pulled into #52 (the canonical channel-aware novu-bridge dispatch via config.getChannel()). Closing as merged-via-#52.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants