DEV Community

Cover image for How to build and deploy a multifunctional Twitter bot

How to build and deploy a multifunctional Twitter bot

Scott Spence on May 24, 2017

I've been busy building Twitter bots again! If you take a look at my GitHub profile, you'll see that I have quite a few repos relating to Twitter ...
Collapse
 
bendiuguid profile image
Ben Diuguid • Edited

Awesome tutorial!

I was deploying my twitter-bot with now.sh and it appears that you need to run a web server or you can encounter errors while deploying, might want to modify you're deployment to include a simple node http server like the following

const {createServer} = require('http');

const server = createServer(() => {});

server.listen(3000);
Enter fullscreen mode Exit fullscreen mode

For more info check this GitHub Issue

Collapse
 
spences10 profile image
Scott Spence

Thanks Ben, I came across this issue as well the other day. If you want I'd happily accept a PR for this.

Collapse
 
stellarstoic profile image
StellarStoic

Thank you for your time writing such an extensive article.
But since I'm a n00b in JS and coding in general, I still have no idea how can I grab certain data from the nonTwitter API and tweet this data with my bot. The address where my data is is @ flysafe.klv.si/mobile/flights .But the bot will only tweet if the flight is longer then 100 km. Do I have to parse the data first or the twitter stream API is all I need?

Collapse
 
spences10 profile image
Scott Spence

Hey @simplepotato thanks for taking the time to read through it.

It is quite an extensive post going over the examples which I hope gives you a better understanding of how to use the API.

It has been a while since I have done anything with the Twitter API so I'm not sure I'm the best person to ask my friend.

If it is a case of logic on some of the data then maybe add some conditional logic before it gets to the tweet?

Collapse
 
stellarstoic profile image
StellarStoic • Edited

It surely gave me better understanding about bots. One of the best post out there. Well im going to figure it out the one way or another ☺ Thanks

Thread Thread
 
spences10 profile image
Scott Spence

Good luck 💪

Collapse
 
cmilr profile image
Cary Miller

Wow! Really exhaustive writeup. Thanks for this!

Collapse
 
ben profile image
Ben Halpern

Wow, really great tutorial!

Collapse
 
spences10 profile image
Scott Spence

Thanks Ben, it's a bit of a whopper isn't it? How did you find it to read?

Collapse
 
vcoelho profile image
desempregado

So it runs locally? I'm not familiar with the JS stack, but to my understanding you run the script once and kept restarting the function when needed?

Collapse
 
spences10 profile image
Scott Spence

It's setInterval that triggers the functions. There's also the streams which triggers on Twitter events, like when someone follows you.