feat(channels): add whatsapp token refresh and unify channel refresh jobs - #937
Merged
Conversation
…jobs Adds automatic long-lived-token refresh for WhatsApp integrations (daily cron + a new manual "refresh all channel tokens" builder action), tracked via a new tokenRefreshError column. Consolidates the five separate per-channel cron schedulers (zalo/tiktok/instagram/ messenger) into a single refreshChannelTokens dispatcher that now also covers whatsapp, and dedupes IntegrationWhatsappService by removing findWorkspaceIntegration in favor of the existing findByIdForWorkspace naming convention shared with the other channel services.
…ings Adds a red warning icon before the integration name on the settings/channels manage tables (Zalo, TikTok, Instagram, Messenger, WhatsApp) when tokenRefreshError is set, with the error message shown on hover. Also exposes tokenRefreshError on IntegrationWhatsappResource, which previously only picked id/name/inboxId/displayPhoneNumber.
4 tasks
viethung0o0
pushed a commit
that referenced
this pull request
Sep 7, 2026
…jobs (#937) * feat(channels): add whatsapp token refresh and unify channel refresh jobs Adds automatic long-lived-token refresh for WhatsApp integrations (daily cron + a new manual "refresh all channel tokens" builder action), tracked via a new tokenRefreshError column. Consolidates the five separate per-channel cron schedulers (zalo/tiktok/instagram/ messenger) into a single refreshChannelTokens dispatcher that now also covers whatsapp, and dedupes IntegrationWhatsappService by removing findWorkspaceIntegration in favor of the existing findByIdForWorkspace naming convention shared with the other channel services. * feat(channels): show token refresh error warning icon in channel settings Adds a red warning icon before the integration name on the settings/channels manage tables (Zalo, TikTok, Instagram, Messenger, WhatsApp) when tokenRefreshError is set, with the error message shown on hover. Also exposes tokenRefreshError on IntegrationWhatsappResource, which previously only picked id/name/inboxId/displayPhoneNumber. --------- Co-authored-by: Deathgiver <anonymous@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
refreshWhatsappTokens), tracking failures in a newtokenRefreshErrorcolumn, plus a manual "refresh all channel tokens" builder action covering zalo/tiktok/instagram/messenger/whatsapp.refreshZaloTokens,refreshTiktokTokens,refreshInstagramTokens,refreshMessengerTokens,refreshInstagramFacebookTokens) into a singlerefreshChannelTokensdispatcher.IntegrationWhatsappService/IntegrationWhatsappRepositoryby removingfindWorkspaceIntegrationin favor of thefindByIdForWorkspacenaming convention already shared with the messenger/instagram services.Changes
apps/worker/src/schedule/handlers/refresh-channel-tokens.ts(new) — dispatches to a per-channel refresh function via aRecord<ChannelType, ...>adapter.apps/worker/src/schedule/handlers/refresh-whatsapp-tokens.ts(new) — batched, lock-guarded WhatsApp token refresh.apps/worker/src/schedule/{handlers/register-schedules.ts,worker.ts}— replace 5 per-channel schedulers/cases with the unifiedrefreshChannelTokensjob.packages/worker-config/src/queues/schedule/index.ts— replace the 5 per-channelScheduleJobDataentries withrefreshChannelTokens.apps/builder/src/features/workspaces/actions/refresh-all-channel-tokens.action.ts(new) — manual trigger action.integrations/whatsapp/src/{api/auth.ts,integration.ts}— exposerefreshAuthfor WhatsApp.packages/database/src/schema/integration-whatsapp.ts+packages/database/drizzle/20260811025220_add_whatsapp_token_refresh_error/— addtokenRefreshErrorcolumn.packages/database/src/repositories/integration-whatsapp/repository.ts,packages/business/src/integration-whatsapp/service.ts— addfindAllForTokenRefresh,findForTokenRefreshByWorkspaceIds,updateAuth,markTokenRefreshError; remove duplicatefindWorkspaceIntegrationin favor offindByIdForWorkspace.apps/builder/src/features/integration-whatsapp/verification/actions.ts+ its test — migrated off the removedfindWorkspaceIntegration.Test plan
pnpm lintpnpm --filter worker check-typespnpm --filter builder check-typespnpm --filter @chatbotx.io/business check-typespnpm --filter @chatbotx.io/database check-typespnpm --filter @chatbotx.io/integration-whatsapp check-typespnpm --filter builder test whatsapp-verification-actions(13/13 passing)