Skip to content

Fixes SMS not sending for country codes not supporting alphanumeric sender IDs#5969

Merged
CarinaWolli merged 12 commits intomainfrom
fix/sms-sender-id
Dec 12, 2022
Merged

Fixes SMS not sending for country codes not supporting alphanumeric sender IDs#5969
CarinaWolli merged 12 commits intomainfrom
fix/sms-sender-id

Conversation

@CarinaWolli
Copy link
Copy Markdown
Member

@CarinaWolli CarinaWolli commented Dec 10, 2022

What does this PR do?

Not all countries support alphanumeric sender IDs for SMS sending. Here is the list of countries supporting/not supporting it: Supported Countries

This caused that SMS sending didn't work for some countries. With this PR we now check if the country code supports alphanumeric sender Ids and then won't use them if it's not supported.

Fixes #5943

Environment: Staging(main branch)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How should this be tested?

  • Test workflow SMS action with a phone number that does not support alphanumeric sender IDs
  • Test workflow SMS action with a phone number that does support alphanumeric sender IDs

@vercel
Copy link
Copy Markdown

vercel Bot commented Dec 10, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
cal ✅ Ready (Inspect) Visit Preview Dec 12, 2022 at 9:57AM (UTC)

? reminder.booking?.attendees[0].timeZone
: reminder.booking?.user?.timeZone;

const isAlphanumericSenderIdSupported = !noAlphanumericSenderIdSupport.find(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If country code is not in list, then the alphanumeric sender id is supported

Comment thread packages/features/ee/workflows/lib/reminders/smsProviders/twilioProvider.ts Outdated
@@ -0,0 +1,75 @@
export const noAlphanumericSenderIdSupport = [
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

List of country codes that don't support alphanumeric sender IDs:
Supported Countries
Country codes from here: Country Codes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we throw an error if the country is not supported?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@PeerRich We don't throw an error, but if alphanumeric sender ids are not supported SMS are still sent with our twilio phone number (instead of the sender id)

Copy link
Copy Markdown
Contributor

@pumfleet pumfleet left a comment

Choose a reason for hiding this comment

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

Great PR! I've left a couple of comments about a file name (and subsequently it's imports) being misspelt as well as a hardcoded phone number, but otherwise all good :)

Comment thread packages/features/ee/workflows/api/scheduleSMSReminders.ts Outdated
Comment thread packages/features/ee/workflows/api/scheduleSMSReminders.ts Outdated
Comment thread packages/features/ee/workflows/components/WorkflowStepContainer.tsx Outdated
Comment thread packages/features/ee/workflows/lib/reminders/smsProviders/twilioProvider.ts Outdated
Comment thread packages/features/ee/workflows/lib/aphanumericSenderIdSupport.ts Outdated
Comment thread packages/features/ee/workflows/lib/reminders/smsReminderManager.ts Outdated
Copy link
Copy Markdown
Contributor

@emrysal emrysal left a comment

Choose a reason for hiding this comment

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

- const isAlphanumericSenderIdSupported = !noAlphanumericSenderIdSupport.find(
-     (code) => code === reminderPhone?.substring(0, code.length)
-   );
-   const senderID = isAlphanumericSenderIdSupported ? sender : "";
+ getSenderId(reminderPhone)
// or
+ getSenderId(sendTo) // returns process.env.TWILIO_SENDER_ID = "Cal" || ""
  1. getSenderId Should be the function exposed through the library - this way you can reduce the duplicate code.
  2. The SENDER_ID should be an environment variable (optional) - defaulting to Cal - allowing self hosters to easily update the SENDER_ID. Perhaps should be non-twilio-specific.

@emrysal emrysal added the docs area: docs, documentation, cal.com/docs label Dec 10, 2022
@@ -0,0 +1,87 @@
import { SENDER_ID } from "@calcom/lib/constants";

export function getSenderId(phoneNumber?: string | null, sender?: string | null) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@emrysal added the getSenderId function and also added a new constant SENDER_ID which is the new NEXT_PUBLIC_SENDER_ID env variable (if empty, "Cal" as a fallback)

Copy link
Copy Markdown
Contributor

@emrysal emrysal left a comment

Choose a reason for hiding this comment

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

🚀 Perfect!

@CarinaWolli CarinaWolli dismissed pumfleet’s stale review December 12, 2022 11:00

already approved

@CarinaWolli CarinaWolli merged commit c1bbb9b into main Dec 12, 2022
@CarinaWolli CarinaWolli deleted the fix/sms-sender-id branch December 12, 2022 11:00
@alishaz-polymath alishaz-polymath removed the docs area: docs, documentation, cal.com/docs label Jan 29, 2023
@PeerRich PeerRich added the core area: core, team members only label Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core area: core, team members only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CAL-574] SMS reminder not working for workflows

6 participants