Instagram Engagement Automations, Now in the Ayrshare API
If you’ve been asked to build “ManyChat for our users” inside your product, this one’s for you. The Ayrshare API now supports Instagram engagement automations: rules that trigger a DM, webhook, or email when an end user’s Instagram account receives a specific type of engagement.
A keyword-matching comment on a post, a story reply, or a comment on a story. Each can trigger a DM, a webhook into your own pipeline, an email, or any combination. Every rule is configured per profile, lives behind your existing Ayrshare integration, and stays within Meta’s published policies. That last part is most of the work.
What the Instagram Graph API Allows (And What it Doesn’t)
Before the capabilities, the constraints. Anyone who has worked against the Instagram Graph API knows the gap between what customers ask for and what Meta permits is wider than it looks.
Three things that get requested constantly and are not possible on the public API:
- Auto-DM on new followers. The Instagram Graph API does not emit follower events. There is no webhook to subscribe to, and no way to trigger an action when someone follows an account.
- First-message DMs to strangers. Meta requires the user to initiate contact before a business account can message them. You cannot DM a user who has not engaged with you.
- Bulk outbound campaigns to your audience. Beyond per-account hourly DM caps, Meta’s anti-abuse heuristics flag burst patterns and suspend accounts that trip them.
Engagement-triggered messaging is in policy and is now in the API. The end-user has already opened the conversation by commenting, replying, or interacting with a story. Responding to them is allowed.
Trigger Types and Action Types: The Full API Surface
Four trigger types, three action types. Mix freely.
Triggers
| Type | Fires when |
|---|---|
comment_keyword | A comment matching one or more keywords lands on a specific post |
story_reply | A user replies to a story (also identified as a DM) |
dm_reaction | A user reacts to a DM |
dm_keyword | A user sends a DM message |
Actions
| Type | Does |
|---|---|
send_dm | DMs the user who triggered the rule, using a template |
fire_webhook | POSTs the event to a webhook of your choosing |
send_email | Sends an email to an address you specify |
A single automation can carry multiple actions. Fire a webhook into your analytics pipeline and send a DM from the same rule.
What an Instagram Automation Rule Looks Like
POST /automations
{
"platform": "instagram",
"name": "SPRING20 discount drop",
"triggers": [
{
"type": "comment_keyword",
"postId": "<ig-media-id>",
"keywords": ["SPRING", "spring", "discount"]
}
],
"actions": [
{
"type": "send_dm",
"message": "Hi {{recipient_username}}, thanks for engaging. Here's your code: SPRING20"
}
]
}
That is the entire surface. Update with PUT /automations/:id, pause by setting active: false, delete with DELETE /automations/:id, list yours with GET /automations, and audit every fire with GET /automations/:id/activity.
Use Cases: Comment-to-DM, Story Reply Automations, and More
The SPRING/SPRING20 example above is one shape. A few others worth picturing:
- Realtor with a new listing. Followers comment “Viewing” on the post, and the API DMs them a calendar link to book a property tour.
- Content creator selling tickets to a live event. Fans reply “Presale” to a story, and the API DMs them the early-access code.
- Travel brand running a destination campaign. Viewers comment with the destination name, and the API DMs them the itinerary plus a booking link.
Every example above hits the same endpoint with the same trigger and action types. Only the keywords and message content differ.
What the Ayrshare API Handles So Your Users Don’t Get Banned
A thin “reply to a comment with a DM” implementation looks easy. It also ends in account suspensions. Meta’s rules around messaging are not suggestions, and a few of them deserve specific mention:
- Daily DM caps per account. Meta enforces them. The API schedules to stay under both Meta’s caps and your tier’s daily ceiling, with per-profile sub-caps so one chatty creator does not burn the budget for the rest of your customers.
- Anti-bot heuristics on burst patterns. Identical timing on every DM looks like a bot. The API adds randomized delay on dispatch so traffic does not fingerprint.
- Duplicate-DM risk. If the same person triggers the same rule twice in a week, you do not want them to receive the same DM twice. The API dedupes per recipient on a 7-day rolling window by default.
- Webhook retries from Meta. Meta retries on non-200 responses. That is good for delivery and bad for naive implementations that fire the action on every retry. Incoming events are persisted and idempotency-keyed at ingress, so a Meta retry is a silent no-op.
- Visibility. Every fire writes an activity record: what triggered it, what action ran, whether it was sent, was rate-limited, deduped, or failed. Paginated via
GET /automations/:id/activity.
An API’s compliance posture is inherited by every product built on it. The work here is keeping your end-users’ accounts safe at volumes no human DM workflow would ever have produced. AI agents and high-throughput creator platforms now generate exactly those volumes.
How This Fits Into Your Existing Ayrshare Integration
Engagement automations live alongside the existing publishing, history, analytics, messaging, and moderation endpoints. Same multi-tenant architecture, same OAuth flows, same rate-limit budgeting. If you have already integrated Ayrshare publishing for your end-users, the automations endpoint reads against the same profile references you are already passing. No new auth, no new identifiers.
AI content agents can use the same endpoint to respond to comments and story interactions on the accounts they manage, with rate-limiting and deduplication applied identically.
The Ayrshare API is also built to support AI content agents managing accounts at large volumes. Agents operating on behalf of your users follow the same rate-limiting and deduplication logic as any other integration: the compliance layer doesn’t know or care whether the trigger came from a human or a workflow.
Plans, Limits, and How to Get Started
Instagram engagement automations are available on Business and Enterprise plans; up to 10 active automations per profile on Business, 50 on Enterprise. Every mutation routes through the API, and every event lands in the audit trail.
No migration required for existing customers. The one prerequisite: your connected Instagram account needs messaging enabled if it isn’t already.
The Automations API is in beta and we are actively collecting feedback. Endpoints, payloads, and limits may change as we iterate. Please send feedback and bug reports to support so we can prioritize the right improvements.
The full endpoint reference is in the API docs. If you’re already integrated, you can call the automations endpoints against your current API key and profile references at launch.
Ready to build? Get started with the Ayrshare API.