What you're building
Someone comments "interested" on your Instagram post. Within seconds they receive a personalised DM. They click a button, fill out a form, and your n8n workflow captures their name, email, and the keyword they used — then sends them the resource they asked for automatically.
This runs 24/7. Zero manual intervention after setup.
Stack:
RapidDM — Instagram comment-to-DM trigger
n8n — automation canvas (free 14-day trial or self-hosted)
Notion — lead database and email template storage
Gmail — automated email delivery
*Architecture overview:
*
`Instagram comment → RapidDM detects keyword
↓
DM sent → user clicks form button
↓
n8n Form Trigger receives submission
↓
Notion query — fetch matching template
↓
Code node — personalise email body
↓
HTTP Request — fetch actual file from Notion URL
↓
Gmail — send personalised email + attachment`
Part 1 — Set up RapidDM
RapidDM watches your Instagram posts and fires a DM when someone comments a trigger word.
Step 1 — Connect your Instagram account
Sign up at RapidDM (5-day free trial, no credit card). Navigate to the Instagram tab → Connect Account → follow the authorisation flow.
Step 2 — Create a Comment Automation
Sidebar → Automation → Comment Automation.
Step 3 — Configure trigger keywords
Select "Comments with specific words." Add your keywords:
`automation
interested
resources
guide`
Any comment containing one of these words fires the workflow.
Step 4 — Enable the Follow Gate
Under automation settings, toggle "Ask to Follow" ON. This prevents non-followers from consuming your ElevenLabs or resource credits. Non-followers see a follow prompt first. After following, they proceed to the form.
Step 5 — Write the DM message
`Thanks for your interest! I've put together something
useful for you. Click below to access your resource.`
Step 6 — Add the action button
Button label: Get Resource
Destination URL: leave blank for now — you'll paste the n8n form URL here after Part 2.
*Part 2 — Build the n8n workflow
*
Node 1 — Form Trigger
Log into n8n → New Workflow → name it Instagram Lead Bot.
Add node: n8n Form Trigger
For the dropdown, add every keyword you set in RapidDM as an option. This lets you route different resources to different keywords later.
Click "Execute Node" → test form appears → fill it with test data → click "Pin Data" on the right panel. This saves test data so you don't have to re-fill the form at every subsequent node.
Copy the Production URL. Go back to RapidDM → paste it into the button destination field from Step 6 above.
Node 2 — Notion query
Add node: Notion → Operation: Get Many → Database: select your lead template database.
Set Limit: 1.
This pulls the matching template row for the submitted keyword.
Node 3 — Code node (personalise the email body)
The Notion body contains [First Name] as a placeholder. This node swaps it for the actual name from the form.
Add node: Code → rename it Personalise
Paste this exactly:
`const items = $input.all();
const formSubmission = $("On form submission").all()[0];
const updatedItems = items.map((item) => {
item.json.property_body = item.json.property_body.replace(
"[First Name]",
formSubmission.json["Name"]
);
return item;
});
return updatedItems;`
Execute the node. Check the output — the body field should now contain the submitter's actual name instead of the placeholder.
Node 4 — HTTP Request (fetch the file)
Notion stores files as URLs, not as actual binary data. You can't attach a URL to an email. This node fetches the actual file.
Add node: HTTP Request
Configuration:
`Method: GET
URL: {{ $json.property_file[1] }}
Authentication: None
Response format: File ← this is the critical setting`
Click "Add Option" → find "Response" → change "Response Format" from "Auto-detect" to File.
Execute the node. The output should show a file object with a binary data field rather than JSON text. If you see JSON, you missed the response format step.
Node 5 — Gmail (send the email)
Add node: Gmail → Operation: Send Message
Connect your Gmail account via the credential prompt (one-click Google OAuth).
Field configuration:
To: {{ $('On form submission').first().json['Email'] }}
Subject: {{ $json.property_subject }}
Email type: HTML
Message: {{ $('Personalise').first().json.property_body }}
Add attachment:
Click "Add Option" → "Attachments" → "Add Attachment"
Property name: data
This grabs the binary file from the HTTP Request node output.
Execute the node. Check the inbox you used in your test submission — you should receive a personalised HTML email with the file attached within seconds.
Connecting all nodes
**
Wire the nodes in sequence:**
Form Trigger → Notion → Personalise → HTTP Request → Gmail
Toggle the workflow active (top right button turns blue).
What tends to break
Gmail sends but the attachment is missing — The property name in the attachment field must be exactly data. That's the default binary field name from the HTTP Request node. If you renamed the node, the field name may have changed — check the HTTP Request output panel for the actual binary field name.
HTTP Request returns JSON instead of a file — You missed changing "Response Format" to File in the Options section. It's a dropdown inside "Add Option" → "Response" — easy to miss on first pass.
Notion returns no results — Check that the Tag column in your Notion row matches the exact string the form submits. Case sensitive. automation ≠ Automation.
Form submits but nothing triggers in n8n — You're using the Test URL, not the Production URL. Test URL only works when the node is actively open in the editor. Production URL works when the workflow is toggled active.
What this unlocks next
Once this is running, extend it:
Add a Switch node after the Form Trigger to route different keywords to different Notion rows — different resources for different audiences
Add a Notion "Create page" node to log each lead submission into a separate database
Replace Gmail with a proper email marketing tool connector to add leads directly to your sequence
Full guide with all screenshots at elevoras.com.
Building a variation of this? Share your workflow in the comments — happy to look at the node config.
Top comments (0)