## 1. Set Up Connector Package

- [ ] 1.1 Create new GitHub repo `aimanager-instagram-connector` (empty, no files)
- [ ] 1.2 Clone the repo locally: `git clone git@github.com:zrosty-apps/aimanager-instagram-connector.git`
- [ ] 1.3 Download Messenger connector source from npm: `npm pack @tiledesk/tiledesk-messenger-connector && tar xzf tiledesk-*.tgz && cp -r package/* . && rm -rf package tiledesk-*.tgz`
- [ ] 1.4 Rename everything from `messenger` → `instagram` in package.json, file names, class names, routes
- [ ] 1.5 Create `TiledeskInstagramTranslator.js` — convert Instagram `messaging` payload ↔ AI Manager format
- [ ] 1.6 Create `InstagramClient.js` — Instagram Graph API client (adapted from FacebookClient.js)
- [ ] 1.7 Create `InstagramOAuth.js` — OAuth flow (port existing lab `instagram-oauth.js`)
- [ ] 1.8 Update `TiledeskChannel.js` — change lead_id prefix to `instagram-`
- [ ] 1.9 Update `index.js` — rename routes to `/instagram`, wire up OAuth configure page
- [ ] 1.10 Update `template/configure.html` — replace basic form with "Connect Instagram" OAuth button
- [ ] 1.11 Copy common kernel files: KVBaseMongo, TiledeskAppsClient, TiledeskSubscriptionClient, MessageHandler
- [ ] 1.12 Add MIT license from original package, keep copyright notice
- [ ] 1.13 Push to GitHub: `git init && git add -A && git commit -m "init" && git push origin master`

## 2. Create Server PubModule

- [ ] 2.1 Create `pubmodules/instagram/index.js` — require connector, export listener + route
- [ ] 2.2 Create `pubmodules/instagram/listener.js` — call connector.startApp() with config
- [ ] 2.3 Add npm dependency to server's `package.json`
- [ ] 2.4 Register in `pubModulesManager.js`:
  - [ ] Constructor: `this.instagram = undefined; this.instagramRoute = undefined;`
  - [ ] `use()`: `app.use('/modules/instagram', this.instagramRoute);`
  - [ ] `init()`: try/catch with `require('./instagram')` + `listener.listen(config)`

## 3. Add Dashboard UI

- [ ] 3.1 Add `CHANNEL_TYPE_INSTAGRAM` to dashboard `utils/constants.ts`
- [ ] 3.2 Add `CHANNELS_NAME.INSTAGRAM` and CHANNELS[] entry in `utils/util.ts`
- [ ] 3.3 Add `INTEGRATIONS_KEYS.INSTAGRAM` and `APPS_TITLE.INSTAGRAM` in `integrations/utils.ts`
- [ ] 3.4 Add INTEGRATIONS[] entry for Instagram (with icon paths, plan)
- [ ] 3.5 Add Instagram app fetching in `integrations.component.ts` `getApps()`
- [ ] 3.6 Add Instagram badge handling in 4 HTML templates (unserved, served, history, detail)
- [ ] 3.7 Add `CHANNEL_TYPE_INSTAGRAM` to Design Studio `constants.ts`
- [ ] 3.8 Add Instagram icon/logo/SVG to assets

## 4. Deploy & Test

- [ ] 4.1 Publish npm package to GHCR or npm registry
- [ ] 4.2 Commit server submodule changes
- [ ] 4.3 Commit dashboard submodule changes
- [ ] 4.4 Commit parent repo and push
- [ ] 4.5 ArgoCD sync
- [ ] 4.6 Test: Dashboard → Apps → Instagram → OAuth → Connect → Send test DM
- [ ] 4.7 Verify Instagram conversation appears in agent dashboard with correct channel icon
