Parameterized message tutorial continued
Create your file to send a message
Create a new file namedindex.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 usingteam
, you may have something like fav_charity
, last_purchase
or address
. The sky is the limit!- Assign your values to the following parameters:
Parameter | Your value |
---|---|
SERVICE_PLAN_ID | The service plan ID found on your Sinch Customer Dashboard. SMS > APIs > REST configuration |
API_TOKEN | The API token found on your Sinch Customer dashboard. SMS > APIs > REST configuration > Click Show to reveal your API token. |
SINCH_NUMBER | A 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_NUMBER | The phone number to which you want to send the test SMS message. |
parameter_key | The parameters from your database. We have used firstName and team in our sample. |
msisdn | In 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 . |
- Save the file.
Send your customized SMS message
Now you can execute the code and send your test SMS message.
Run the following command:
node index.mjs
msisdn
, you should have recieved an SMS message!Need to go back to the previous step?Next steps
- Find other useful code samples in our API reference.
- Check out another tutorial.