Skip to content

feat: add Twilio SMS notification channel#3534

Merged
ajhollid merged 3 commits into
bluewave-labs:developfrom
egeoztass:feat/twilio-sms-notification
Apr 20, 2026
Merged

feat: add Twilio SMS notification channel#3534
ajhollid merged 3 commits into
bluewave-labs:developfrom
egeoztass:feat/twilio-sms-notification

Conversation

@egeoztass
Copy link
Copy Markdown
Contributor

Summary

  • Adds Twilio SMS as a new notification channel (Feature Request: Add Twilio SMS Notification Support #3095)
  • Users can configure their Twilio Account SID, Auth Token, From number (Twilio), and To number (recipient) to receive SMS alerts
  • Follows the exact same provider pattern as Pushover, Telegram, Discord, etc.

Changes

Backend (7 files)

  • New: twilio.ts provider — sends via Twilio REST API with HTTP Basic Auth
  • Registered in notification types, MongoDB model enum, Zod validation
  • Wired into NotificationsService (both send and sendTestNotification routing)
  • Instantiated in services.ts, exported from service index

Frontend (5 files)

  • Added "twilio" to NotificationChannels type
  • Added Zod validation schema (all 4 fields required)
  • Added form defaults in useNotificationForm hook
  • Added form UI with 4 fields: Account SID, Auth Token, From number, To number
  • Added English i18n keys (other languages via PoEditor)

Tests (2 files)

  • New: Twilio provider test suite — 18 tests covering all paths
  • Updated NotificationsService test constructor with twilioProvider

Field mapping

Uses existing Notification schema fields — no schema migration needed:

  • address → Account SID
  • accessToken → Auth Token
  • homeserverUrl → From number (Twilio number)
  • phone → To number (recipient)

Test plan

  • Run npm test -- --testPathPatterns="twilioProvider" — all 18 tests pass
  • Run npm test -- --testPathPatterns="notificationsService" — all 24 tests pass
  • Start dev server, navigate to Notifications → Create
  • Select "twilio" from channel type dropdown
  • Verify form shows Account SID, Auth Token, From number, and To number fields
  • Save and verify notification appears in the list
  • Edit existing Twilio notification and verify fields are pre-populated

Closes #3095

🤖 Generated with Claude Code

Adds Twilio SMS as a new notification channel, allowing users to
receive SMS alerts via the Twilio API.

Backend: provider using HTTP Basic Auth, type registration, validation,
service wiring. Uses existing fields: address (Account SID),
accessToken (Auth Token), homeserverUrl (From number), phone (To number).
Frontend: form UI with 4 fields, validation, i18n keys.
Tests: 18 provider tests + updated service test constructor.

Closes bluewave-labs#3095

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@egeoztass
Copy link
Copy Markdown
Contributor Author

Screenshot

Twilio SMS notification channel form with Account SID, Auth Token, From number, and To number fields:
Ekran Resmi 2026-04-16 21 48 38

Copy link
Copy Markdown
Collaborator

@ajhollid ajhollid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good 👍

We can declare bespoke fields for twilio here rather than reusing homserverUrl, and we need a couple more tests here.

Thanks for your hard work!

Comment on lines +86 to +89
address: z.string().min(1, "Account SID is required"),
accessToken: z.string().min(1, "Auth token is required"),
phone: z.string().min(1, "Recipient phone number is required"),
homeserverUrl: z.string().min(1, "Twilio phone number is required"),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than repurpose the address and homerserverUrl fiels for something they weren't intended for, let's add new fields.

We've already got notification type specific fields like homeserverUrl, so we may as well add twilioPhoneNumber and accountSID or whatever is appropriate here.

Please remember to update repositories/models after making this change. Thanks!

Comment on lines 111 to +114
case "pushover":
return await this.pushoverProvider.sendMessage!(notification, notificationMessage);
case "twilio":
return await this.twilioProvider.sendMessage!(notification, notificationMessage);
Copy link
Copy Markdown
Collaborator

@ajhollid ajhollid Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two cases (Pushover and Twiliio) are untested, please add the appropriate tests and check coverage by running npm run test

Comment on lines +179 to +180
case "twilio":
return await this.twilioProvider.sendTestAlert(notification);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also uncovered

- Added `accountSid` and `twilioPhoneNumber` fields to Notification
  type, MongoDB model, and frontend type instead of reusing
  `address` and `homeserverUrl`
- Updated provider, validation, form hook, and form UI to use new fields
- Added Pushover and Twilio to notificationsService routing tests
  (both handleNotifications and sendTestNotification)
- All 59 tests passing

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@egeoztass
Copy link
Copy Markdown
Contributor Author

Both issues addressed:

  1. Dedicated fields — Added accountSid and twilioPhoneNumber as new fields on the Notification type, MongoDB model, and frontend type. No longer reusing address and homeserverUrl. Updated provider, validation, form, and tests accordingly.

  2. Service switch case tests — Added pushover and twilio to both the handleNotifications routing test and the sendTestNotification routing test in notificationsService.test.ts.

All 59 tests passing (18 Twilio provider + 15 Pushover provider + 26 notifications service).

Updated both MongoDB and TimescaleDB repositories to map the new
Twilio-specific fields (accountSid, twilioPhoneNumber) in create,
update, and toEntity methods.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@ajhollid ajhollid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, but there is no migration for the TimescaleDB implementation. The columns have been added to the query, but they don't exist. Postgres is not forgiving like mongo and won't create columns that don't exist. Let's be sure to add that migration 👍

Other than that, do we care if the account SID and Twilio phone number are compromised? They are currently sent from the BE to the FE in plain text.

If they are sensitive, they probably shouldn't be returned at all.

Comment on lines +143 to +144
accountSid: row.account_sid ?? undefined,
twilioPhoneNumber: row.twilio_phone_number ?? undefined,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we care if these are returned unmasked? I don't know if these are sensitive or not

Copy link
Copy Markdown
Collaborator

@ajhollid ajhollid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@egeoztass an executive decision has just been made to only support MongoDB and drop TimescaleDB for maintenance reasons.

I'm going to merge this now with the caveat that you can review and open a new PR with regards to the plaintext return of the account SID and Twilio phone number if needed.

Thanks for another great PR!

@ajhollid ajhollid merged commit 984a611 into bluewave-labs:develop Apr 20, 2026
5 checks passed
@egeoztass
Copy link
Copy Markdown
Contributor Author

Follow-up PR for the sensitive field masking: #3559

Masks accessToken and accountSid in all notification API responses, and strips masked values on edit to avoid overwriting real credentials.

@harsh-aghara harsh-aghara mentioned this pull request Apr 21, 2026
10 tasks
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.

Feature Request: Add Twilio SMS Notification Support

2 participants