Parameterized message tutorial continued

Create your file to send a message

Create a new file named index.mjs in the project and paste the provided "Send a parameterized SMS message" code into the file.

Fill in your parameters

Any parameters below with curly brases can be switched out for parameters from your own database. For example, we are using team, you may have something like fav_charity, last_purchase or address. The sky is the limit!
  1. Assign your values to the following parameters:
ParameterYour value
SERVICE_PLAN_IDThe service plan ID found on your Sinch Customer Dashboard. SMS > APIs > REST configuration
API_TOKENThe API token found on your Sinch Customer dashboard. SMS > APIs > REST configuration > Click Show to reveal your API token.
SINCH_NUMBERA free test number or any Sinch virtual number you've rented. Find the number on your Sinch Customer Dashboard by clicking the service plan ID link and scrolling to the bottom of the page.
TO_NUMBERThe phone number to which you want to send the test SMS message.
parameter_keyThe parameters from your database. We have used firstName and team in our sample.
msisdnIn the API reference, you'll see msisdn. This is the phone number you are sending a message to. For testing, use your own phone number. In our sample, it's 14051234567.
  1. Save the file.

Send your customized SMS message

Now you can execute the code and send your test SMS message.

Run the following command:

Copy
Copied
node index.mjs
If you used your own phone number as the msisdn, you should have recieved an SMS message!Need to go back to the previous step?

Next steps

We'd love to hear from you!
Rate this content:
Still have a question?
 
Ask the community.