Reply to Instagram DMs with keyword-based affiliate links via Meta Graph API
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.
Related Templates
Extract Named Entities from Web Pages with Google Natural Language API
Who is this for? Content strategists analyzing web page semantic content SEO professionals conducting entity-based anal...
Add product ideas to Notion via a Slack command
Use Case In most companies, employees have a lot of great ideas. That was the same for us at n8n. We wanted to make it a...
Automate Daily Keyword Research with Google Sheets, Suggest API & Custom Search
Who's it for This workflow is perfect for SEO specialists, marketers, bloggers, and content creators who want to automa...
🔒 Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments