Because Tessel runs Node, we can leverage the thousands of libraries that the Node community has made.
This code snippet makes Tessel send a tweet from a dummy account (@TesselTweet) that we’ve created for this purpose.
If you would prefer to post from your own account, go to apps.twitter.com, create your own OAuth tokens with read and write permissions, and paste them into the script.
Create a new directory within your “tessel-code” directory:
mkdir tessel-tweet; cd tessel-tweet; t2 init
Use npm to install the Twitter library that the Node.js community has built:
npm install twitter
Rename the “index.js” file you’ve just created to “tweet.js”, then copy and paste the below script over the existing text:
Change the “twitterHandle” var to your own Twitter handle and save.
Make sure you’re connected to Wifi, then run:
t2 run tweet.js
Bonus: Try making Tessel tweet output from a module.
Extra bonus: What’s another Node module you can try out? Maybe Twilio, PubNub, Plotly, Firebase? Surf around on npm until you find a Node library you like, then try using it with Tessel.