Twilio - Updating the usage of the phone library

@zone6nft are you familiar with Node.js? I looked and Twilio’s API doesn’t appear to support sending SMS to multiple messages at one time. But you can add a Node.js code step to your workflow, link your Twilio account to that step, and write custom code to loop through your phone numbers, sending a message for each. I’d recommend taking a look at the Twilio docs for more information, but something like this should work:

const { phone } = require("phone");
const twilioClient = require("twilio");

const client = twilioClient(auths.twilio.Sid, auths.twilio.Secret, {
  accountSid: auths.twilio.AccountSid,
});

 // Enter all numbers in an array here
const numbers = ["+123...", "+456..."]

for (const num of numbers) {
  const toParsed = phone(num);
  if (!toParsed || !toParsed.phoneNumber) {
    throw new Error(`Phone number ${num} couldn't be parsed as a valid number.`);
  }

  const data = {
    to: toParsed.phoneNumber,
    from: <your from number here>,
    body: <your message here>,
  };

  await client.messages.create(data);
}
1 Like