Shinas AR
000%
Back to workShinas · AR

◇ Case study / 04 · 2026

Instagram DM Automation

Stateful conversational lead capture

Role
Sole engineer · Wall Street Jr Investments
Duration
Apr 2026 — ongoing
Status
Live
Stack
n8n · Meta Graph API · Instagram Messaging · Google Sheets
Instagram DM Automation

◇ The problem

What we were trying to solve

The CEO's personal-brand Instagram was generating qualified inbound — DMs, ad-form leads, comment intent — but the team was missing replies for hours during the day and entirely overnight. By the time someone got to a hot lead, the visitor had already moved on. Conversion was leaking.

◇ The solution

How it shipped

Built an n8n workflow on a Meta Graph API webhook with two paths: a GET handler that returns Meta's challenge token to complete subscription verification, and a POST handler that ingests four event types (DM, new follower, post comment, Meta Ad lead) and routes each into a stateful multi-turn conversation. Per-user state (waiting_name → waiting_phone → waiting_email → complete) lives in n8n's static data, keyed by Instagram sender ID. Each stage validates input (phone regex, email regex) before advancing. On `complete`, the qualified lead is appended to Google Sheets with name, phone, email, IG ID, source, and timestamp — ready for the sales team to action.

◇ Decisions

Engineering choices worth flagging

01 · Decision

Stateful per-user conversation, not one-shot

Most Instagram automations are one-message blasts. The leap was treating each conversation as state — track which question the user is on, validate their reply, advance them. This is what turns DM automation from spam to a real lead-capture funnel.

02 · Decision

n8n static data over external DB for state

For medium volume, `$getWorkflowStaticData('global')` is dramatically simpler than wiring Supabase or Redis. Trade-off documented in the README: doesn't survive workflow restructure, so production at scale would externalise to Postgres. Right call for v1.

03 · Decision

Two webhook paths in one workflow

Meta's webhook subscription requires a GET endpoint that returns `hub.challenge` before any events are sent. Most tutorials wire that into a separate workflow; I kept verification + event handling in the same n8n flow with two webhook nodes on the same path. Means one URL to register, one place to debug.

04 · Decision

Same pattern reused inside WSJR Academy's ATLAS

Once the multi-turn pattern worked, I lifted the architecture into the WSJR School ATLAS advisor. One battle-tested flow, two production surfaces. Reuse is leverage.

◇ Results

What shipped

0%
Manual DM handling
Fully replaced
4
Event types handled
4
Conversation stages
Name → Phone → Email → Thanks
MIT
Public on GitHub

◇ Stack

Tools used

n8nMeta Graph APIInstagram MessagingGoogle SheetsJavaScript

◇ Keep exploring

Other case studies.