
Instagram Comment-to-DM Automation: Ever wished you could automatically reply to Instagram comments with a direct message, sending links or info without lifting a finger? π€³ Well, get ready, because today we're diving into how you can build your very own Instagram Comment-to-DM Automation using OpenReply. This isn't just a dream; it's a practical, accessible project that puts you in control.
This guide will walk you through setting up OpenReply, an open-source solution that leverages powerful, often free-tier compatible services like Vercel, Railway, PostgreSQL, Redis, and Resend. You'll learn how to integrate with the Meta Instagram API, deploy your web app and worker, and create a robust automation system. Let's make your Instagram workflow smarter! ✨
Advertisement
What is OpenReply and Why It Matters to You? π€
OpenReply is an incredible open-source project designed to automate your Instagram direct messages based on comments. Imagine someone comments a specific keyword on your post, and *poof*! They instantly receive a DM from you with the info they need. This isn't some shady third-party tool; it uses Meta's official Instagram API, meaning you're playing by the rules.
For creators, students, and small business owners, this is a game-changer. It means less time manually responding and more time creating or focusing on your business. OpenReply provides a practical, cost-effective blueprint for integrating with the Meta Instagram API, lowering the barrier to entry for developing applications that interact with Instagram's platform. It's about empowering you to innovate and experiment with social media-driven projects without breaking the bank. π°
The OpenReply Architecture: Your Digital Dream Team π️
Before we dive into the 'how,' let's understand the 'what.' OpenReply isn't a single app; it's a team of services working together. Think of it as a well-oiled machine with different parts handling specific jobs. This setup ensures your automation is robust, scalable, and reliable.
Here's the core lineup: a web application (your dashboard and webhook receiver), a separate worker (the unsung hero that sends DMs), a database (PostgreSQL for your app data), a super-fast cache (Redis for queues and rate limiting), and an email service (Resend for secure logins). All these pieces communicate seamlessly to make your Instagram automation magic happen. ✨
π¦ Vercel: Your Web App's Home
Vercel is where your OpenReply web application lives. It's fantastic for deploying front-end applications and handles your dashboard, OAuth callbacks, and incoming Meta webhooks. Vercel's integrations simplify backend infrastructure and email services, offering seamless deployment and environment management. You can connect your Vercel project directly to Railway for databases and Resend for email, making setup a breeze. Plus, their free tier is super generous for getting started! π
π₯ Railway: Powering Your Worker and Databases
Railway is the backbone for your OpenReply worker, PostgreSQL database, and Redis instance. The worker is crucial because it's the part of your application that actually *sends* the DMs. It runs continuously, processing your automation queue. Railway simplifies the deployment of complex applications, offering robust support for various services and deployment workflows. Its integrated approach means faster development cycles and less time worrying about infrastructure. You can even use their free tier to get started! π
πͺ Resend: Secure Email Logins
OpenReply uses email-based authentication for security and simplicity. This is where Resend comes in. It's a developer-first email API that makes sending transactional emails (like your login magic links) incredibly easy and reliable. Resend offers immediate production access, even on its free tier, without any sandbox or approval process. This means you can get your login emails up and running quickly and efficiently. π§
Getting Started: Cloning OpenReply and Setting Up Your Dev Environment π©π»
Your journey begins by grabbing the OpenReply code. It's an open-source project by Diwen Huang (@diwenne), and it's built on a fork of Anish Raj's instagram-comment-to-dm project. You'll want to start with the official repository. If you plan to customize or deploy from your own GitHub account, it's a good idea to fork the project first, then clone your fork.
Once you have the code, you'll want to set up your local development environment. This usually involves copying an environment template, spinning up PostgreSQL and Redis using Docker Compose, and then running the web app and worker in separate terminals. Always refer to the latest OpenReply setup documentation for the most current instructions and environment variables. Don't guess; verify! ✅

Cloning the OpenReply repository is your first step to building Instagram automation.
Configuring Your Services: Vercel, Railway, and Resend π
Now it's time to connect your services. You'll deploy your web application to Vercel and your worker, PostgreSQL, and Redis to Railway. The beauty of these platforms is their seamless integration. Vercel's marketplace makes it easy to connect to Railway for your databases and Resend for email. This streamlined process means you spend less time configuring and more time building.
Remember, the web app and worker need to speak the same language when it comes to your database and Redis instances. This means using the exact same connection URLs and encryption configurations. This synchronization is critical for your automation to function correctly. Generate strong, unique secrets for all your environment variables – never use default or easily guessable values! π
- Vercel Deployment: Connect your OpenReply repository to Vercel. Configure environment variables like `NEXTAUTH_URL` and `ENCRYPTION_KEY`.
- Railway Setup: Create a Railway project. Add PostgreSQL and Redis services. Then, add your OpenReply repository as the worker service. Configure its environment variables, including `DATABASE_URL` and `REDIS_URL`.
- Resend Integration: Set up your Resend account and verify your sending domain. Obtain your `RESEND_API_KEY` and add it to both your Vercel and Railway environments. Test that login emails are successfully delivered. π¬
Advertisement
Connecting to the Meta Instagram API: The Heart of Automation ❤️
This is where your OpenReply instance truly comes alive. You'll need to create a developer app within Meta for Developers. This step is crucial, and you'll need to follow OpenReply's `docs/setup.md` carefully. Selecting the wrong Meta use case can cause headaches with OAuth, so pay close attention to the instructions.
A key requirement is that the Instagram account you connect must be a Business or Creator account, not a personal one. You'll configure OAuth redirect URIs and webhooks within the Meta Instagram product. Don't forget to subscribe to the `comments` field for webhook events; this is how Meta tells your OpenReply instance that a new comment has arrived! π£

Configuring your Meta Developer app is essential for Instagram API integration.
Environment Variables: Your Secrets to Success π€«
Environment variables are like the secret sauce for your application. They hold sensitive information and configuration details that your app needs to run, but that you *never* want to hardcode into your public repository. Both Vercel and Railway provide secure ways to manage these. Remember, the web app and worker must share the same critical variables.
Here’s a quick rundown of some essential variables you’ll need to configure. Always refer to the OpenReply `docs/setup.md` for the complete and most current list, as these can change with updates to the project. Security is paramount here; if you accidentally expose a credential, rotate it immediately! π‘️
- `NEXTAUTH_URL`: The public URL of your deployed OpenReply web application.
- `ENCRYPTION_KEY`: A strong, randomly generated key used to encrypt sensitive data, shared between web app and worker.
- `DATABASE_URL`: The connection string for your PostgreSQL database on Railway.
- `REDIS_URL`: The connection string for your Redis instance on Railway.
- `RESEND_API_KEY`: Your API key from Resend for sending login emails.
- `INSTAGRAM_APP_ID` / `INSTAGRAM_APP_SECRET`: Credentials from your Meta Developer app.
- `WEBHOOK_VERIFY_TOKEN`: A secret token used by Meta to verify your webhook endpoint.
Testing Your Automation and Staying Compliant π§ͺ
Once everything is deployed and configured, it's time for the fun part: testing! Start small. Create a single campaign within OpenReply for one of your own posts or Reels. Choose a simple keyword, like "AUTO" or "LINK," and write a private reply. Then, from an authorized test account (not your main one!), comment that keyword on your test post.
Watch the magic happen! Confirm that Meta delivers the event to your OpenReply webhook, that the campaign matches the text, a job enters the queue, and your worker processes the private reply. Use OpenReply’s logs and your hosting logs (Vercel and Railway) to trace any failures. A crucial test: turn off your local development environment and test again. If it still works, your cloud setup is independent and robust! ☁️
Finally, remember to stay within Meta's rules. Keep your repository updated, monitor for worker or webhook failures, protect and rotate your credentials, and back up important data. Respect Meta's platform permissions, messaging windows, and rate limits. While OpenReply helps with queue and rate-limit behavior, self-hosting means you're responsible for maintaining the deployment and responding to upstream API changes. Happy automating! π
Complete step-by-step walkthrough
Original TECH4SSD tutorial and reference media
Tools
- OpenReply
- GitHub
- Codex / Claude Code / Cursor
- Vercel
- Railway
- PostgreSQL
- Redis
- Resend
- Meta for Developers
- Instagram API
Before you begin
- A GitHub account
- Codex, Claude Code, Cursor, or another trusted coding agent
- A Facebook account for Meta Developer registration
- An Instagram Business or Creator account you own or are authorized to manage
- A Meta Developer account
- A Resend account with a verified sender domain for login emails
- Hosting for the web app plus an always-on worker, PostgreSQL, and Redis
Watch the original Instagram tutorial
1. 1. Start with the official OpenReply repository
Open the official OpenReply repository by Diwen Huang (@diwenne). OpenReply is an open-source Instagram comment-to-DM automation project: when a comment matches a campaign keyword, Meta sends your instance a webhook, OpenReply matches the text, queues a job, and its worker sends the private reply through Meta’s official Instagram API. The repository is MIT licensed and must be self-hosted; the public demo is not a hosted automation service.
Tip: Creator credit: OpenReply is built and maintained by Diwen Huang (@diwenne). The repository also credits the earlier MIT-licensed instagram-comment-to-dm project by Anish Raj. If this project helps you, star the original repository and keep the upstream attribution intact.
- Open the official repository
- Read README.md
- Read docs/setup.md
- Review the MIT license
OpenReply, official GitHub repository
2. 2. Clone OpenReply
Clone the official repository and enter the project directory. If you plan to customize or deploy from your own GitHub account, fork the project first and then clone your fork.
Code
git clone https://github.com/diwenne/openreply.git
cd openreply
npm install
- Repository cloned
- Project directory opened
- Node dependencies installed
3. 3. Let your coding agent drive the setup
Open the cloned repository in Codex, Claude Code, Cursor, or another coding agent you trust. Tell the agent to read the repository’s own README and setup documentation before changing anything. Have it identify the exact environment variables and infrastructure required for the current version rather than guessing from an older tutorial.
Exact prompt
You are helping me self-host OpenReply from this repository. First read README.md, docs/setup.md, .env.example, package.json, the database configuration, the worker implementation, and the deployment configuration. Explain the architecture and give me a checklist of everything required to run it locally and in production. Then help me configure it step by step. Install dependencies and run safe setup commands when appropriate, but stop and ask me whenever you need a secret, an external account action, or a decision only I can make. Never expose secrets in frontend code, logs, commits, screenshots, or public files. Keep the web app and worker configuration consistent, especially shared database, Redis, and encryption values. Do not replace OpenReply's official Meta API integration with scraping or browser automation.
Tip: OpenReply’s documentation already contains an AI-assistant workflow. The prompt above is intentionally designed to make the agent re-read the current repository first, so it adapts if upstream setup details change.
- Agent has read README.md
- Agent has read docs/setup.md
- Required services identified
- Required environment variables identified
4. 4. Understand the production architecture
OpenReply is not a single server process. The web app/API serves the dashboard, OAuth callback, and incoming Meta webhook. A separate long-running worker consumes the send queue and performs the DM work. PostgreSQL stores application data and Redis powers the BullMQ queue and rate limiting. The web app and worker must point to the same database and Redis instance and must share the same encryption configuration so the worker can decrypt the Instagram credentials written by the web app.
Requirement: If the dashboard works but comment-triggered DMs never send, inspect the worker first. The worker is a separate process and must remain online.
- Web app/API understood
- Worker understood
- PostgreSQL identified
- Redis identified
- Shared production configuration understood
5. 5. Run OpenReply locally
For local development, copy the environment template, start PostgreSQL and Redis with Docker Compose, generate/migrate the database as required by the current repository, then run the web app and worker in separate terminals. Fill the environment file using the current docs/setup.md rather than inventing values.
Code
cp .env.example .env
docker-compose up -d
npm run db:generate
npm run db:migrate
npm run dev
# In a second terminal:
npm run worker
Requirement: The web process receives requests and webhooks; the worker sends the queued messages. Keep both running during an end-to-end local test.
- .env created and Git-ignored
- PostgreSQL running
- Redis running
- Database prepared
- Web app running
- Worker running
6. 6. Set up login email with Resend
OpenReply uses email-based authentication, so configure the Resend credentials and sender/domain required by the current environment template. Verify the sending domain with Resend and test that a login email reaches an account you control. Store the Resend API key only in server-side environment variables.
Warning: Never commit the Resend API key to GitHub or expose it in browser code.
- Resend account created
- Sender domain verified
- Server-side email variables configured
- Login email tested
7. 7. Create Railway services for Postgres, Redis, and the worker
For the repository’s documented production layout, create a Railway project, add PostgreSQL and Redis, and add your OpenReply repository as the worker service. Configure the worker according to the current setup guide. The repository documentation specifies a long-running worker rather than relying on a serverless web host for queue consumption.
Code
# Current OpenReply docs specify the worker start command as:
npm run worker
Tip: The repository currently recommends Railway for the worker plus PostgreSQL and Redis, while the web app can run on Vercel. Other compatible infrastructure is possible, but follow upstream documentation if you want the least-friction setup.
- Railway project created
- PostgreSQL added
- Redis added
- Worker service connected to repository
- Worker start command configured
8. 8. Keep the web app and worker secrets synchronized
Configure the production environment variables identified by OpenReply’s current .env.example and setup guide. Critically, the web app and worker must use the same database URL, Redis URL, and encryption configuration where required. Generate strong secrets rather than using tutorial placeholders. Never publish your actual values.
Warning: A mismatched encryption key can cause the web app to save an encrypted Instagram token that the worker cannot decrypt, making sends fail even though both services appear online.
- Database configuration shared correctly
- Redis configuration shared correctly
- Encryption configuration matches
- Authentication/webhook secrets generated
- No production secret committed to Git
9. 9. Deploy the web application
Deploy the web app using the production layout in the current OpenReply documentation. The repository recommends Vercel for the Next.js web application. Your public deployment URL becomes important because Meta needs reachable OAuth redirect and webhook URLs. Configure the production environment, deploy, and confirm the dashboard is reachable before moving to Meta integration.
- Web app deployed
- Public HTTPS URL available
- Production environment configured
- Dashboard loads
10. 10. Create the Meta Developer app correctly
Create your own app in Meta for Developers. Follow OpenReply’s current docs/setup.md carefully because selecting the wrong Meta use case can break OAuth. Connect only Instagram Business or Creator accounts that you own or are authorized to manage. Configure only the permissions and products OpenReply currently requires.
Requirement: OpenReply uses Meta’s official Instagram API; it does not need your Instagram password. The upstream setup guide specifically documents the Meta configuration and common wrong turns, so use that as the source of truth.
- Meta app created
- Correct Instagram use case selected
- Authorized professional account available
- Required permissions identified
11. 11. Add Meta credentials securely
Collect the Meta app values required by the current OpenReply environment template and place them only in your secure server-side deployment environment. Never put app secrets, access tokens, or webhook secrets into frontend JavaScript, a public repository, screenshots, or a tutorial video. If you expose a credential accidentally, rotate it immediately.
- Meta app values collected
- Secrets stored server-side
- No secrets committed to Git
- No secrets visible in frontend
12. 12. Configure OAuth and the Meta webhook
Use your deployed OpenReply URL to configure the OAuth redirect and webhook callback values described in docs/setup.md. Complete webhook verification and subscribe to the event fields required by the OpenReply features you intend to use. Connect your authorized Instagram professional account through your own deployed OpenReply instance.
Requirement: Meta must be able to reach the production callback over HTTPS. A dashboard running only on localhost cannot receive production Meta webhooks without a tunnel.
- OAuth redirect configured
- Webhook callback configured
- Webhook verification succeeds
- Instagram account connected
13. 13. Create your first keyword-to-DM campaign
Inside OpenReply, create a campaign for one of your own posts or Reels. Choose a simple keyword such as AUTO or LINK, write the private reply, and optionally configure the public comment reply or tracked links supported by the current version. Start with a test account and a single campaign before enabling broader automation.
Tip: OpenReply supports more than the basic keyword-to-DM flow, including features documented upstream such as tracked links, optional public replies, personalization, campaign templates, logs, and additional trigger options. Verify the current README before promising a particular feature to clients.
- Campaign created
- Keyword configured
- Private reply configured
- Target post/Reel selected
14. 14. Test the complete automation path
From an authorized test account, comment the configured keyword on your test post/Reel. Confirm that Meta delivers the event to the OpenReply webhook, the campaign matches the text, a job enters the queue, and the worker processes the private reply. Use OpenReply’s logs plus your hosting logs to trace any failure.
- Webhook event received
- Campaign keyword matches
- Job enters queue
- Worker processes job
- Expected reply is delivered
15. 15. Turn off your computer and test again
Once production is healthy, stop your local web app and worker. Trigger another authorized test. If the workflow still completes, your deployed web service, Railway worker, Postgres, and Redis are handling the automation independently of your laptop. That is the point of the self-hosted cloud setup.
- Local processes stopped
- Production web app remains online
- Production worker remains online
- Automation completes without laptop
16. 16. Stay within Meta rules and maintain the stack
Keep the repository updated, monitor worker/webhook failures, protect and rotate credentials, back up important data, and review Meta API changes. Respect the platform’s permissions, messaging windows, and rate limits. OpenReply includes queue/rate-limit behavior, but self-hosting means you are responsible for maintaining the deployment and responding to upstream API changes.
Warning: Open-source software does not mean zero operating cost. Depending on your usage and provider plans, hosting, database, Redis, email, domain, or other services may have costs.
17. 17. Credit the people who built the project
OpenReply was built and is maintained by Diwen Huang (@diwenne). The project README also states that OpenReply is a fork of the MIT-licensed instagram-comment-to-dm project by Anish Raj. This TECH4SSD guide explains how to deploy and use the project; it does not claim authorship of OpenReply. If the repository saves you time or subscription costs, consider starring the original project and supporting its maintainers.
Tip: Project credit: Diwen Huang (@diwenne), with upstream credit to Anish Raj as documented by the OpenReply repository.
Star and credit OpenReply on GitHub
18. 18. Get the resources from the TECH4SSD Reel
Comment AUTO on the companion TECH4SSD Reel to get the resource link, then use this Breakdown as your detailed setup checklist. Because OpenReply is actively maintained and Meta changes its developer platform over time, always compare this guide against the repository’s latest README and docs/setup.md before production deployment.
- Open the official OpenReply repository
- Follow the current upstream setup documentation
- Use this Breakdown as the guided workflow
- Re-check Meta requirements before going live
π‘ Pro Tip: Always refer to the official OpenReply GitHub repository's `README.md` and `docs/setup.md` for the most up-to-date instructions, as Meta's API and project dependencies can evolve.
Key Takeaways
- OpenReply is an open-source solution for Instagram Comment-to-DM automation, leveraging Meta's official API.
- The recommended stack includes Vercel (web app), Railway (worker, PostgreSQL, Redis), and Resend (email login).
- You'll need a Meta Developer app and an Instagram Business or Creator account for API integration.
- Careful configuration of environment variables across Vercel and Railway is crucial for synchronized operation.
- Thorough testing, starting with simple campaigns, is essential to ensure your automation works as expected.
Related on Tech4SSD π
π© Want the freshest AI trends every week?
Subscribe to Tech4SSD — practical AI tools and trends, explained for everyone. Free. Subscribe →
Advertisement
Frequently Asked Questions
Can I use OpenReply with a personal Instagram account?
No, OpenReply requires your connected Instagram account to be either a Business or Creator account to access the necessary Meta Instagram API features.
Are the services like Vercel and Railway truly free to use for this setup?
Yes, Vercel, Railway, and Resend all offer generous free tiers that are compatible with setting up OpenReply for small projects and testing. As your usage scales, you might need to upgrade to paid plans.
What happens if I accidentally expose my API keys or secrets?
If you accidentally expose any sensitive credentials (like API keys or app secrets), you should immediately revoke them and generate new ones. This is a critical security measure to protect your application and accounts.
How do I update my OpenReply instance when the original repository gets new features?
If you forked the repository, you can pull the latest changes from the upstream OpenReply repository into your fork. Then, deploy the updated code to Vercel and Railway. Always check the `README.md` and `docs/setup.md` for any breaking changes or new configuration requirements.
Final Word
You've just walked through the blueprint for building your very own Instagram Comment-to-DM automation with OpenReply. This powerful, open-source tool, combined with modern cloud services, puts the power of automated engagement directly in your hands. No more manual DMs, no more missed opportunities – just smart, efficient interaction.
Embrace the builder within! With this guide, you're not just deploying an app; you're gaining a deeper understanding of modern web infrastructure and API integration. Go forth and automate, making your digital life a little bit easier and a lot more impactful! π
Sources & Further Reading
- openreply/docs/setup.md at main
- diwenne/openreply
- docs/setup.md
- README.md
- docs/stack.md
- im-anishraj/instagram-comment-to-dm
- docker-compose.yml
- Jenesyx/openreply-fa
- README.md
- Troy96/x2ig
- Railway for Vercel
- Resend
- https://vercel.com/changelog/railway-integration-postgres-redis-mysql
- Prepare Email
- Saasbase
- Railway for AI Agents
- Railway Template Validator
- https://forums-production.up.railway.app/questions/project-outside-git-hub-0649165c
- What are Resend account quotas and limits?
- Usage Limits
- Does Resend require production approval?
- Automations
- https://wearables.developer.meta.com/docs/develop/webapps/setup
- Meta
- https://ai.developer.meta.com/docs/features/chat-completion/
- https://ai.developer.meta.com/docs/protocols/responses
AI tools and features change fast — verify current options before relying on them. — Tech4SSD Editorial
Discussion
Have a question or something to add?
Join the discussion on Blogger