Skip to content

Daily

Publish planned posts to Instagram and Facebook with email results

Your planned posts go out on Instagram and your Facebook Page at their scheduled times, and you get an email for each success or failure.

Runs
Daily
Apps
Facebook Pages, Gmail
AI
Not needed
Access
instagram_content_publish, pages_manage_posts; gmail.send

Send this to your assistant

Create a ClickRuntime automation: every 15 minutes, publish the next planned post that's due to Instagram and my Facebook Page, and email me whether it worked.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

A boutique plans product photos for Instagram and Facebook a week ahead. When posting fails, because of an expired login or a wrong image size, nobody notices until a customer asks why the new collection wasn't announced.

Each planned post now goes out on time on both networks, and every result is emailed: a confirmation with links when it works, and the reason when it doesn't, so problems are fixed the same day.

What you get out of it

  • Posts go out on time

    No one needs to be online when a post is due.

  • Failures don't go unnoticed

    An email tells you straight away if something didn't post, and why.

  • Both networks at once

    Instagram and Facebook get the same post.

  • A record of every post

    Confirmation emails show what went out and when.

How it works

What happens, step by step

  1. Every 15 minutes, ClickRuntime looks for the next planned post that's due.

  2. It prepares the image on Instagram and publishes it, then posts it to your Facebook Page.

  3. The post is marked as done, or as failed with the reason.

  4. You get an email with the result and links.

Before it runs live

  • Connect Facebook Pages
  • Connect Google through your own Google app (a one-time, 10-minute setup), so it works with your own Gmail

What you get

RunsDaily
Publish planned posts to Instagram and Facebook with email resultstoday, 9:00Succeeded
Gmail · Post donePost done: The Harbour knit is here... Published on Instagram and Facebook.

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Run it at a different time, more or less often, or only on weekdays
  • Add an AI step, for example to summarize, sort or draft a reply
  • Add another app, for example also send it to Slack
  • Combine it with other Facebook Pages and Gmail steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
scheduled_instagram_facebook_publishing_with_email_alerts.pyexample
import base64
from datetime import datetime, timezone
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_trigger, credentials, http, state

PAGE_ID, IG_ID, G = "1234567890", "17841400000000000", "https://graph.facebook.com/v21.0"

@on_trigger
def run(event):
    plan = state.get("plan") or []
    due = next((p for p in plan if not p.get("status") and p["time"] <= datetime.now(timezone.utc).isoformat()), None)
    if not due:
        return {"posted": False}
    t = {"access_token": credentials.connection("facebook", "work")}
    try:
        c = http.post(f"{G}/{IG_ID}/media", data={**t, "image_url": due["image"], "caption": due["caption"]}).json()["id"]
        ig = http.post(f"{G}/{IG_ID}/media_publish", data={**t, "creation_id": c}).json()["id"]
        fb = http.post(f"{G}/{PAGE_ID}/photos", data={**t, "url": due["image"], "caption": due["caption"]}).json()["id"]
        due["status"], body = "done", f"Published. Instagram {ig}, Facebook {fb}."
    except Exception as e:
        due["status"], body = "failed", f"Failed: {e}"
    gmail = build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)
    raw = f"To: me\r\nSubject: Post {due['status']}: {due['caption'][:60]}\r\n\r\n{body}"
    gmail.users().messages().send(userId="me", body={"raw": base64.urlsafe_b64encode(raw.encode()).decode()}).execute()
    state.set("plan", plan)
    return {"status": due["status"]}

FAQ

Common questions

Where do I plan posts?
Give the posts to your AI assistant with their times and image links, and they're stored as the plan. You can add or change them at any time.
Why might a post fail?
Common reasons are an image link that isn't public, an image with an unsupported shape, or a Facebook login that needs renewing.
Does a failed post retry?
It stays in the plan as failed until you fix it, so it won't post at the wrong moment.
What permissions does it need?
instagram_content_publish, pages_manage_posts; gmail.send. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run each time it runs (daily). Checks that find nothing to do and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Publish planned posts to Instagram and Facebook with email results” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.