How to automate Instagram DM's
This guide takes you through the step-by-step process of setting up a bot to send Instagram DMs. However, if you are keen to get started quickly, we have a one-click setup template you can use instead of this guide.
Below the overall bot structure:
Design pattern: Instagram DM part 1
Below the steps nested in the "If condition" step:
Design pattern: Instagram DM part 2
- 2.3 If condition
- 2.3.1 Click element
- 2.3.2 Wait
- 2.3.3 Click element
- 2.3.4 Wait
- 2.3.5Enter text
- 2.3.6 Press key(s)
# Create a blank Google Sheet
Create a Google Sheet, in Col A add links to profiles and in Col B insert your DM.
| A | B |
|---|---|
| https://www.instagram.com/alfiesmith81/ | My custom message 1 |
| https://www.instagram.com/axiom.ai/ | My custom message 2 |
# Start from blank, adding the following steps
In the axiom.ai (opens new window) Chrome extension, click "New Automation" and then select "Start from Blank". Use the step finder to add the steps outlined below.
# Add a ‘Read data from a Google Sheet’ step
We start making our automation by fetching our DM content from the Google Sheet we created. To set up this step, follow these instructions.
- Spreadsheet - Search for the Google Sheet you created in the "Spreadsheet" field. Once found, click to select.
- Sheet name - Choose a sheet tab or leave blank to use the first tab.
- First cell - Start from a specified column and row, "A1".
- Last cell - End at a specified column and row, "AB1".
Tip
💡 For our test runs, set "Last cell" to "AB1" to send a single DM. When you are ready to send more DMs, change it to "AB10" for example, to send 10 direct messages. Instagram does set limits, and you will be blocked if you exceed them.
# Add a ‘Loop through data’ step
This step loops the automation sending the direct messages.
- Loop through data - Click ‘Insert data’ select ‘google-sheet-data’.
# Add a ‘Go to page’ sub-step to load the Instagram profiles
Next we load the Instagram profiles into a Chrome browser ready to send the DMs.
- Enter URL - Click ‘Insert data’ select ‘google-sheet-data’ and the Col containing the links.
# Add a "Get data from bot"s current page' sub-step
Now using the selector tool, choose the div that wraps around the header of the Instagram profile page.
- Select - Click select the header containing the message button.
# Add a "If condition" sub-step
Now using an "If condition" we check the header we just scraped for the text "Message" to confirm we can DM the Instagram user. If found the bot will send a DM,
- Data to check - Click select the "[scrape-data]".
- Condition to check - Words insert text "Message", you will need to localise the text.
- Reverse condition - Set to "Run steps if condition is true".
# Add a ‘Click element’ to click the DM button
Our next step we set up to click the ‘Message’ button that loads Direct messages with the correct Instagram user selected.
- Select - Click "Select" highlight the ‘submit’ button click on it.
- Click - "Custom" and tick "Use element text instead of HTML", followed by "Complete".
# Add a ‘Wait’ step to pause the bot for a moment
A dialog confirmation window opens but only when you run the bot, we need to pause the bot to allow it to open so we can click it.
# Add a ‘Click element’ to close the dialog window
Our next step we set up to click the ‘Not now' button to close this window which is only visible when the bot runs.
- Select - Click "Select" highlight the ‘Not now’ button click on it.
- Click - "Custom" and tick "Use element text instead of HTML", followed by "Complete."
# Add a ‘Wait’ step to pause the bot for a moment
We need a short pause to allow the dialog to close
# Add an ‘Enter text’ step to type in the direct message
Next up we enter our DM using an "Enter text" step, we will need to pass in the DM from the Google Sheet.
- Text - Click ‘Insert data’ select ‘google-sheet-data’ to pass the message from the Sheet. Select column ‘B’ in the preview.
Tip
💡 Learn to check the cursor position when automating forms. In this case the cursor is already in the text input field we do not need to select it.
# Add an ‘Press key(s)’ step to send DM
Almost done, next we record a keystroke to send the Direct Message.
- Record - Click ‘Record’ then press "Return", finally click "Stop recording".
# Add a ‘Delete rows from a Google Sheet’ sub-step
Finally, we delete the processed row that has just been completed in the Loop so that we do not send multiple DMs to the same Insta user.
- Spreadsheet - Search for the Google Sheet you created in the "Spreadsheet" field. Once found, click to select.
- Sheet name - Choose a sheet tab or leave blank to use the first tab.
- First row to delete - Leave set to 1.
- Last row to delete - Leave set to 1.
# Wrapping up
By following these steps, it's possible to automate sending direct messages on Instagram. Sending too many messages can get your account blocked, but it works well if you stick within Instagram's DM limits. Better still, there is an Instagram template that can be set up with a single click.
