Templates / Reply to Instagram DMs with keyword-based affiliate links via Meta Graph API

Reply to Instagram DMs with keyword-based affiliate links via Meta Graph API

Ready for 3.0

by Mihajlo ✓ · 295 views · created 2026-04-18 · Lead Nurturing, AI Chatbot

Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.

Nodes used (10)

What it does

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.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.