How to Use n8n to Share a Photo on a Facebook Page and Leave a Comment

In today’s digital landscape, automation tools are revolutionizing the way we manage our online presence, making it easier than ever to engage with audiences across various platforms. One such powerful tool is n8n, an open-source workflow automation software that allows users to connect different applications and automate tasks seamlessly.

In this blog post, we will explore how to leverage n8n to share a photo on your Facebook page while leaving a comment, streamlining your social media management process.

Whether you’re a small business owner looking to enhance your online engagement or a social media enthusiast aiming to simplify your posting routine, this guide will provide you with step-by-step instructions to harness the full potential of n8n for your Facebook interactions.\

Here’s an example of a workflow that gets an image and caption from a Google Sheet, and posts the photo to Instagram and Facebook, then leaves a comment on the Facebook post. This article will focus on Facebook specifically.

how to n8n Share a Photo on a Facebook Page and Leave a Comment

What You’ll Need

Ensure you have a Permanent Facebook Page Open Graph access token, so you don’t have to authenticate every few months.

Ensure your Facebook page is linked to a Business Portfolio: https://business.facebook.com/latest/settings/pages

Prepare Your Images and Captions

Populate a Google Sheet or Airtable Base with 3 columns: Your Image URL, Caption, and a “Shared” column to ensure you don’t post the same image twice.

Here’s an example. Mine has more columns because I use it for Pinterest sharing also.

Sample google sheet with images and captions for Social media sharing n8n
Social media sheet example

Add a Sheets Node to your n8n Workflow

Add the Sheets node to your n8n Workflow. Choose the Operation “Get Rows”. Add a Filter to search for the “Shared” column as empty. Finally, under “Options” add the option to “Return only First Matching Row” and turn it on to green.

Add a Facebook Node to Your Workflow

Next, connect a “Facebook Graph API” node. Change the name to “Facebook Photo” so it’s clear what the node does.

Credential to connect with – Add your Facebook credential here using the Permanent token.
Host URL – Default
HTTP Request Method – POST
Graph API Version – v21.0
Node – me
Edge – photos

Options
Query Parameters
Name – url
Value – {{ $json[‘Image URL’] }}
Name – caption
Value – {{ $json.Caption }}

n8n Share Facebook Photo
Photo

That’s all you need to share a photo on your Facebook Page!

Leave a Comment on the Photo You Just Posted

If you want to leave a comment on your photo then connect another “Facebook Graph API” node. Change the name to “Comment” so you remember what the node does.

Edit the Node Parameters:

Credential to connect with – Select your Facebook credential.
Host URL – Default
HTTP Request Method – POST
Graph API Version – v21.0
Node – {{ $json.post_id }}
Edge – comments

Options
Query Parameters
Name – message
Value – YOUR_COMMENT_GOES_HERE

Be sure to pull in the $json.post_id from the “INPUT” Schema section of the previous node so you leave a comment on the photo you just posted.

n8n Leave Facebook Comment
Comment

Optional: Mark as Done

Finally, add a Sheets node to mark the image as shared. Find the same document and add an Operation to “Update Row.” Choose row_number as the “Column to match on.” Under “Values to Update” add your “Shared” column and write in the value as “true.”

This will ensure the next time you run the Workflow, a new Facebook image row that has not yet been shared is selected.

Enjoyed this post? Subscribe to my weekly newsletter!

Leave a Comment