The sendWhen constant is set to a Date object that represents the time at which the SMS should be sent. The sendScheduledSms() function is where the magic happens. This short application creates an instance of the Twilio client object and initializes it with the Account SID and Auth Token values that come from the environment variables you configured earlier. To keep things nicely organized, open a terminal or command prompt, find a suitable place, and create a new directory where the project you are about to create will live: In this section, you are going to set up a brand new Node project. In the “Body Text” enter some text to send yourself.Ĭlick the “Send test SMS” button, and make sure you receive the SMS on your phone. In the “From Messaging Service SID”, select the Messaging Service you just created. In the “To phone number” pulldown, select your personal number, which should be registered and verified with your Twilio account. It is a good idea to test that your messaging service is able to send messages, so go ahead and click on “Try sending a message”. You will now be offered the option to send a test message. To complete the configuration of your Messaging Service, click on “Complete Messaging Service Setup”. You don’t have to change any of the settings on this page, just click on “Step 4: Add compliance info”. Select Phone Number in the “Sender Type” dropdown, and click “Continue”.Īdd a checkmark next to the phone number you want to use as a sender, and click “Add phone numbers”.Ĭlick the “Step 3: Set up integration” button to move on to the next step. Click the “Add Senders” button to add the Twilio phone number you acquired in the previous section. In this part of the configuration, you have to add the sender phone number(s) to the sender pool used by the service. On the first page of the creation process, enter a friendly name for the service, such as “Appointments”, and select “Notify my users” in the “Select what you want to use Messaging for” dropdown.Ĭlick the “Create Messaging Service” button to move to the second step. Then click the “Create Messaging Service” button. Still in the Console, find the “Messaging” product and click on its Services option. Scheduled messages can only be sent from a Messaging Service at this time, so the next step is to configure one and add your Twilio phone number to it. After you confirm your purchase, click the “Close” button. If you’d like to request a number that is local to your region, you can enter your area code in the “Number” field.Ĭlick the “Search” button to see what numbers are available, and then click “Buy” for the number you like from the results. On the “Buy a Number” page, select your country and check SMS in the “Capabilities” field. Note that if you have a free account, you will be using your trial credit for this purchase. Log in to the Twilio Console, select Phone Numbers, and then click on the “Buy a number” button to buy a Twilio number. If you haven't done so already, your first task is to purchase a Twilio phone number to send SMS.
0 Comments
Leave a Reply. |