How I Replaced Buffer to Post in Twitter (With n8n)

Twitter. The Popular Microblogging & Social Networking Platform which has more active users. No matter what niche you’re into. There is always discussion going on Twitter.

But. I want to make use of it. And for weird reason I hate using Buffer.

Why limit our-self to some third party tool if we have God sent n8n?

Here is my use case:

I want to constantly share the articles with our users in Twitter. At the same time not with Buffer. Because buffer has limitation (It’s just a Scheduler)

So I built my own with n8n.

Nodes Used:

  • Cron (for Trigger)
  • Google Sheets (For Storing our Post Title, Link, Hashtag)
  • Function Node (with some code. To Pick Random Single Row from Google Sheet. YOU CAN COPY PASTE THE CODE)
  • Twitter Node (To Post a Tweet)

Here is how it looks like.

Short and Sweet Right?

And Have a look inside Google Sheets.

image

Here is how it works.

  • Cron Node will trigger at a time.
  • Google Node fetches all the row from Sheet
  • Function Node pick one row
  • Tweet Node post it

Easy right?

Bonus: In n8n you can change the timezone of your Workflow. You can pick the time according to your niche or business.

That’s it.

🎁 Workflow Code
{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "const newItems = [];\n\nrandom_row = items[Math.floor(Math.random() * Math.floor(items.length))];\nnewItems.push(random_row);\n\nreturn newItems;\n"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        1020,
        330
      ]
    },
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "hour": 9
            }
          ]
        }
      },
      "name": "Cron",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [
        670,
        330
      ]
    },
    {
      "parameters": {
        "text": "={{$node[\"Function\"].json[\"Title\"]}} {{$node[\"Function\"].json[\"Link\"]}}\n{{$node[\"Function\"].json[\"Hashtag\"]}}",
        "additionalFields": {}
      },
      "name": "Twitter",
      "type": "n8n-nodes-base.twitter",
      "typeVersion": 1,
      "position": [
        1220,
        330
      ],
      "credentials": {
        "twitterOAuth1Api": "Twitter FOSS IO Bot"
      }
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "sheetId": "1BxYyTE_zc2mj8o1YiztQbQj1GzN_MYAyj7muGI6IY_M",
        "range": "A:C",
        "options": {}
      },
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        850,
        330
      ],
      "credentials": {
        "googleSheetsOAuth2Api": "blpsheets"
      }
    }
  ],
  "connections": {
    "Function": {
      "main": [
        [
          {
            "node": "Twitter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cron": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Important:

  • You need Twitter API: http://developers.twitter.com/
  • Play safe with Twitter API
  • Make sure you have atleast 50-80 Rows in Google Sheets with Different Text and Hashtag

Please comment your Thoughts. (Helps to motivate me :heart:)

3 Likes

Thanks, @mcnaveen for making this. I’ve been planning to do something similar to this for a while now. I will try it out and share my feedback soon :slightly_smiling_face:

1 Like

Sure @harshil1712 bro :heart: n8n is fun.

Edit: Finally verified my n8n account. I’ll share more workflows soon.

3 Likes

I use the same to publish on LinkedIn, Facebook, … :slight_smile:

2 Likes

Very cool @mcnaveen ! This post made me think of Retool. We had an internal hackathon at n8n in December and I finally got to try it out with n8n. It’s is an awesome no-code tool for making frontend UIs for internal apps. We hacked a dashboard together in one day without any prior Retool experience (and consumed n8n workflows as a Restful API endpoint via the Webhook trigger node).

If at any point you want to make a lightweight front-end UI for this workflow, I recommend checking it out :slight_smile:

3 Likes

That’s Great @maxT n8n is really a game changer :heart:

Happy to be a Part of n8n user family :tada:

3 Likes