---
name: openreply-comment-to-dm
description: Use when you say set up OpenReply, the free open-source ManyChat alternative, or make Instagram comments send an automatic DM with my link; it walks you through deploying the self-hosted OpenReply app, worker, Postgres, Redis and Instagram connection, then building keyword campaigns.
---
# OpenReply: comment-to-DM on your own server
## What it does
OpenReply is open-sourced ManyChat for Instagram comment-to-DM automation. Someone comments `LINK` on your reel, and OpenReply queues a DM with your link. It watches comments on your Instagram posts, and when a comment matches a keyword you set, it sends that person a private reply through the official Meta API. It can post a public reply under the comment at the same time.
It is MIT-licensed software you run on your own infrastructure, with no software seat limits or plan caps. Hosting and optional provider costs are separate. It uses Meta's official Instagram private replies: no scraping, no browser automation, and it never asks for an Instagram password. Instagram's policies, permissions, messaging windows and rate limits still apply.
What is in the project:
- Keyword to DM, one or many keywords per post, whole-word or partial.
- Optional public reply on top of the DM.
- DM and Story reply triggers, so "Reply LINK to this Story" works with no post involved.
- Tracked links with clicks and CTR per campaign, and up to two tappable link buttons per DM, each with its own stats.
- Follow gate: ask the commenter to follow, check Meta's `is_user_follow_business` flag, and send the link once they follow. It fails open when Instagram does not return follow status.
- Personalization with `{username}`.
- Per-account rate limiting under Meta's documented cap of 750 private replies per hour, queuing the overflow.
- Multiple Instagram accounts, workspaces with owner, admin and member roles and invite links.
- Campaign templates, DM logs of every send, skip and failure, and self-comment filtering.
- Inbox: read and reply to Instagram DMs from the dashboard inside Meta's 24-hour messaging window.
- Read-only API and MCP for campaign settings, destination links and aggregate stats, with workspace-scoped revocable keys (30/60/90 days).
- Interface in English, Traditional Chinese, Brazilian Portuguese and Russian.
Two processes, always: the web app receives webhooks and serves the dashboard, and a separate always-on worker sends the DMs. Both share the same Postgres and Redis.
## What you need
- Your own deployed copy. `openreply.diwen.dev` is a demo of the dashboard, not a service you can sign up for.
- An Instagram Business or Creator account. A personal account cannot be connected.
- An Instagram connection: either your own Meta app (needs a Facebook account for Meta developer registration, Instagram Login, app secrets, webhook and App Review where required) or Zernio, an optional paid provider and sponsor that registers the webhook for you.
- PostgreSQL, Redis (must support blocking commands, so HTTP-only Redis will not work with BullMQ), a public HTTPS URL, and an always-on host for the worker.
- A Resend account with a verified sender domain for magic-link login, or your own SMTP server via `EMAIL_SERVER`.
- Somewhere to host. The guide uses Vercel for the web app and Railway for the worker, Postgres and Redis. You do not need to buy a domain; Vercel gives you a free `your-app.vercel.app` URL.
- Node and npm, plus Docker if you want the local Postgres and Redis.
If you are moving from ManyChat or another DM tool, disconnect it from the Instagram account and give OpenReply control of conversations in Meta Business Suite, or button taps in DMs will fail with "not the thread owner".
## Setup
Run it locally first:
```bash
git clone https://github.com/diwenne/openreply.git
cd openreply
npm install
cp .env.example .env # then fill in the values, see docs/setup.md
docker-compose up -d # starts Postgres and Redis
npm run db:generate
npm run db:migrate
npm run dev # web app on http://localhost:3000
npm run worker # in a second terminal, this sends the DMs
```
For hosting, the setup guide does Railway first (Postgres, Redis, worker) because Vercel needs the database URLs from it. The Railway worker service uses:
```
Build Command: npm run db:generate
Start Command: npm run worker
```
Migrate the production database once from your machine with the public Postgres URL:
```bash
DATABASE_URL="postgresql://...proxy.rlwy.net.../railway" npm run db:migrate
```
The web app and the worker must share the same `DATABASE_URL`, `REDIS_URL` and `ENCRYPTION_KEY`, or every send fails to decrypt. Give Vercel the public Railway URLs, not the `*.railway.internal` ones. Full environment variables, the Meta app steps and the Zernio path are in docs/setup.md: https://github.com/diwenne/openreply/blob/main/docs/setup.md
There is a ready-made AI assistant prompt in the "Set it up with an AI assistant" section of that guide. Paste it into Claude Code inside a clone of this repo and choose your provider before configuring any Meta secrets.
This tool sends DMs to real people from your Instagram account. Keep `ALLOWED_EMAILS` set so only you can sign in, and test a keyword comment from another account of yours before you point it at a live post. Use it only on your own Instagram accounts and within Instagram's terms.
## How to use it with Claude
- "Clone OpenReply and get the dashboard and worker running locally with docker-compose."
- "Open docs/setup.md, use its AI assistant prompt, and help me pick between Zernio and my own Meta app."
- "Walk me through the Railway worker, Postgres and Redis setup, then the Vercel environment variables."
- "Explain which env vars must match between the web app and the worker, and generate the secrets the guide asks for."
- "Help me build a campaign with the keyword REPLY, a tracked link button and a public reply, then test it."
- "Comments are coming in but no DM arrives. Check the worker and the DM logs with me."
## Credits
Made by diwenne (OpenReply), packaged by Orbit. Source: https://github.com/diwenne/openreply, license: MIT. Built and maintained by Diwen Huang; initially forked from instagram-comment-to-dm by Anish Raj, also MIT.