I've got
MG...
)through which I'm sending out programmatic SMSs to various European countries. Some of these countries apparently don't support Alphanumeric IDs (e.g. Belgium).
So, assuming my code looks like this:
import twilio from "twilio";
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const messagingServiceSid = process.env.TWILIO_MESSAGING_SID;
const twilioClient = twilio(accountSid, authToken);
// https://www.twilio.com/docs/errors/21211 etc
const PhoneRelatedTwilioErrorCodes = [
21211, 20023, 21217, 21401, 21407, 21421, 21601, 21612, 22102
];
// ... more code
try {
messageResponse = await twilioClient.messages.create({
messagingServiceSid,
to: '123',
body: 'xyz'
});
} catch (twexc: any) {
// ...
}
I've got the following questions:
There's no need to fall back programmatically. The Messaging Service's Sender Pool needs a long code number to fall back to so you'll need to manually add a "Phone Number Sender" alongside your Alpha Sender ID:
Note for the discerning reader: the order of these senders doesn't really matter. Quoting the docs:
If you add an Alpha Sender to your Twilio Messaging Service, Twilio will select the Alphanumeric Sender ID automatically when you send a message to a supported country, unless you also have a short code number in that same country.