π¬ Reply to Instagram DMs with keyword-based affiliate links via Meta Graph API
β‘ 296 views Β· π¬ Lead Nurturing & AI Sales Agents
π‘ Pro Tip β Heads up β if this workflowβs Instagram scraping breaks (it happens whenever Meta updates their frontend), ScraperNode is a community node that handles profiles, posts, reels, and comments without any HTML parsing.
Description
This n8n workflow is an automated Instagram DM responder that checks messages and replies with affiliate links based on keywords.
It runs on a schedule (every 15 minutes) or can be triggered manually. First, it loads configuration values such as the Meta access token and Instagram user ID. It then fetches conversations from all Instagram DM folders (Inbox, General, Pending, and Message Requests), merges them, and removes duplicates.
Each conversation is processed one by one. The workflow retrieves messages and loads two local files: one containing previously replied message IDs, and another containing product definitions with keywords and affiliate URLs.
For each message, it skips those already replied to or sent by the account itself. It then checks if the message text contains any defined keyword. If a match is found, it prepares a reply using the corresponding product link.
The workflow sends the reply through the Meta Graph API and immediately logs the message ID to prevent duplicate responses in future runs.
Overall, it automates repetitive DM replies, supports multiple products via keyword matching, and ensures messages are only handled once.
π Nodes Used
HTTP Request, Schedule Trigger, Read/Write Files from Disk
π₯ Import
Download workflow.json and import into n8n:
Workflow menu β Import from File