Public MIT
Instagram DM Safe Bot × SlimeTree-RLM Pre-processing
For Instagram Business inbound DMs the RLM classifies up-front — spam DMs / investment pitches / identity probes are µ suppressed, FAQs return as D for instant reply, real inquiries go to R for Claude. With Access Token + IG User ID + IGSID you can really Send; without them the simulator runs standalone.
1. Instagram Graph API credentials
At developers.facebook.com/docs/instagram-api/getting-started, link your Instagram Business account to a Facebook Page → add the Instagram Graph API product in the Meta App → issue a Page Access Token.
Required permissions: instagram_business_basic + instagram_business_manage_messages + pages_messaging.
- 24-hour window: Free-form replies are allowed only within 24 hours of the customer's last DM. Beyond that, only the HUMAN_AGENT tag or specific message types may be sent
- Opt-in required: The customer must have actively DM'd your account first (no unsolicited sending)
- IGSID (Instagram-Scoped User ID): The customer's IG ID is obtained from
sender.idin the webhook payload and is different from the normal username - IG User ID is not the username: Not
@brandbut a numeric ID like17841.... Retrieve it viaGET /me - Business / Creator accounts only: Personal accounts cannot use the DM API; switching to Business is required
2. Reply scope
Beyond DMs, Instagram also exposes Story replies and Comment replies. This demo focuses on DMs; the others are shown for scope only (Send is implemented for DM only).
POST /v22.0/{ig_user_id}/messages — 1-on-1 free-form reply (within 24h window)
3. Inbound message simulator
Type as the "customer" with a DM → the bot pre-processes via RLM → an automatic reply is generated.
Typical examples:
· 商品の値段教えて (Tell me the product price) → D (instant FAQ)
· あ / $$$ 投資案件 $$$ (investment offer) / 住所教えて (tell me your address) → µ (suppressed)
· 御社の事例をフォロワー向けに紹介したい (We'd like to share your case study with our followers) → R (delegated to Claude)
3. LLM API key (called only on R verdict)
R-verdict replies are delegated to an LLM (browser-direct). Keys stay in localStorage only and never traverse JAVATEL servers.
4.5 Operating mode NEW: Pattern B (cross-vendor) — via the shared module
5. API call log
(nothing has run yet)
Pricing example: 10,000 inbound DMs/month
Monthly cost of the same workload across 6 LLM tiers. The RLM filters 73%, so the reduction ratio is the same on every provider. See the service page for details.
| Tier | Class | No filter | With RLM | Savings/month | Annual |
|---|---|---|---|---|---|
| Gemini 2.5 Flash | Everyone | $7.50 | $2.03 | $5.47 | $66 |
| Gemini 2.5 Pro | Everyone | $103 | $28 | $75 | $900 |
| GPT-5 mini | Business | $26 | $7 | $19 | $228 |
| GPT-5 | Business | $310 | $84 | $226 | $2,712 |
| Claude Haiku 4.5 | Business | $42 | $11 | $31 | $372 |
| Claude Opus 4.7 | Business | $1,530 | $413 | $1,117 | $13,404 |
* 200 in / 1,000 out tokens. "No filter" = all 10,000 DMs go to the LLM; "With RLM" = only the 2,700 R-verdict DMs do. Prices reflect public unit rates as of 2026-05; industry mix is adjustable.
6. Why the RLM works for Instagram DMs (unique strengths)
- Automatic spam-DM rejection: Influential accounts on Instagram receive a flood of "investment offers", "collab requests", and "affiliate" spam. The µ verdict drops them before the operator reads → prevents staff burnout and fraud exposure
- D verdict for instant reply inside 24h: Standard inquiries about products / hours / shipping status are 0 tokens → maximizes response rate before the window expires and sustains engagement
- R verdict for brand-aware replies: Marginal cases (collab pitches, press inquiries) go via Claude for careful responses → reduces brand damage risk
- Preventing PII leaks: "Tell me your home address" / "Tell me your phone number" are mechanically suppressed by µ → safeguards the influencer's personal safety
- WAL audit chain: For harassment / report cases, later you can air-gap reproduce "what DM arrived when, and how the bot handled it" via the SHA-256 chain
- Story replies / Comment replies can be rolled out with the same pattern (this demo implements DM only)
7. Source / Related
- Full source on this page = MIT, same license as the Gateway source page
- RLM mock: slimetree-rlm-mock.js (shared)
- Instagram Graph API docs: developers.facebook.com/docs/instagram-api/
- Sister demos: Gateway / Threads / Messenger / WhatsApp
