This section applies to Rebar only.
The unit for sending SMS is based on the service provided by Twilio. It takes care of sending SMS and error handling.
In /configuration/units/rb-sms/server/settings.js
populate the SMSRecipientSubstitution
setting with rules for replacement of an SMS recipient. This setting is useful in a development environment, where during testing one would like all SMS messages to be sent to only one phone number instead of the phone numbers of real users.
In the example below, for development
environment (as specified by NODE_ENV), we would send all emails to (123) 456-7890
:
export const SMSRecipientSubstitution = {
'development': [
{ match: /[\s\S]*/, replacement: '+11234567890' }
]
}
From the Twilio console https://www.twilio.com/console retrieve your account's SID
and AUTH_TOKEN
:
In .env
specify:
SMS_TWILIO_ACCOUNT_SID=abc
SMS_TWILIO_AUTH_TOKEN=xyz
using the values above.
In the SMS services section https://www.twilio.com/console/sms/services create a service:
Assign a number to it like shown below:
In .env
specify:
SMS_TWILIO_PHONE_NUMBER=+1xxxyyyzzzz
using the value above.
In order to send an SMS use code like the following:
SMSSender.sendSMS(
'+11234567890', // to
'Reminder from Pacific Gadget', // body
)