A few weeks ago, our app was approved with the following permissions:

instagram_business_manage_messages, instagram_manage_comments, instagram_manage_messages, instagram_business_manage_comments

and this is our login url with scopes, example -

https://www.instagram.com/oauth/authorize?third_party=re&client_id=867763&redirect_uri=oauth%2Fcallback&response_type=code&scope=business_basic%2Cbusiness_manage_messages%2Cbusiness_manage_comments%2Cbusiness_content_publish 

Our use case is as follows: when someone comments on our post with a matching keyword specified in our backend, we send a reply to that comment and simultaneously send a direct message (DM) to the user.

However, we're facing an issue where only 1 out of 100 comments successfully sends both the comment reply and DM. In other cases, the comment replies are sent consistently, but the DM fails with the error: "This message is sent outside of allowed window." This occurs 99% of the time.

Given that we have access to the Business API, we are unsure why we are facing this issue. Could you please advise?

this is the

error: {   error: {     message: 'This message is sent outside of allowed window.',     type: 'IGApiException',     code: 10,     error_subcode: 2534022,     fbtrace_id: 'ASeWzBS_LCXn'   } } 

same error code mentioned on fb docs https://developers.facebook.com/docs/messenger-platform/error-codes

We tried with different multiple accounts but same error, but when a user first sends a message to owner of insta post then again comments on post then it sending comment and dm successfully.

Tag:facebook, facebook-graph-api, instagram, instagram-graph-api

Only one comment.

  1. Jackson Savitraz

    You're right! It's allowed to send a DM in response to each comment. However, the message is not sent through the usual method: you need to specify as "comment_id" field the value received by webhook callback in the "recipient" property instead of "id" field, normally used. It will work without any issues.

    Wrong way:

    recipient: { id: FROM-ID }

    Correct way:

    recipient: { comment_id: COMMENT-ID }

Add a new comment.