Add keyword-based Instagram DM verification with ManyChat#6
Open
aceyeom wants to merge 1 commit into
Open
Conversation
The IG DM verification layer was fully built but silently bypassed whenever VITE_IG_VERIFY_ENABLED wasn't set — the seal fell back to a local stub that let anyone through, even on a deployed backend. Two fixes: 1. ManyChat activation keyword. ManyChat needs a word to wake an automation, so the code is now shown/copied as "seal 4071" (keyword + code). A ManyChat Keyword trigger on "seal" (Contains match) fires the External Request; the edge functions parse the 4-digit code back out (keyword-adjacent first, with a generic fallback for backward compatibility). Keyword is configurable via VITE_IG_KEYWORD (front-end) / IG_KEYWORD (functions), default "seal". 2. Fail closed in production. When a real Supabase backend is connected but verification is off, sealing is now blocked with an operator notice instead of stubbing people through. The dev/demo stub only survives when there's no backend at all; /demo still bypasses verification. Also rewrites docs/SETUP-IG-VERIFY.md §3–4 with explicit DB + keys + ManyChat keyword-trigger wiring, and updates GO-LIVE, the READMEs, and .env.example. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QXRnr1V7MZMTMqUnUQdXcK
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactors Instagram DM handle verification to use a keyword trigger instead of a default reply, making the system more robust and explicit. Users now DM a keyword + code (e.g.,
seal 4071) to trigger verification, rather than relying on a catch-all default reply.Key Changes
Documentation & Setup
docs/SETUP-IG-VERIFY.md: Completely restructured to clarify the keyword-based flow:VITE_IG_KEYWORD(defaults toseal)docs/GO-LIVE.md: Updated references to keyword-based flow and added fail-closed safety explanationapp/README.md: Clarified that seal fails closed on deployed builds without verification enabledFrontend Changes
app/src/api/igverify.js:igKeyword()function to readVITE_IG_KEYWORD(defaults toseal)igMessage(code)function to construct the full DM text (e.g.,seal 4071)app/src/components/screens.jsx:IgVerifySheetto copy the full message (seal 4071) instead of just the codeapp/src/App.jsx:VITE_IG_VERIFY_ENABLEDis not set, sealing is blocked with an operator noticeapp/.env.example: AddedVITE_IG_KEYWORDwith documentationapp/src/i18n/strings.js:Backend Functions
supabase/functions/celestual-manychat/index.ts:KEYWORDconstant (readsIG_KEYWORDsecret, defaults toseal)codeCandidates()to prioritize codes immediately after the keyword (e.g.,seal 4071) before falling back to any standalone 4-digit numberreEscape()helper for safe regex constructionsupabase/functions/celestual-ig-webhook/index.ts:KEYWORDconstant (readsIG_KEYWORDsecret, defaults toseal)codeCandidates()with same keyword-aware parsing logicreEscape()helperNotable Implementation Details
Keyword sync requirement: The keyword must match in three places:
VITE_IG_KEYWORDenvironment variable (§5)IG_KEYWORDsecret (optional, only if overriding default)Fail-closed safety: On deployed builds with a real Supabase backend, sealing now blocks with an operator notice if verification isn't enabled, preventing accidental production deployments that silently stub users through.
Code parsing priority: Both functions now try to extract codes from the keyword pattern first (
seal 4071), then fall back to any standalone 4-digit number, ensuring robust parsing while maintaining security (parsing is never the security boundary).ManyChat trigger type: Uses Contains match
https://claude.ai/code/session_01QXRnr1V7MZMTMqUnUQdXcK