Fireship · @fireship
How I post banger tweets with artificial intelligence // Twitter Bot Tutorial
Uploaded February 3, 2022 · Length 9:23
Summary
build a twitter bot with artificial intelligence to post tweets using oauth 2.0 and node.js
- twitter bot
- artificial intelligence
- oauth 2.0
- node.js
- twitter api
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
a few weeks ago i taught you how to
- 0:01
exploit the twitter algorithm to get a
- 0:03
six-figure job in tech but there's just
- 0:05
one major flaw with that strategy nobody
- 0:07
learning how to code has time to tweet
- 0:09
multiple times per day luckily you don't
- 0:11
have to because today i'll teach you how
- 0:13
to build a twitter bot from scratch that
- 0:15
uses artificial intelligence to create
- 0:16
unique high-value tweets all day long my
- 0:19
twitter bot bob is coming up with
- 0:21
awesome tweets at the top of the hour
- 0:22
every hour and i only pay him like 10
- 0:24
cents a day he tells funny jokes gives
- 0:26
web dev hot takes promulgates conspiracy
- 0:28
theories says nice things about his mom
- 0:30
and humble brags about his 100 days of
- 0:31
code journey he is my protege my magnum
- 0:34
opus when i die he will be the one to
- 0:36
carry the fire if you're new here like
- 0:37
and subscribe because in today's
- 0:38
tutorial you'll learn one of the most
- 0:40
important techniques in web development
- 0:41
today and that's how to work with the
- 0:43
oauth 2.0 authentication protocol as a
- 0:46
developer it opens the door to building
- 0:48
apps that act on behalf of a user from
- 0:50
another service like you might use it to
- 0:52
upload files to google drive process
- 0:54
payments with stripe connect or in our
- 0:56
case post tweets to somebody's twitter
- 0:57
account so before we jump into the code
- 0:59
let's do a quick crash course on api
- 1:01
authentication for twitter you'll first
- 1:03
want to create a developer account then
- 1:05
on the developer portal you can create a
- 1:06
new application when you create an app
- 1:08
it will give you an api key and api
- 1:10
secret the api key is like a username
- 1:12
while the secret is like a password
- 1:14
these two values together create what's
- 1:16
known as a bearer token to authenticate
- 1:18
your developer app this token is
- 1:20
included on an authorization header when
- 1:22
making a request to the api that tells
- 1:24
twitter who you are and what you have
- 1:25
access to that's nice and easy but it
- 1:27
just provides read-only access to public
- 1:30
information on twitter that's because
- 1:31
you don't automatically have access to
- 1:33
somebody else's account to get
- 1:34
permission from a user you'll need to go
- 1:36
through the oauth 2.0 authorization code
- 1:38
flow there are three steps in the
- 1:40
process on the server you'll first need
- 1:42
to create an authorization link that
- 1:43
will redirect the user to twitter where
- 1:45
they can grant access to your
- 1:46
application from the browser once
- 1:48
permission is granted twitter will then
- 1:50
redirect them to a different endpoint on
- 1:52
your server which is called the callback
- 1:54
url that url will also include a special
- 1:56
code that you'll need to verify on the
- 1:58
server once verified twitter will give


