fix(novu-bridge): channel-aware dispatch so SMS works - #44
Closed
ChakshuGautam wants to merge 1 commit into
Closed
Conversation
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>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Collaborator
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
whatsappwas hardcoded in 4 places inside novu-bridge, so even withchannel=smsconfigured 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 fromWHATSAPP→SMS. SMS works out-of-the-box with any Twilio sender; WhatsApp requires a pre-approved Programmable WhatsApp number we don't ship.TwilioProviderStrategy—whatsapp:prefix on sender number now keyed offResolvedProvider.channel. For non-WhatsApp channels, also defensively strips anywhatsapp:prefix that leaked in from MDMS data.DispatchPipelineService—formatWhatsappPhone()renamed toformatRecipientPhone()and made channel-aware. Only prependswhatsapp: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.)PreferenceServiceClient—isWhatsAppAllowed()renamed toisChannelAllowed(channel); consent lookup is nowconsent.get(channel.toUpperCase())instead of hardcoded"WHATSAPP". A user with SMS=GRANTED but no WHATSAPP entry would otherwise be silently denied.Test plan
mvn clean package -DskipTestsNOVU_BRIDGE_CHANNEL=SMScomplaints.domain.events→ bridge → Novu → Twilio SMS delivered (requires MDMS TemplateBinding seed from fix(notif-seed): align seed.sh + schemas with live config-service behavior (corrections for #37) #41)/user-otpstill delivers (regression check)🤖 Generated with Claude Code