diff --git a/src/notification/twilio.ts b/src/notification/twilio.ts index 86f3ac2e3f..c1243df361 100644 --- a/src/notification/twilio.ts +++ b/src/notification/twilio.ts @@ -17,17 +17,24 @@ export function sendTwilioMessage(link: Link, store: Store) { (async () => { const givenUrl = link.cartUrl ? link.cartUrl : link.url; const message = `${Print.inStock(link, store)}\n${givenUrl}`; - - try { - await client.messages.create({ - body: message, - from: twilio.from, - to: twilio.to - }); - logger.info('✔ twilio message sent'); - } catch (error: unknown) { - logger.error("✖ couldn't send twilio message", error); + const numbers = twilio.to.split(','); + const results = []; + for (const number of numbers) { + try { + results.push( + client.messages.create({ + body: message, + from: twilio.from, + to: number + }) + ); + logger.info('✔ twilio message sent'); + } catch (error: unknown) { + logger.error("✖ couldn't send twilio message", error); + } } + + await Promise.all(results); })(); } }