Repository navigation
Description
Summary
New Meta apps can require Instagram API with Unified Login. ChatbotX's instagram-direct channel currently starts the legacy direct Instagram OAuth flow at https://www.instagram.com/oauth/authorize and has no way to supply Meta's Unified Login config_id.
For such apps, connecting the channel fails with:
Invalid Request: Request parameters are invalid: Invalid platform app
Meta's generated login URL instead uses https://www.facebook.com/dialog/oauth with client_id, config_id, response_type=code, and override_default_response_type=true.
Reproduction
- Create a new Meta app for which Meta exposes Unified Login rather than the previous Instagram Login flow.
- Configure the callback and webhook URLs for ChatbotX.
- Add the app ID and secret as ChatbotX Instagram platform credentials.
- Try to connect an
instagram-directchannel.
The legacy Instagram authorization URL is opened and Meta rejects the app as an invalid platform app.
Expected behavior
ChatbotX should support Meta's Unified Login flow without breaking existing credentials that still use the direct Instagram OAuth flow.
Proposed compatibility approach
I have prepared an implementation that:
- adds an optional Unified Login Configuration ID to Instagram platform credentials;
- uses
facebook.com/dialog/oauthonly when that ID is configured, keeping the existing direct flow as the fallback; - exchanges the authorization code through the Graph API;
- resolves the business user and paginates
assigned_instagram_accounts; - lets the user select the Instagram account when multiple accounts are returned;
- stores and uses the business access token plus the selected Instagram account ID for messaging, profiles, media, comments, webhook subscription, and sync;
- uses the Unified Login webhook fields and skips the legacy
ig_refresh_tokenpath; - requires no database migration because the new credential field is optional in the encrypted credential payload.
Validation completed
- Instagram integration: 30 test files, 134 tests passed
- Database credential tests: 19 passed
- TypeScript checks passed for the Instagram integration, database package, and builder
- New tests cover the Unified OAuth URL, token exchange, business-user/account resolution, pagination, and backward compatibility
A live Meta OAuth smoke test is still pending, so I will open the implementation as a draft PR and keep the legacy path unchanged.
Meta documentation:
Activity