In part one of this series, we discussed building a small app that checks whether Target has any Xbox Series Xs in stock. Our plan is to do this using Puppeteer and automating the usage of Chrome to open the appropriate web page.
In part 2, we will extend the previous code to send an SMS (text) message to your phone when the app detects that there is stock available.
We could send an email, but do you really notice emails quickly? I don’t. We could send a push notification to a mobile application. I like this option, but I don’t want to create a separate app so that I can receive push notifications. An easier option is to use SMS.
Sending SMS messages requires a third-party provider. Probably one of the most popular providers right now is Twilio. So our next step is to go to Twilio and sign up for SMS. You can do this with a trial account.
In the Twilio UI, you will be able to get an Account SID and an Auth Token, which you will need to send SMS messages.
We also need to install the Twilio npm package.
npm install twilio
- Our “sending” phone number (specified within Twilio)
- Our “receiving” phone number
- The message body
The code sending an SMS is straightforward and makes extending our stock tracker pretty easy. Our next step will be scheduling our checker to run every five minutes.