Give a loving gift that will make her heart melt! I May Not Be Your First Date, Your First Kiss Or Your First Love, But I Just Want To Be Your Last EveryThing. Only Then Would You Realize How Special You Are To Me, And That You Are That Best Thing That Ever Happened To Me. If I Could Give You One Thing In Life, I Would Give You The Ability To See Yourself Through My Eyes. You can see that I added a currentMessage counter which will be incremented every time we send a message, this way we're going to loop over the entire array of messages.Couples Gifts Necklace To My Soulmate Necklace Birthday Christmas Jewelry Romantic Gifts For My Wife with Message Card Box Personalized Gift Present Pendant for Future Wife Soulmate Girlfriend We can combine them into the final code: const cron = require('node-cron') I only added 3 messages above, but you can fill the array up until you get to 24 messages. `In a sea of people, my eyes always search for you.` `If you were a movie, I'd watch you over and over again.`, `If I could give you one thing in life, I'd give you the ability to see yourself through my eyes, only then would you realize how special you are to me.`, We need a list of 24 romantic messages, so for that let's create a messages.js file and put all the messages in there inside an array. The TO number (this is the number we want to send the message to).The FROM number (this is the trial number created above).You can see that the () function required three things: const config = require('./config') Ĭonst client = require('twilio')(accountSid, authToken) Let's do that and also let's create the sendMessage() function, which will. config.js file.Īlong with the ACCOUNT_SID and AUTH_TOKEN we can also store the PHONE_NR of our loved one as we are going to use this to tell Twilio where to send the message TO. We need to install the Twilio package: npm install twilio and we need to use the data we stored inside the. Now that we have everything in place, let's go back to our code! This number will be used to send the messages FROM. The next thing will be to create a Trial Number (you can find the button on the /console page). This is a secret key so we're going to store them inside this "secret" config.js file. We need these to call the Twilio API so we are going to store them inside a config.js file. Here you'll get the ACCOUNT SID and AUTH TOKEN. In there they'll ask you a couple of questions like: "What programming language are you using?" You can pick Node.js and then you'll end up on the /console page. (I had to "steal" my wife's phone in order to verify the number ?) You need to verify your email address and also verify the number you want to send the message to. We need a Twilio acount, so head over to and create one. We don't have the sendMessage() function yet, but we'll create it later.Īlso, in case you don't know how the CRON string works, here is an awesome website where you can test it out.īasically '0 * * * *' means: Run every hour at 0 minutes, so it will run at: 00:00, 01:00, 02:00, etc. Next, we're going to schedule a function to run every hour: const cron = require('node-cron') For the lazy ones out there, here is a Video Tutorial: Create a CRON jobįirst, we need to create a CRON job which will run a function every hour.įor that, let's install the node-cron package into our NodeJS app: In this short tutorial I'm going to show you how to do it. How awesome would it be to do it automatically using a Node.js script? We are after all. How nice would it be if you sent a Romantic Message every hour to your loved one? But even better.
0 Comments
Leave a Reply. |