Already a Spur customer?

Log in
Instagram

How to Build an Instagram Bot With Meta's Official API

Build an Instagram bot that answers DMs and comments the allowed way: code it on the Instagram API with Instagram Login, or set one up with no code at all.

By Rohan Rajpal Published Updated 9 min read

Add as a preferred source
How to Build an Instagram Bot With Meta's Official API

Key takeaways

  • The only Instagram bot you can safely build is a chatbot that answers DMs and comments through Meta's Instagram API on a business or creator account.
  • The Instagram Basic Display API was shut down on 4 December 2024. New bots use the Instagram API with Instagram Login or with Facebook Login.
  • A coded bot needs a Meta app, the instagram_business_manage_messages permission, an HTTPS webhook, and App Review plus Business Verification before it can serve other accounts.
  • A bot can only message people who contacted you first, within 24 hours of their last message, or up to 7 days when the chat started from a Click to Instagram ad.
  • Bots that follow, like, view or create accounts break Instagram's Terms of Use and lead to restrictions.

Ask an AI about this article

To build an Instagram bot today, you connect a business or creator account to Meta's Instagram API and let software answer DMs and comments for you. You can code it yourself on the Instagram API with Instagram Login, or set it up without code on a platform like Spur that is built on the same official API. Bots that follow, like or comment from your login are a different thing, and they break Instagram's rules.

This guide covers how Instagram bots work, what you need before you start, both build methods step by step (checked against Meta's developer docs on 1 December 2026), and the messaging rules your bot has to follow.

Chatbots vs engagement bots: which kind you can build

An Instagram bot is software that takes actions on an Instagram account automatically. There are two kinds, and only one is allowed.

Instagram chatbot (allowed) Engagement bot (not allowed)
What it does Answers DMs, replies to comments, sends links and products Follows, unfollows, likes, comments on strangers' posts, adds views
How it connects Meta's Instagram API with permissions you approve Logs in with your username and password
Account type Business or creator account Any account
Result Faster replies, captured leads Restrictions under Instagram's Terms

Instagram's Terms of Use forbid creating accounts or collecting information in an automated way without permission, and forbid collecting other people's usernames and passwords. That covers follower bots, view bots, account creator bots and scrapers. Everything below is about the allowed kind: an Instagram bot that talks to customers.

Already seeing a warning from a follower app? Our guide to the Instagram automated behavior warning explains how to clean it up.

How the bot loop works

Developer setting up an API integration and webhook configuration for an Instagram bot

An Instagram bot works as a loop between Meta and your server. A person sends a DM or comments on your post. Meta sends that event to your webhook URL. Your code decides what to say and calls the Instagram API to send the reply.

The loop has four parts:

  1. Webhook. An HTTPS endpoint on your server that Meta calls for each new message, comment or reaction.
  2. Logic. Your code, a set of keyword rules, or an AI model that reads the message and picks a reply.
  3. Send API. A POST request to the Instagram API that delivers the reply in the same chat.
  4. Handoff. A way for a person on your team to take over when the bot cannot help.

The handoff is the part most home-built bots skip, and customers notice. Our chatbot to human handoff guide covers when and how to pass a chat to a person.

Meta's Instagram messaging API docs list what a bot can send: text and links up to 1,000 bytes, images up to 8 MB, audio, video and PDF files up to 25 MB, stickers, reactions, your own posts, quick replies and templates. Group chats are not supported; each conversation is with one person.

What you need before you start

Before you build an Instagram bot, get these in place. Most first-time builders get stuck on the permissions and the webhook, so sort those out early.

  • A professional Instagram account. Business or creator. Meta's Instagram Platform overview only supports professional accounts.
  • A Meta developer account and a Meta app. Free to create at Meta for Developers.
  • The right permissions. For DMs, instagram_business_basic and instagram_business_manage_messages. For comments, add instagram_business_manage_comments.
  • An HTTPS server for the webhook. Any host works as long as it answers Meta quickly with a 200 response.
  • A verified business, later. To serve accounts you do not own or manage, the app needs Advanced Access, which requires App Review and Business Verification.

There is no follower minimum. The old Instagram Basic Display API is not an option: Meta shut it down on 4 December 2024 and pointed developers to the Instagram API with Instagram Login or Facebook Login.

Instagram Login or Facebook Login

Pick Instagram Login unless you need a feature that only Facebook Login has. Here is how the two compare, from Meta's platform overview:

Feature Instagram Login Facebook Login
Facebook Page required No Yes, linked to the Instagram account
API host graph.instagram.com graph.facebook.com
Messaging Yes Yes, through the Messenger Platform
Comment moderation Yes Yes
Hashtag search No Yes
Product tagging No Yes

Meta's overview also lists a newer Unified Login option for new integrations, which lets people log in with either Instagram or Facebook. The steps below use Instagram Login because it needs no Facebook Page.

How to build an Instagram bot with code: step by step

These steps follow Meta's guide to creating a Meta app with Instagram and its webhooks setup guide, checked on 1 December 2026.

  1. Switch to a professional account. In the Instagram app, change the account to Business or Creator in account type settings.
  2. Create the app. Go to Meta for Developers, click Create App, choose the use case Other, then the app type Business, and enter an app name and contact email.
  3. Add Instagram. On the App Dashboard, scroll to Instagram and click Set up. "API setup with Instagram login" is added for you.
  4. Add a test account and generate a token. Add your Instagram account as a tester (it must be public), log in when prompted, and copy the access token.
  5. Build the webhook endpoint. Meta first sends a GET request with hub.mode, hub.verify_token and hub.challenge. Check the token matches yours and return the challenge value. For every later event, return 200 OK before doing slow work, and validate the X-Hub-Signature-256 header with your app secret.
  6. Configure webhooks in the dashboard. Click Configure, enter your Callback URL and Verify token, and save. The default fields include messages, comments, live_comments, messaging_postbacks and messaging_seen.
  7. Subscribe the account. Send a POST to the account's /subscribed_apps edge on graph.instagram.com so its events reach your app.
  8. Send a reply. When a messages event arrives, take the sender's Instagram-scoped ID and send a POST to graph.instagram.com/v27.0/<IG_ID>/messages with your Instagram user access token as a Bearer token and this JSON body:
    
  
  1. Handle comments. For comment-to-DM, answer the comments event with a private reply. Meta allows one private reply per comment, within 7 days of the comment (private replies docs).
  2. Go live. The app must be Live to receive events from real users, and comment events need Advanced Access. Submit App Review with screen recordings that show each permission in use, and complete Business Verification.

Meta retries failed webhook deliveries for up to 36 hours, so make your handler ignore duplicates. Plan for the parts Meta does not give you: a database of conversations, a way to stop the bot when a person takes over, and logs.

Would rather skip the webhook server and App Review? Spur is already approved on Meta's Instagram API, so you can connect your account and launch comment-to-DM and an AI agent the same day.

How to build an Instagram bot without code

Spur Instagram automation screen showing a comment-to-DM trigger and chatbot builder

A no-code platform gives you the same Instagram bot on top of Meta's official API, with the webhook, hosting and App Review already done. You connect your account through Meta's login screen and build the flow in a visual editor. Here is how it works in Spur, based on the Spur help center:

  1. Connect Instagram. In Spur, go to Settings, open Instagram & Facebook and click Connect New Channel. You log in on Meta's page and approve permissions; Spur never sees your password.
  2. Create a workflow. Open Automations and click New Workflow, then name it.
  3. Pick a trigger. For example, an Instagram comment on a post, so the flow starts when someone comments a keyword.
  4. Add the messages. Click the plus button, choose Instagram, and add the reply: text, buttons, a link, or product cards from your store.
  5. Add logic if you need it. Delays, conditions and actions such as adding a contact tag.
  6. Test it. Comment on your own post from a second account and check the Executions tab.
  7. Turn it on. Save and switch the workflow to enabled.

On top of keyword flows, Spur's Instagram automation includes a follow-gate that checks a person follows you before sending the freebie, story mention and story reply automation, ice breakers, Live comment triggers and Click to Instagram ad flows.

Its AI agent is trained on your website and FAQs, answers follow-up questions in the DM, and hands the chat to your team in a shared inbox that also holds WhatsApp, Messenger and live chat. If you want to compare other builders, our list of no-code chatbot builders covers the field.

Messaging rules your bot must follow

An Instagram bot can only answer people who started the conversation, and only inside Meta's messaging windows. Build these rules into your logic from day one.

  • 24-hour window. After a person messages you, the bot can reply for 24 hours from their last message (messaging API docs).
  • Up to 7 days after an ad. When the first message follows a Click to Instagram ad, the window can last up to 7 days. Our post on the 7-day messaging window for Instagram ads explains the change.
  • Human Agent tag. A person on your team gets a separate 7-day window to reply, if the reply is tagged.
  • One private reply per comment. Within 7 days of the comment, and only during the broadcast for Live comments.
  • Disclosure. Meta's platform policy requires automated chats to say they are automated where the law requires it, and recommends it everywhere. Our guide to EU AI Act chatbot disclosure covers the European rule.
The complete list of limits, including rate limits and what counts as permission, is in our guide to Instagram DM automation rules.

Bot ideas that customers welcome

The best Instagram bot answers the question a person already has, using content you already wrote. Our guide on training a chatbot on your website data shows how to feed it. These flows work because the customer starts them:

  • Comment-to-DM. "Comment GUIDE and we will send it." The bot DMs the link to everyone who comments the keyword. Our Instagram auto reply to comments guide shows the setup.
  • FAQ answers. Shipping times, sizes, prices and opening hours, answered from your website content.
  • Lead capture. Ask two or three questions in the DM, save the answers, and send qualified leads to sales.
  • Story replies and mentions. Thank people who mention you and answer replies to your stories.
  • Ad conversations. Start a flow the moment someone messages from a Click to Instagram ad, while the 7-day window is open.
  • Human handoff. Pass the chat to a person when the bot is unsure, with the full conversation visible.

Choosing your Instagram bot route

Build your own Instagram bot if you have developers, need custom logic, and can handle App Review, hosting and upkeep as Meta's API versions change. Use a no-code platform if you want the bot live this week and your team to manage it without code. Either way, stay on Meta's official API, answer only people who reached out, and keep a person one tap away.

Spur gives you comment-to-DM, an AI agent and a shared inbox for Instagram, WhatsApp, Messenger and live chat on the official API. Try it with the 14-day free trial, no credit card needed.

Comparing chatbot builders? See Spur vs ManyChat, Spur vs BotPenguin, and Spur vs Engati.

Frequently asked questions

Sources

The pages this article links out to, in the order they appear.

  1. Terms of Use help.instagram.com
  2. Instagram messaging API docs developers.facebook.com
  3. Instagram Platform overview developers.facebook.com
  4. shut it down on 4 December 2024 developers.facebook.com
  5. creating a Meta app with Instagram developers.facebook.com
  6. webhooks setup guide developers.facebook.com
  7. private replies docs developers.facebook.com
  8. platform policy developers.facebook.com

Was this article useful?

All articles

Instagram 16 min

How to Measure Instagram DM ROI (2026 Guide)

Stop treating Instagram DMs like engagement. Track exact ROI using UTM links, identity capture, and Conversions API to prove what CFOs care about: profit.

Put these guides to work on your own customers.

WhatsApp, Instagram and live chat marketing and support from one inbox, with AI agents.

14-day free trial, no credit card needed

  • Meta Business Partner
  • Shopify Partner