You can absolutely build your own Instagram DM bot. The API is public, documented, and more approachable than its reputation suggests — a competent developer can get a reply sending in an afternoon. This guide walks the real path, with Meta's actual rules rather than the hand-waving most tutorials stop at.
It also does something the tutorials don't: it prices the upkeep. Building the bot is the small part. Keeping it alive through token rotations, webhook outages and rate ceilings is the part that decides whether this was a good idea. By the end you'll know both the steps and whether you want them.
What you need before you start
- An Instagram professional account (business or creator) — a personal account can't do this at all.
- A Facebook Page linked to it, if you go the Facebook Login route.
- A Meta developer account, and an app you'll create in the App Dashboard.
- A public HTTPS endpoint with a valid TLS certificate. Self-signed certificates are not supported.
- Somewhere to store tokens and conversation state that isn't a variable in memory.
How to build your own Instagram DM bot, step by step
Step 1: Set up the account prerequisites
Convert the Instagram account to a professional one, and link the Facebook Page if you're using Facebook Login for Business. This sounds like box-ticking and is the source of a genuinely large share of “why doesn't my webhook fire” questions. The permissions model is built on top of this relationship; get it wrong and everything downstream fails in confusing ways.
Step 2: Create a Meta app and choose your login path
In the App Dashboard, create an app and choose how users will authenticate. Meta's Instagram Platform documentation offers two paths: Business Login for Instagram, which issues Instagram User access tokens, or Facebook Login for Business, which issues Facebook User or Page tokens. Pick deliberately — the token type, the permission names and the endpoints all differ, and switching later means rewriting your auth layer.
Step 3: Work out which access level you actually need
This is the step that saves or costs you weeks. Meta's rule: “If your app only serves your Instagram professional account or an account you manage, Standard Access is all your app needs.” Advanced Access — which requires App Review and Business Verification — is the level needed once your app serves accounts you don't own or manage.
Read plainly: automating your own store's DMs does not require App Review. Automating your clients' accounts does. The permissions in play are instagram_business_basic and instagram_business_manage_messages (or instagram_manage_messages on the Facebook Login path). Note Meta's own caveat that because of Standard Access's limited scope, some features may not work fully until an app has Advanced Access — so test the specific thing you need early rather than assuming.
Step 4: Stand up a webhook endpoint Meta trusts
Meta delivers messages by webhook, so you need an endpoint that handles two kinds of request. The first is verification: a GET carrying hub.mode, hub.challenge and hub.verify_token. You check the verify token matches the string you set in the dashboard, then echo back the challenge value. The second is the event notification itself, which you acknowledge with 200 OK.
Then subscribe to the fields you care about — messages for DMs, comments if you want the comment-to-DM pattern. Here's the sentence from Meta's webhook documentation that should shape your whole architecture: “If any update sent to your server fails, we will retry immediately, then try a few more times with decreasing frequency over the next 36 hours,” and “unacknowledged responses will be dropped after 36 hours.” A weekend outage doesn't queue politely — past a point, those customer messages are simply gone.
Step 5: Survive the token lifecycle
Meta's chain runs: an authorization code valid for one hour, exchanged for a short-lived token valid for one hour, exchanged for a long-lived token valid for 60 days that can be refreshed before it expires. Write the refresh job on day one, alert on its failure, and test the alert. A token refresh that fails silently is indistinguishable from a slow sales week until someone opens the inbox and finds a fortnight of unanswered DMs.
Step 6: Send the reply inside the window
Post to the Send API with the recipient's Instagram-scoped ID. The constraint that governs the design: Meta gives your app 24 hours to respond to a user's message. Miss it and the standard window has closed. The human agent tag extends that to 7 days for genuine human follow-up, but it “requires successful completion of the App Review process before your app can access live data” — so it's not a hatch you can open in a hurry.
Step 7: Respect the rate limits
Per Instagram professional account, Meta documents 2 calls per second on the Conversations API, 100 calls per second on the Send API for text, links, reactions and stickers, 10 per second for audio or video, and 750 calls per hour for private replies to comments on posts and reels. Build backoff and a queue before you need them. The hour you first hit that 750 ceiling is, by definition, your best hour — the Reel worked — which is exactly when you can least afford to be dropping messages.
Step 8: Decide what the bot actually says
Everything above is plumbing, and plumbing has a finish line. This step doesn't. Keyword matching gets you “comment LINK, receive link,” which is genuinely useful and genuinely limited. Real DMs sound like “do these run small and do you ship to canada and is there a discount rn” — three questions, one message, no keyword. Answering that from your live catalog, in your voice, without inventing a shipping policy you don't have, is the actual product. It's also where a weekend project becomes a maintained system.
Why most people shouldn't build their own Instagram DM bot
Not because it's too hard. Because of what the maintenance curve looks like after launch day, and because the interesting problem isn't the one you'd be solving.
- The plumbing is a solved problem. Tokens, webhooks, retries, rate limits — none of it is novel, none of it differentiates your business, and all of it needs an owner forever.
- The conversation logic never converges. Every new product, price change and promo is another branch you write and maintain yourself, because a hand-rolled bot has nowhere else to put it. The logic grows faster than the business does.
- Failure is silent. A dead API integration doesn't throw an error your customer sees. It just quietly stops selling, and you find out later.
- The hours are real even when they're unpaid. Your Sunday has a cost; it just doesn't appear on an invoice, so it never makes it into the build-vs-buy spreadsheet.
Build it anyway if the logic is genuinely deterministic, you already run the infrastructure, or you want to learn the platform properly — all good reasons, and we set out that decision in full in our n8n, Make and Zapier build-vs-buy comparison. If you'd rather not write the auth layer at all, n8n's Facebook Trigger node handles the receiving half natively and is a reasonable middle path.
So should you build your own Instagram DM bot?
Do it once and you'll understand the platform better than any comparison page can teach you — where the windows are, why replies have deadlines, what Meta actually permits. That knowledge is worth having whichever way you end up going, and it makes you a much harder person to sell to.
Most people who build their own Instagram DM bot discover the same thing: the API was the easy part, and the reply was the product all along. HyperDM exists for both halves — we own the plumbing above (Standard versus Advanced Access, the tokens, the webhook retries, the 750-an-hour ceiling), and the reply is an AI agent grounded in your real synced catalog, answering from what you actually sell over Meta's official APIs, on Instagram today. The deterministic paths you'd have hand-coded get a visual flow builder — comment, keyword and story-reply triggers, conditions, delays, data capture — and the agent drops into those flows as a step, so the questions you couldn't anticipate don't need a branch of their own. Priced per conversation, not per contact. Free is 50 conversations a month, no card: see the plans and keep your Sundays. Before you point anything at customers, though, read the compliance guide — that part matters whichever way you build.
Run the automations. Let the AI close.
Comment-to-DM, keyword replies, follow gates — set up in minutes, then the AI answers from your real catalog. Free on one channel, 50 conversations a month, no card.
