Skip to content

Add Instagram posting strategy#175

Draft
Copilot wants to merge 1 commit into
mainfrom
copilot/add-instagram-post-strategy
Draft

Add Instagram posting strategy#175
Copilot wants to merge 1 commit into
mainfrom
copilot/add-instagram-post-strategy

Conversation

Copilot AI commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Adds an InstagramStrategy for crossposting to Instagram. Unlike other strategies, Instagram requires an image, so post() rejects when none is provided.

Changes

  • src/strategies/instagram.js — New InstagramStrategy (accessToken + accountId). Uses the Instagram Graph API content-publishing flow: create media container → publish → fetch permalink. Uses the first image as media and the message as caption. MAX_MESSAGE_LENGTH = 2200; getUrlFromResponse() returns the permalink.
  • src/index.ts — Exports the strategy and its types.
  • src/bin.js-i/--instagram CLI flag; reads INSTAGRAM_ACCESS_TOKEN and INSTAGRAM_ACCOUNT_ID.
  • README.md — API/CLI usage, env vars, and setup instructions.
  • tests/strategies/instagram.test.js — Covers constructor validation, image-required behavior, publish flow, API/abort failures, URL extraction, and length calculation.
const instagram = new InstagramStrategy({
	accessToken: "your-access-token",
	accountId: "your-instagram-account-id",
});

// Throws TypeError: "Instagram requires an image to post."
await instagram.post("Hello world!");

await instagram.post("Hello world!", {
	images: [{ data: imageData, alt: "Description" }],
});

Note for reviewers

The Graph API officially publishes images via a public image_url, not binary upload. To stay consistent with this library's Uint8Array image convention (used by all other strategies), the image is sent as multipart form-data. Open to switching to a hosted-URL input if preferred.

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.

2 participants