# Instagram Bulk Messenger (`webscrap18/instagram-bulk-dm`)

This actor allows you to send the Individual DM's to Multiple users.

- **URL**: https://beta-securitybyobscurity.apify.com/webscrap18/instagram-bulk-dm.md
- **Developed by:** [WebScrap](https://beta-securitybyobscurity.apify.com/webscrap18) (community)
- **Categories:** Automation, Developer tools, Social media
- **Stats:** 45 total users, 8 monthly users, 6.3% runs succeeded, 3 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

$15.00/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period.
You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#rental-actors

# README

## Instagram Bulk DM Sender

This Actor allows you to send personalized direct messages to multiple Instagram users with customizable delays between messages.

### Features

- Send messages to multiple Instagram users
- Personalize messages with randomized variations
- Configurable delays between messages to avoid rate limiting
- Authentication methods:
  - Cookie-based authentication (bypasses 2FA)

### Authentication Methods

#### 1. Cookie-based Authentication (Recommended)

This method bypasses 2FA and is the most reliable. You can obtain your Instagram cookies:

##### Using browser developer tools

For Puppeteer automation, you can export the cookies as a JSON file:

- you can use the [xport-cookie JSON plugin](https://chromewebstore.google.com/detail/nmckokihipjgplolmcmjakknndddifde?utm_source=item-share-cb) to export the cookies in a JSON format compatible with Puppeteer sessions.
- Log into Instagram
- Click on the extension icon
- Click "Export" to save the cookies in JSON format
- This JSON file can be directly used with Puppeteer for automation

### Message Templates

You can use a simple templating system to randomize parts of your messages:

```
Hey {there|hi|hello}, how are you {doing|feeling} today?
```

This will randomly select one option from each set of braces, creating variations like:

- "Hey there, how are you doing today?"
- "Hey hi, how are you feeling today?"
- "Hey hello, how are you doing today?"

### Input Fields Description

- **Instagram Cookies**\
  Paste your Instagram session cookie string here.

- **Target Usernames**\
  A list of Instagram usernames to whom the message should be sent. You can:
  - Add usernames one by one.
  - Use the **Bulk Edit** feature to input multiple usernames at once.
  - Use **Remove Empty Fields** to clean up unused entries.

- **Message Template**\
  The message content to be sent to each user. You can optionally use template syntax to randomize messages:
  ```
  Are you {good|doing okay|feeling fine}? 😊
  ```
  This adds natural variation to reduce detection as automated messaging.

- **Minimum Delay (seconds) (optional)**\
  The minimum amount of time (in seconds) to wait between sending messages. Recommended value: 60 seconds or more.

- **Maximum Delay (seconds) (optional)**\
  The maximum wait time (in seconds) between two consecutive messages. A random delay between min and max will be used to simulate human behavior and avoid rate limits.

### Output

The Actor returns a JSON object containing:

```json
{
  "success": true,
  "sent": [
    {
      "username": "username1",
      "user_id": "12345678",
      "message": "Hey there, how are you doing today?",
      "timestamp": "2025-05-22T12:34:56.789Z"
    }
  ],
  "failed": [
    {
      "username": "non_existent_user",
      "error": "User not found",
      "timestamp": "2025-05-22T12:35:56.789Z"
    }
  ],
  "total_sent": 1,
  "total_failed": 1
}
```

### Notes

- To avoid being rate-limited by Instagram, keep the delays reasonably high (at least 30-60 seconds between messages)
- Instagram has automatic protections against spam, so use this tool responsibly
- For best results, use an account that has been active for a while and has established relationships with the users you're messaging
- Using a saved session can help avoid frequent logins which may trigger security measures

### License

This Actor is proprietary software. All rights reserved.

No permission is granted for any use, copying, modification, distribution, or operation of this software without explicit written permission from the owners. If you wish to use this software, please contact us for licensing information.

### Disclaimer

This Actor is not affiliated with, authorized, maintained, sponsored or endorsed by Instagram or any of its affiliates or subsidiaries. Use at your own risk and responsibility.

# Actor input Schema

## `cookies` (type: `string`):

Instagram cookies for authentication. Can be in JSON format or raw cookie string. Use this to bypass 2FA requirements.

## `session_file` (type: `string`):

Path to a previously saved Instagram session file. If provided, it will be used instead of username/password.

## `usernames` (type: `array`):

List of Instagram usernames to send messages to.

## `message` (type: `string`):

Message template with optional randomized parts. Use {option1|option2|option3} syntax for random selection.

## `min_delay` (type: `integer`):

Minimum delay between sending messages (in seconds).

## `max_delay` (type: `integer`):

Maximum delay between sending messages (in seconds).

## `save_session` (type: `boolean`):

Whether to save the session for future use.

## `session_path` (type: `string`):

Path where to save the session file if save\_session is enabled.

## Actor input object example

```json
{
  "usernames": [
    "username1",
    "username2"
  ],
  "message": "Hey {there|hi|hello}, how are you {doing|feeling} today?",
  "min_delay": 10,
  "max_delay": 20,
  "save_session": true,
  "session_path": "./instagram_session.json"
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "usernames": [
        "username1",
        "username2"
    ],
    "message": "Hey {there|hi|hello}, how are you {doing|feeling} today?",
    "min_delay": 10,
    "max_delay": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("webscrap18/instagram-bulk-dm").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "usernames": [
        "username1",
        "username2",
    ],
    "message": "Hey {there|hi|hello}, how are you {doing|feeling} today?",
    "min_delay": 10,
    "max_delay": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("webscrap18/instagram-bulk-dm").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "usernames": [
    "username1",
    "username2"
  ],
  "message": "Hey {there|hi|hello}, how are you {doing|feeling} today?",
  "min_delay": 10,
  "max_delay": 20
}' |
apify call webscrap18/instagram-bulk-dm --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=webscrap18/instagram-bulk-dm",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Instagram Bulk Messenger",
        "description": "This actor allows you to send the Individual DM's to Multiple users.",
        "version": "0.1",
        "x-build-id": "ixlffloh7pdm32A7Q"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/webscrap18~instagram-bulk-dm/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-webscrap18-instagram-bulk-dm",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/webscrap18~instagram-bulk-dm/runs": {
            "post": {
                "operationId": "runs-sync-webscrap18-instagram-bulk-dm",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/webscrap18~instagram-bulk-dm/run-sync": {
            "post": {
                "operationId": "run-sync-webscrap18-instagram-bulk-dm",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "cookies",
                    "usernames",
                    "message"
                ],
                "properties": {
                    "cookies": {
                        "title": "Instagram Cookies (Make sure cookies are latest and valid)",
                        "type": "string",
                        "description": "Instagram cookies for authentication. Can be in JSON format or raw cookie string. Use this to bypass 2FA requirements."
                    },
                    "session_file": {
                        "title": "Session File (Optional)",
                        "type": "string",
                        "description": "Path to a previously saved Instagram session file. If provided, it will be used instead of username/password."
                    },
                    "usernames": {
                        "title": "Target Usernames",
                        "type": "array",
                        "description": "List of Instagram usernames to send messages to.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "message": {
                        "title": "Message Template",
                        "type": "string",
                        "description": "Message template with optional randomized parts. Use {option1|option2|option3} syntax for random selection."
                    },
                    "min_delay": {
                        "title": "Minimum Delay (seconds)",
                        "minimum": 5,
                        "type": "integer",
                        "description": "Minimum delay between sending messages (in seconds)."
                    },
                    "max_delay": {
                        "title": "Maximum Delay (seconds)",
                        "minimum": 10,
                        "type": "integer",
                        "description": "Maximum delay between sending messages (in seconds)."
                    },
                    "save_session": {
                        "title": "Save Session",
                        "type": "boolean",
                        "description": "Whether to save the session for future use.",
                        "default": true
                    },
                    "session_path": {
                        "title": "Session Save Path",
                        "type": "string",
                        "description": "Path where to save the session file if save_session is enabled.",
                        "default": "./instagram_session.json"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
