I built a self-hosted Instagram comment-to-DM system with n8n

Hi everyone! This is my first post in the n8n community.

I wanted an Instagram keyword automation similar to ManyChat, but with full control over the logic, data and infrastructure.

So I built a self-hosted system in my homelab using n8n and Meta’s official Graph API.

It:

  • Manages multiple posts and campaigns from one workflow
  • Detects keywords and small typos
  • Sends private DMs and optional public replies
  • Rotates message variations and prevents duplicates
  • Logs successful and rejected deliveries
  • Feeds a real-time dashboard connected to my Docker-based n8n database

Campaigns and messages are managed through n8n Data Tables, so I can add new posts without duplicating the workflow.

For this use case, it gives me more flexibility than ManyChat while keeping everything inside my own infrastructure.

I’d love to hear how you would handle deduplication: per user, post, campaign or with a cooldown?

Good build, when it comes to dedup I’d do a composite key rather than picking just one dimension something like “hash user_id + post_id + campaign_id” and check that against your Data Table before sending. This handles someone commenting the same keyword on different posts. So legitimate ones get a DM vs spam post which should not.

I’d also add a short cool down would be nice, like 120 seconds per user_id alone, regardless of the composite key. This is mainly to survive duplicate webhook deliveries or race conditions if two comments fall within the same execution window. Composite keys solve “should this get a reply,” and cooldown solves “did Meta send me this event twice”.