developer guide
DM Automation API: Comment-to-DM on Instagram and Facebook
ESER API Engineering August 6, 20269 min read
ESER AI · field notes
How to implement automated Comment-to-DM funnels on Instagram and Facebook via API, complying with Meta policies and 24-hour service windows.
## Implementing Comment-to-DM Automations via API
Comment-to-DM automation allows creators and brands to deliver digital downloads, discounts, and resource links directly into user inboxes whenever they comment with a trigger keyword on a post or reel.
---
### Meta Platform Compliance Rules
When implementing automated messaging via the Meta Graph API, strict guardrails apply:
- **24-Hour Messaging Window:** Direct messages can only be sent within 24 hours of an inbound interaction.
- **Account Types:** Requires an Instagram Professional (Creator or Business) account connected to a Facebook Page.
- **User Consent:** Triggers must be clearly communicated to users in post captions (e.g. "Comment GUIDE below to receive the PDF").
---
### ESER AI API Contract
Create an active automation with a single `POST` request to `https://app.eserai.tech/v1/automations/dm`:
```json
{
"name": "Ebook Delivery Funnel",
"platform": "instagram",
"accountId": "acc_instagram_sample",
"triggerType": "COMMENT",
"postScope": "SPECIFIC",
"postId": "post_live_12345",
"keywords": ["EBOOK", "DOWNLOAD", "PDF"],
"responseTemplate": "Hey! Thanks for commenting. Here is your direct download link: https://eserai.tech/resources/ebook.pdf",
"publicCommentReply": "Just sent the download link to your DMs! 🚀",
"isActive": true
}
```
---
### Webhook Event Pipeline
When a user comments on your post, ESER AI's webhook listeners match keywords in real time, issue the public comment acknowledgement, and dispatch the private message with sub-second latency.
Automate your social strategy with ESER AI
Ingest content sources and generate multi-platform posts automatically.