Use this comprehensive n8n workflow to automatically manage and refresh Zalo OA OAuth tokens. Securely cache tokens using n8n static data for reliable, persistent API access.
Download this n8n workflow template and start using it instantly.
This is a critical n8n workflow designed to maintain valid API connectivity for Zalo Official Accounts (OA). Handling OAuth tokens can be challenging due to their short lifespan. This automated n8n solution ensures that a fresh access token is always available by utilizing n8n's Workflow Static Data feature for persistent caching. This specific n8n workflow supports both a regular, scheduled refresh cycle (triggered every 12 hours) and provides dedicated webhooks for immediate token retrieval or forcing a manual cache reset. Implementing this n8n automation means your downstream services will never fail due to an expired token.
The core of this automation is initiated by the Schedule Trigger n8n node, set to run every 12 hours. This process ensures the token is refreshed well before expiry.
Set Refresh Token and App ID n8n node injects the necessary credentials (initial refresh token, App ID, and Secret Key) into the flow.Load to Static Data Code n8n node retrieves the currently cached token from the global Workflow Static Data. It determines if a refresh is needed based on the expiration time, applying a 90-second buffer to trigger the refresh early.Refresh Token (Zalo v4) HTTP Request n8n node contacts the Zalo OAuth endpoint, using the current refresh token to acquire a brand-new access token and an updated refresh token.Store to SD & Pass token Code n8n node is crucial. It overwrites the global Workflow Static Data with the new access token, refresh token, and updated expiry timestamps, completing the refresh cycle.Additionally, an Execute_Node Webhook allows users to manually trigger a reset via the Clean Zalo Static Data Code n8n node, flushing the cache for re-seeding. A separate Webhook n8n trigger is available for external services to easily retrieve the current, valid access token.
To install this n8n workflow:
Set Refresh Token and App ID n8n node.refreshtoken, appid, and secretkey with your actual Zalo OA credentials.{{ $env.ZALOREFRESHTOKEN }}) instead of hardcoding sensitive data.ExecuteNode for manual reset and Webhook for retrieval). Ensure your n8n instance is accessible externally if you intend to use these integration points. Schedule Trigger (n8n trigger): Runs the token refresh logic automatically every 12 hours to maintain token validity.
Set Refresh Token and App ID (Set n8n node): Serves as the configuration point, injecting the initial static Zalo OA credentials (refresh token, app ID, secret key) into the data stream.
Load to Static Data (Code n8n node): Checks the global workflow cache. This custom n8n node determines if the existing access token is still valid or if a new refresh cycle is required.
Refresh Token (Zalo v4) (HTTP Request n8n node): Performs the core OAuth action, calling the Zalo API to exchange the expiring refresh token for a new pair of access and refresh tokens. Uses form-urlencoded body type.
Store to SD & Pass token (Code n8n node): Persists the newly acquired tokens and their updated expiration times into the global Workflow Static Data, ensuring the cache is up-to-date.
Clean Zalo Static Data (Code n8n node): Executes on the manual reset path, deleting the cached tokens from the workflow static data, forcing the next run to use the initial seed token.
Use this powerful n8n workflow to automatically transcribe YouTube videos via Gemini AI and convert the output into structured, SEO-ready blog posts, complete with category and HTML formatting.

Use this powerful n8n workflow to automate scheduled YouTube video uploads (12-hour intervals) directly from your self-hosted environment. Ideal for consistent content publishing.

Automate YouTube uploads! This powerful n8n workflow uses AI (OpenAI/Gemini) to generate high-quality, SEO-optimized tags and descriptions from video transcripts, and automatically schedules videos for consistent future publication dates.

Learn how to use this robust n8n workflow template to automatically back up all your active n8n workflows daily to a dedicated GitHub repository using the internal n8n API node.

Secure your installation using this n8n workflow. Automatically export all decrypted n8n credentials using the Execute Command n8n node and store the backup safely in Google Drive.

Salesforce Architect with 10+ years of experience in CRM, integrations, and automation. Skilled in Apex, LWC, REST APIs, and full-stack dev (JavaScript, .NET). I build secure, scalable workflows in n8n—connecting Salesforce, Stripe, and more. Passionate about lead scoring, data sync, and secure field masking. Certified Application Architect with deep expertise in platform, integration, and data architecture.







































