Wrote up my comment automation setup a while back and got a bunch of DMs (ironic, I know) asking for the DM version instead of comments. So here’s that one. Same general idea, different trigger, and honestly the DM side is where this actually gets interesting because people ask real, specific questions in DMs, not just “price?” like they do in comments.
The problem with static DM auto replies
If you’ve used InstantDM’s built in auto reply or keyword triggers, you know they’re solid for the basics, someone DMs “info” and gets a templated response back instantly. But the second someone writes something like “does the medium size run small or true to fit” instead of the expected keyword, a template just can’t handle that. Routing the actual DM text through an AI model before replying fixes that gap completely.
The setup
Instagram DM → InstantDM webhook → Make custom webhook → Filter → AI module (OpenAI or Claude) → HTTP module back to InstantDM
Step 1: Get InstantDM sending DMs into Make
In InstantDM, go to Settings, Integrations, Webhook Configuration, and point it at a custom webhook module in a fresh Make scenario. Copy the URL Make generates and paste it into InstantDM’s webhook field, then select the dm_received event specifically. That’s the event that fires for every inbound message, so this is the one you want here, not comment or postback.
Grab your API key too while you’re in there, Settings, Integrations, API Keys. You’ll need it in the header for the reply call later.
Step 2: Filter before it touches the AI
Don’t send every single DM straight to an AI model without a filter first, it’s a waste of API calls and money. I run mine through a router with a couple of branches:
- If the message is a single word or emoji, route to a static fallback reply instead of burning a call on yes.
- If the message contains something clearly transactional, like an order number pattern, route to a different flow entirely rather than letting AI touch order details.
- Everything else goes to the AI branch.
Step 3: The AI module
Drop in an OpenAI (Create a Chat Completion) or Anthropic module and map the incoming message text into the user message field. My system prompt is intentionally narrow:
You're replying to an Instagram DM for [brand]. Answer only using the product info below. Keep replies under 3 sentences, warm but not overly enthusiastic. If you don't know the answer, say you'll have someone from the team follow up, don't guess.
[paste product FAQ / sizing info / shipping policy here]
That last line matters more than anything else in the prompt. Without it, the model will confidently make up a return policy that doesn’t exist, and now you’ve got a screenshot problem.
Step 4: Send the reply back through InstantDM
HTTP module, “Make a Request”:
Method: POST
URL: https://api.instantdm.com/api-webhook
Headers:
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
Body:
{
"action": "send_message",
"type": "dm",
"recipient_id": "{{sender_id}}",
"message": {
"text": "{{ai_reply}}"
}
}
Same endpoint regardless of what you’re sending, just swap the recipient and message body.
Things I learned the annoying way
The 24 hour messaging window is real and InstantDM doesn’t override it, if you’re outside that window with a given user, the send just fails silently unless you’re checking for errors. I added a Slack alert on any non 200 response from that HTTP module so I actually notice when something didn’t send instead of assuming it did.
Strip the AI output before sending. Models love prefacing answers with “Sure, here’s a response:” or wrapping things in quotes. A quick text parser step to clean that up saved me from a few replies that clearly read like they came from a bot repeating instructions back.
Cap the token limit low, somewhere around 80-100 tokens. Long, rambly DM replies feel worse than a short one, and it keeps this cheap to run at volume.
I also log every AI generated reply alongside the original question into a Google Sheet, one branch off the router before the HTTP call. Not for anything fancy, just so I can scroll through weekly and see if the AI is answering things reasonably or if my system prompt needs tightening.
Started this on one low traffic account for about two weeks before trusting it anywhere with real customer volume, would recommend the same to anyone copying this. Happy to share the actual scenario blueprint if that’s easier than rebuilding from a text writeup.