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.