SmartERP Documentation An Ashewa Technology Solutions Platform

The auto-publish workflow

Import the auto-publish workflow so n8n publishes due posts to the real platforms.

The Auto Publish (All Platforms) workflow pushes due posts to the real platform APIs and reports each result back. The file is n8n/workflows/auto-publish.json.

Warning

Each platform's exact API request shape inside the workflow is a best-effort placeholder. The workflow imports cleanly and shows its full graph in the n8n editor, but the URLs and payloads for Facebook, Instagram, X, LinkedIn, TikTok and YouTube need your own developer-app credentials to set up and test, and platform APIs change over time. Verify against each platform's current documentation before you go live.

What it does#

NodeJob
Every 15 MinutesTimer trigger.
Get Due Posts from OdooGETs /social_media/webhook/posts/due with the shared key.
Split Out PostsTurns the posts list into one item per post.
Build Platform RequestA Code node that maps the post's platform to a request: URL, method and body. Throws for a platform with no mapping.
Call Platform APIOne generic HTTP node that sends that request. It continues on failure so one bad post does not stop the batch.
Build Result PayloadTurns the outcome into {post_id, callback_url, success, error}.
Report Result to OdooPOSTs {success, error} to /social_media/webhook/posts/<id>/result.

Setup#

  1. Set n8n environment variables (Settings → Environments, or your .env):

    VariableValue
    ODOO_BASE_URLYour SmartERP address, for example https://smarterp.example.com.
    SOCIAL_MEDIA_API_KEYMust match the shared API key saved in SmartERP exactly.
    FACEBOOK_PAGE_ID, FACEBOOK_PAGE_ACCESS_TOKENFor Facebook.
    INSTAGRAM_ACCOUNT_ID, INSTAGRAM_ACCESS_TOKENFor Instagram.
    LINKEDIN_ORG_ID, …For LinkedIn, and so on for the other platforms you wire up.
  2. Import auto-publish.json and activate it.
  3. Deactivate SmartERP's own scheduled action so the two do not race to publish the same post:

    Settings → Technical → Automation → Scheduled Actions → "Social Media Marketing: Publish Scheduled Posts"

Making it production-ready#

  • One branch per platform. The template uses a single generic HTTP node driven by a Code node's mapping, to keep it readable. Split it with a Switch node on platform, so each branch can use n8n's OAuth2 credential type and get proper token refresh instead of long-lived tokens in environment variables.
  • Instagram is two steps. The Graph API needs a media container created, then published. The template covers only the first step. Split it into two HTTP nodes.
  • YouTube has no simple text-post endpoint. Wire it to your own upload pipeline if you need it.
  • Engagement sync. The result route already accepts like_count, comment_count, share_count and click_count. Extend it with a second scheduled workflow that re-fetches stats for published posts and reports them the same way.

Adapting it for the AI Growth Workforce#

The template is written for the self-contained module. To use it with the AI Growth Workforce:

ChangeWhy
Use /social_ai/webhook/posts/due and /social_ai/webhook/posts/<id>/result.Different route prefix.
Read platforms (a map of flags) instead of platform, and publish to each platform whose flag is true.The AI Workforce returns one post that may target several platforms.
hashtags is one string, as typed on the post (normally already containing #). Do not add another # to each.Different payload shape.
Use the key from social_media_ai_workforce.api_key.Different setting.
Deactivate Social: Publish Scheduled Posts, not the other action.Different scheduled action.

Note that in the AI Workforce the platform credentials already live in Odoo and Odoo's own scheduled action can publish through the base module. Use this workflow there only if you specifically want publishing to happen outside Odoo.

Troubleshooting#

SymptomLikely cause
Nothing is publishedThe scheduled action is still active and won the race, or no post is Scheduled with a past date.
401 in the Get Due Posts nodeSOCIAL_MEDIA_API_KEY does not match the key in SmartERP, or no key is saved there.
A post becomes FailedThe platform call failed. The post's Error Message shows the reason.
"No API mapping configured for platform…"The post's platform has no entry in Build Platform Request.
Last updated: 2026-10-16