You’ll notice all of these keys and tokens are blank. We get to fill them in 😄We’ll go in order.

Remember when you signed up for Twitter’s API? Head back there. If you didn’t already, click “Create New App”. Fill out all the required fields. For website, you can put https://twitter.com/ because we’re not going to use this. If you did want to create a site explaining how you’re using Twitter’s API and what your app does, you would put that link here. Then click “Create your Twitter application”.

Once you see a message saying “Your application has been created”, navigate to “Keys and Access Tokens”. Copy both the Consumer Key and Consumer Secret and add them to the respective variables in you .env file.

Then scroll down and click “Create my access token”. Copy both your Access Token and Access Token Secret and add them to the .env file as well.

Next, navigate to the Twilio console and locate your Account SID and Auth Token. Add both of those to the .env . Add your cell phone number to PHONE_NUMBER . Grab the Twilio phone number you purchased earlier and add that to the TWILIO_NUMBER .

The last API token we need is for Firebase. Go to the Firebase console and click “Add project”. After you’ve given it a name and gone through the basic steps, head over to the Service Accounts tab in your project’s settings page. Click the Generate New Private Key button at the bottom of the Firebase Admin SDK section of the Service Accounts tab. After clicking this a JSON file will be generated with your service account key and authentication tokens.

Rename this file to serviceAccountKey.json (note the camel-case) and move it inside the root folder of your project on your local machine.

Woo, we’re ¾ done.

Expose Port With NGROK

Open up the terminal or command line and run ngrok http 1337 . This will expose our local server and allow Twilio to communicate with it. Copy the https URL you see towards the bottom. It should look something like this —> https://42e12834.ngrok.io

Configure Twilio Number

Head back over to the Twilio console and navigate to the phone numbers. Click on the phone number you purchased earlier and then scroll down to messaging.

Where it says “A MESSAGE COMES IN” – Webhook – add the ngrok url you copied a second ago and then append “/sms” after it. It should look something like this:

Configure API_URL and Round Variables

The last two things we need to add are the API_URL and the round variables. Open up the Firebase Console and click on Database on the left-hand side. You should see a link with your project that you can copy. It’ll look something like “https://project-name.firebaseio.com/”.

Copy that and then go into the project, inside app.js and find const API_URL . Replace the URL inside the quotes with your URL and add “/round1.json”. The “1” stands for the round you’re on. So if this is your 2 or 3 round, change that accordingly. It should look something remotely like this: const API_URL = 'https://myproject.firebaseio.com/round1.json’

Last, inside the getMessage() function change the const round to the same number you’re using in your API_URL variable.

Example: const round = 1

Ready For The Magic?

Inside the terminal or command line, change directories until you’re inside the root of the project. Then run node app.js to start the Node app. If you see

Express server listening on port 1337. Let's get coding 🎉 ! it means you are ready to start turning texts into tweets.

Go ahead and test it out by sending a text from your phone to your Twilio phone number.



Open up Twitter and watch it show up!

HUUUUZZAAAH you did it, congratulations. Now go out there and finish the other 99 days of your #100DaysOfCode! 😁👻🎉

If you liked this tutorial, tweet me @jsjoeio and let me know :)