Skip to content

feat(instagram): add Instagram integration#5568

Open
BillLeoutsakosvl346 wants to merge 15 commits into
stagingfrom
feature/instagram-integration
Open

feat(instagram): add Instagram integration#5568
BillLeoutsakosvl346 wants to merge 15 commits into
stagingfrom
feature/instagram-integration

Conversation

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor

Adds Business Login OAuth, 23 tools, block, and publish routes for Instagram

Bill Leoutsakos and others added 3 commits July 9, 2026 17:25
Resolve UserFiles to Meta-fetchable presigned HTTPS URLs (600s TTL) via
internal publish routes, and fix OAuth scope storage plus connect-draft
wiring so Instagram Login publishing is testable end-to-end.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 12, 2026 1:10am

Request Review

@cursor

cursor Bot commented Jul 10, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches OAuth token storage/refresh and new external publishing paths that depend on cloud storage and Meta API behavior; scope is large but mostly additive integration code.

Overview
Introduces a full Instagram integration for professional accounts: Meta Business Login OAuth, workflow block with 23 operations, Graph API tools, and docs/catalog wiring.

OAuth and tokens: Dedicated authorize/callback routes exchange short- for long-lived tokens, persist accounts by Instagram user_id, and process workspace credential drafts. Connect flows route through Instagram-specific URLs (UI, copilot). Shared createConnectDraft replaces inline draft logic in generic OAuth2 authorize. Token refresh adds Meta’s ig_refresh_token strategy plus proactive refresh while long-lived tokens are still valid (14-day window, 24h minimum age).

Publishing: Five long-running API routes resolve uploads to Meta-fetchable HTTPS URLs (10-minute presigned TTL), create containers, poll status, and publish image/video/reel/story/carousel. File upload sub-blocks can set requiresCloudStorage; a new storage-status endpoint and UI guard block uploads when S3/Azure is missing.

Product surface: Instagram block, registry, integrations JSON, icons, env vars (INSTAGRAM_CLIENT_*), and integration docs page.

Reviewed by Cursor Bugbot for commit 24bdce9. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread apps/sim/app/api/tools/instagram/publish-carousel/route.ts
Comment thread apps/sim/lib/integrations/instagram/resolve-media.ts
Comment thread apps/sim/tools/instagram/utils.ts
Comment thread apps/sim/blocks/blocks/instagram.ts
@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds Instagram as a new integration. The main changes are:

  • Business Login OAuth routes and callback handling.
  • Instagram block metadata, icons, registry entries, and docs.
  • Publishing routes for images, videos, reels, stories, and carousels.
  • Instagram tools for media, comments, DMs, insights, and publishing.

Confidence Score: 4/5

This is close, but the callback persistence race should be fixed before merging.

  • Carousel publishing now creates children before polling, so the URL lifetime issue is addressed for the normal flow.
  • The callback now stores the Instagram professional account id, which fixes the wrong-id fallback path.
  • The account write is still a read-then-insert without atomic dedupe, so concurrent callbacks can leave duplicate account rows and stale tokens.

apps/sim/app/api/auth/oauth2/callback/instagram/route.ts

Important Files Changed

Filename Overview
apps/sim/app/api/tools/instagram/publish-carousel/route.ts Creates child containers before polling and polls children in parallel.
apps/sim/app/api/auth/oauth2/callback/instagram/route.ts Uses the Instagram professional account id, but still needs atomic account dedupe.

Reviews (2): Last reviewed commit: "fix(instagram): normalize Graph ID outpu..." | Re-trigger Greptile

Comment thread apps/sim/app/api/tools/instagram/publish-carousel/route.ts Outdated
Comment thread apps/sim/app/api/auth/oauth2/callback/instagram/route.ts Outdated
…s, extend poll window and insights periods, use canonical user_id in OAuth callback
Comment thread apps/sim/tools/instagram/utils.ts Outdated
Comment thread apps/sim/app/api/auth/oauth2/callback/instagram/route.ts
…r_id

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread apps/sim/tools/instagram/reply_to_comment.ts
Comment thread apps/sim/tools/instagram/utils.ts
Comment thread apps/sim/tools/instagram/get_conversation_messages.ts
…ts, request message timestamps explicitly

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread apps/sim/tools/instagram/get_profile.ts Outdated
…trim() calls are safe

Co-authored-by: Cursor <cursoragent@cursor.com>
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile

Comment thread apps/sim/app/api/auth/oauth2/callback/instagram/route.ts
Match the official Instagram look by filling the tile with the orange–pink–purple radial gradient so the white camera glyph sits on a full-bleed brand background.

Co-authored-by: Cursor <cursoragent@cursor.com>
Default Reel share-to-feed to Yes, drop unused media fields params, share publish transform helpers, and warn when cloud storage is missing for Meta-fetchable uploads.

Co-authored-by: Cursor <cursoragent@cursor.com>
Treat loading/error as blocked for requiresCloudStorage uploads, show the warning once the check finishes, and disable selecting local workspace files Meta cannot fetch.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread apps/sim/lib/oauth/oauth.ts
Meta only allows refreshing still-valid Instagram tokens, so refresh within 14 days of expiry (after the 24h age gate) instead of waiting until after accessTokenExpiresAt.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread apps/sim/lib/integrations/instagram/resolve-media.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6720e40. Configure here.

Comment thread apps/sim/tools/instagram/index.ts
The staging merge dropped the opening /** on ProviderAuthConfig.clientIdParamName, which broke TypeScript parse in CI.

Co-authored-by: Cursor <cursoragent@cursor.com>
Wire /api/files/storage-status through a shared route contract so the
strict API validation audit stays at zero non-Zod routes after the new
Instagram cloud-storage check.

Co-authored-by: Cursor <cursoragent@cursor.com>
Drop public-URL paste hints from advanced fields and the cloud-storage banner so the UI mirrors Gmail attachments.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant