How to manually manage comments

Configuring a response to an Instagram callback

You need to toggle the switch in the connected Instagram account within the Messengers section to enable your bot to respond to comments.

If Instagram displays "Reconnect to work with comments" under your Official Instagram connection, you need to reconnect Instagram to update the necessary permissions. To do this, click the trash icon in the lower right corner (delete bot).

Connect the Instagram account again. How to connect Instagram, see here.

It works with comments under Reels as well as under posts.

When a user comments on a post, a callback is sent to the bot (you can view it in the "Clients" section within the user's dialog).

The callback has the format: client_wall_reply_new link id: text

where:

  • link is the post link

  • id is the record ID

  • text is the comment text

We can work with comments in two ways: reply with your comment or write one message in Direct.

client_wall_reply_new - is a common part of the callback.

client_wall_reply_new_comment - if we are interested in comments only on the post

client_wall_reply_new_live - if the comments are only during live broadcast

How to set up an auto-reply to comments in Direct

Copy the callback and go to the Funnel Constructor section. Create a block of the type "Primary condition check" or "Non-state condition" and paste the copied callback into the condition. We are setting up a check "For the presence of keywords"

If you want to set up a reaction to comments under any post for any comment, then in the terms you specify only client_wall_reply_new_comment.

During selecting a match, it sets “Keyword match".

Important note:

If you plan to set up a reaction to a specific post, include client_wall_reply_new_comment followed by the post ID in the trigger field.

ATTENTION!

If you plan to set up a reaction to a specific post, include client_wall_reply_new_comment followed by the post ID in the trigger field.

ATTENTION!

In the reply field, enter the text you want to send as a response to this comment.

Above the message, it indicates that it was sent in response to a comment. If you click on "View post", you will be redirected to the post you commented on.

If a user leaves a comment that you haven't configured a response for (or if you haven't set up any responses), you can reply to them with a single Direct Message in the "Clients" section.

How to use direct Instagram post links when working with comments

To work with comments, you need to enable the "Respond to comments" toggle in the Instagram Channels section.

When a user comments on a post, a notification appears in the chat within the Clients section containing the comment text, and the instagram_media_url variable is generated with a link to the publication.

You can use the instagram_media_url variable to set up reactions to comments on specific Instagram posts.

Let's look at an example.

Setting up different responses based on which post was commented on

Task: The account has several posts, including three featuring products at different prices. Configure responses to comments on these three posts to reply with the exact price. For all other posts, respond with "By agreement." The response should be sent both as a Direct Message and as a comment under the post.

Solution:

  1. Set up keyword-based reactions for comments on the posts. This means the bot will react to any post where a comment contains the specified keywords.

  2. Use the insta_create_comment function in the Calculator to post a comment under the relevant post, while also setting the response text in the Message text field to send a Direct Message. This allows the user to receive the price simultaneously in both the comments and Direct Messages.

  3. If a comment containing the keywords appears under any other post, the user will receive a message saying "by agreement."

Step 1. In the Start block trigger field, enter client_wall_reply_new followed by the keywords you want to trigger a response. Set the match type to "Keyword match".

Example to copy:

client_wall_reply_new_comment (price|how many|cost|find out)

If you only want to respond to comments under posts, use client_wall_reply_new_comment. If you only want to respond to comments during a live broadcast, use client_wall_reply_new_live.

Comments under Reels work the same way as under simple posts.

Step 2. In the "Calculator" field, declare a text variable. Its value is determined by an IF condition that checks the instagram_media_url variable.

Example to copy (remember to replace the links with your actual post URLs). You can copy the URL from the instagram_media_url variable in the client's chat (Clients section) after they comment on the relevant post:

text = if(instagram_media_url == "https://www.instagram.com/reel/Cagzkx", "$10", if(instagram_media_url == "https://www.instagram.com/p/CqvCq4", "$29", if(instagram_media_url == "https://www.instagram.com/p/CocLhN", "$35", "Other")))

Step 3. Use the insta_create_comment method to post a comment.

Example to copy:

insta_create_comment("#{text}")

where #{text} is the response text we send to the user.

Step 4. In the Message text field, enter the variable containing the response for the Direct Message.

In this example, the variable is #{text}. The same response is posted as a comment and duplicated in the Direct Message. You can configure different responses for each if needed.

client_wall_reply_new is the common prefix of the callback. To target only comments under posts, use client_wall_reply_new_comment. To target only comments during a live broadcast, use client_wall_reply_new_live.

How to post a comment in response to a message under a post or during a live broadcast

When working with comments and setting up responses under a post, use a random function and send a variable text. If the bot repeatedly sends identical text, you may encounter the error: "This API call does not support the requested response format." You can learn more about working with the random function here.

Step 1. In the Clients section, copy the callback (notification) indicating a comment has been posted, then navigate to the Builder.

Step 2. Create a "Start" or "Trigger" block and paste the copied callback into the Trigger field.

There are several ways to configure the bot's trigger condition.

In this example, the bot responds to comments under all posts with the message "reply in comments." To set this up, enter the main callback prefix and the keyword in the condition field:

client_wall_reply_new_comment reply in comments

Important: set the matching type to "Keyword match".

ATTENTION!

client_wall_reply_new is the common prefix of the callback that triggers for both posts and live broadcasts.

To respond only to comments under posts, use: client_wall_reply_new_comment

To respond only to comments during a live broadcast, use: client_wall_reply_new_live

Step 3. In the response field, enter #{none}.

Step 4. In the "Calculator" field, write:

insta_create_comment("your comment text response")

Your comment text should be placed inside the parentheses.

Then, click "Done".

With this configuration, as in the example, the bot-generated comment will be posted in response to any comment under a post containing the keywords "reply in the comments".

Example of a bot's response to a comment in the comments.

The bot's response to ANY comment under ANY post.

If you enter only the general callback prefix client_wall_reply_new in the "Trigger" field, your comment will be posted in response to comments under all posts (regardless of the text the user wrote).

The bot's response to A SPECIFIC PHRASE under ANY post.

If you leave in the "Trigger" field client_wall_reply_new and the keyword, then your comment will be sent in response to the comments with the keyword under all posts.

The bot's response to A SPECIFIC PHRASE under A SPECIFIC post.

Copy the full callback from the clients section and put it in the Start block field:

How to save comment text to a variable

To save the text of a user's comment, use the comment_text() function.

Insert the callback client_wall_reply_new in the Trigger field. Then, in the "Calculator" field, assign the text to a variable—for example, comm (you can use any other name):

comm = comment_text()

Next, click "Add condition" in the calculator and specify:

comm = comment_text()

How to delete a comment

The function insta_delete_comment(comment_id) deletes a comment.

If comment_id is not provided, the function uses the client variable instagram_last_comment_id.

On success, it returns {"success":true}. If a non-existent comment_id is provided, it returns {"An unexpected error has occurred. Please retry your request later."}.

Working with account mentions

How to mention in media

When a user tags your profile in their post, your bot will receive the following callback:

The following variables appear:

mention_caption — post caption

post_url — post link

mention_comments_count — number of comments

mention_like_count — number of likes

mention_media_id — post id

Let's configure a reaction to respond to a mention.

To do this, create a "Primary Condition Check" or "State with Condition" block. In the "Condition" field, enter mention_in_media and set the match type to "Keyword match".

In the "Calculator" field, enter the following method:

reply_to_mention(text)

where text is the comment that will appear under the mentioned post. You can specify a variable (inserted without quotes inside the parentheses) or enter the text directly (enclosed in quotes).

Example:

Step 1. Go to the builder and create a block with a trigger (Start block or Trigger block). Then, in the Trigger field, specify the callback mention_in_media.

Select "Mention in post" in the trigger list, and as the calculator method, choose "Reply comment to a post". Then, enter the text for the reply comment.

Step 2. Click "Add trigger". The trigger along with the method will then be entered into the block:

How to mention in a comment

When a user tags your account in the comments, the chat will receive a callback like:

If your account is tagged in a private profile, the callback will not be received.

The following variables will also appear in the client card:

  • mention_like_count — number of likes

  • mention_media_id — post ID

Let's configure a reaction to respond to a mention in a comment.

To do this, create a "Start" or "Trigger" block. In the "Condition" field, enter mention_in_comment and set the match type to "Keyword match".

In the "Calculator" field, enter the following method:

reply_to_mention(text)

where text is the comment that will be posted in reply to the mention. You can specify a variable (inserted without quotes inside the parentheses) or enter the text directly (enclosed in quotes).

Example:

Step 1. Go to the builder, create a block with a trigger (Start block or Trigger block), and enter the following callback in the "Trigger" field:

Next, select the condition "Mention in comment".

Step 3. Click on Calculator and in the field that appears, enter the method:

reply_to_mention("Response text for mention in comment")

How to mention other profiles in the comments under your posts

If someone is tagged in the comments under your account, the variable mentioned_in_comment is created in the client card.

It stores the person's username who was tagged. If more than two people are tagged, the usernames are stored in an array.

If you need to segment users who have tagged two or more friends, you can assign a variable like len = arr_len(mentioned_in_comment) and then compare that variable with the desired value.

Last updated