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#
| Node | Job |
|---|---|
| Every 15 Minutes | Timer trigger. |
| Get Due Posts from Odoo | GETs /social_media/webhook/posts/due with the shared key. |
| Split Out Posts | Turns the posts list into one item per post. |
| Build Platform Request | A Code node that maps the post's platform to a request: URL, method and body. Throws for a platform with no mapping. |
| Call Platform API | One generic HTTP node that sends that request. It continues on failure so one bad post does not stop the batch. |
| Build Result Payload | Turns the outcome into {post_id, callback_url, success, error}. |
| Report Result to Odoo | POSTs {success, error} to /social_media/webhook/posts/<id>/result. |
Setup#
Set n8n environment variables (Settings → Environments, or your
.env):Variable Value 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. - Import
auto-publish.jsonand activate it. 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_countandclick_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:
| Change | Why |
|---|---|
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#
| Symptom | Likely cause |
|---|---|
| Nothing is published | The scheduled action is still active and won the race, or no post is Scheduled with a past date. |
401 in the Get Due Posts node | SOCIAL_MEDIA_API_KEY does not match the key in SmartERP, or no key is saved there. |
| A post becomes Failed | The 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. |