Fireship · @fireship

How I post banger tweets with artificial intelligence // Twitter Bot Tutorial

Uploaded February 3, 2022 · Length 9:23

How I post banger tweets with artificial intelligence // Twitter Bot Tutorial

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.

  1. 0:00

    a few weeks ago i taught you how to

  2. 0:01

    exploit the twitter algorithm to get a

  3. 0:03

    six-figure job in tech but there's just

  4. 0:05

    one major flaw with that strategy nobody

  5. 0:07

    learning how to code has time to tweet

  6. 0:09

    multiple times per day luckily you don't

  7. 0:11

    have to because today i'll teach you how

  8. 0:13

    to build a twitter bot from scratch that

  9. 0:15

    uses artificial intelligence to create

  10. 0:16

    unique high-value tweets all day long my

  11. 0:19

    twitter bot bob is coming up with

  12. 0:21

    awesome tweets at the top of the hour

  13. 0:22

    every hour and i only pay him like 10

  14. 0:24

    cents a day he tells funny jokes gives

  15. 0:26

    web dev hot takes promulgates conspiracy

  16. 0:28

    theories says nice things about his mom

  17. 0:30

    and humble brags about his 100 days of

  18. 0:31

    code journey he is my protege my magnum

  19. 0:34

    opus when i die he will be the one to

  20. 0:36

    carry the fire if you're new here like

  21. 0:37

    and subscribe because in today's

  22. 0:38

    tutorial you'll learn one of the most

  23. 0:40

    important techniques in web development

  24. 0:41

    today and that's how to work with the

  25. 0:43

    oauth 2.0 authentication protocol as a

  26. 0:46

    developer it opens the door to building

  27. 0:48

    apps that act on behalf of a user from

  28. 0:50

    another service like you might use it to

  29. 0:52

    upload files to google drive process

  30. 0:54

    payments with stripe connect or in our

  31. 0:56

    case post tweets to somebody's twitter

  32. 0:57

    account so before we jump into the code

  33. 0:59

    let's do a quick crash course on api

  34. 1:01

    authentication for twitter you'll first

  35. 1:03

    want to create a developer account then

  36. 1:05

    on the developer portal you can create a

  37. 1:06

    new application when you create an app

  38. 1:08

    it will give you an api key and api

  39. 1:10

    secret the api key is like a username

  40. 1:12

    while the secret is like a password

  41. 1:14

    these two values together create what's

  42. 1:16

    known as a bearer token to authenticate

  43. 1:18

    your developer app this token is

  44. 1:20

    included on an authorization header when

  45. 1:22

    making a request to the api that tells

  46. 1:24

    twitter who you are and what you have

  47. 1:25

    access to that's nice and easy but it

  48. 1:27

    just provides read-only access to public

  49. 1:30

    information on twitter that's because

  50. 1:31

    you don't automatically have access to

  51. 1:33

    somebody else's account to get

  52. 1:34

    permission from a user you'll need to go

  53. 1:36

    through the oauth 2.0 authorization code

  54. 1:38

    flow there are three steps in the

  55. 1:40

    process on the server you'll first need

  56. 1:42

    to create an authorization link that

  57. 1:43

    will redirect the user to twitter where

  58. 1:45

    they can grant access to your

  59. 1:46

    application from the browser once

  60. 1:48

    permission is granted twitter will then

  61. 1:50

    redirect them to a different endpoint on

  62. 1:52

    your server which is called the callback

  63. 1:54

    url that url will also include a special

  64. 1:56

    code that you'll need to verify on the

  65. 1:58

    server once verified twitter will give