# Twitter Auto DM (`dead00/twitter-auto-dm`) Actor

A tool for sending direct messages to multiple Twitter/X users automatically. Uses browser cookies for authentication and supports sending personalized messages with configurable delays between sends.

- **URL**: https://apify.com/dead00/twitter-auto-dm.md
- **Developed by:** [Dead](https://apify.com/dead00) (community)
- **Categories:** Automation, Social media, Lead generation
- **Stats:** 17 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$25.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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Twitter DM Scraper

An actor for sending bulk direct messages on Twitter/X. This actor authenticates using browser cookies and can send personalized messages to multiple users with configurable delays.

### Features

- **Bulk DM Sending**: Send messages to multiple Twitter users at once
- **Cookie Authentication**: Uses browser cookies for authentication (no username/password required)
- **Rate Limiting**: Configurable delays between messages to avoid rate limits
- **Error Handling**: Comprehensive error handling and logging
- **Cross-Platform**: Works on Windows, macOS, and Linux

### Input Schema

The actor expects a JSON input with the following structure:

```json
{
  "cookies": [
    {
      "name": "auth_token",
      "value": "your_auth_token_value"
    },
    {
      "name": "ct0",
      "value": "your_ct0_value"
    }
  ],
  "targets": [
    "@username1",
    "user_id_123456",
    "https://twitter.com/username2"
  ],
  "message": "Hello! This is a test message.",
  "delay_seconds": 5
}
```

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `cookies` | Array | Yes | Browser cookies from Twitter/X session |
| `targets` | Array | Yes | List of usernames, user IDs, or profile URLs |
| `message` | String | Yes | The message to send to all targets |
| `delay_seconds` | Number | No | Delay between messages (default: 5 seconds) |

### Cookie Extraction

To get the required cookies:

#### Method 1: Browser Developer Tools

1. Log into Twitter/X in your browser
2. Open Developer Tools (F12)
3. Go to Application/Storage tab
4. Navigate to Cookies → twitter.com (or x.com)
5. Export cookies for: `auth_token`, `ct0`, `kdt`, `twid`

#### Method 2: Browser Extensions

Use cookie export extensions like:

- Cookie Editor (Chrome/Firefox)
- EditThisCookie (Chrome)

#### Required Cookies

- `auth_token`: Authentication token
- `ct0`: CSRF token
- `kdt` (optional): Additional security token
- `twid` (optional): Twitter ID token

### Usage Examples

#### Basic Usage

```json
{
  "cookies": [
    {"name": "auth_token", "value": "abc123..."},
    {"name": "ct0", "value": "def456..."}
  ],
  "targets": ["elonmusk", "twitter", "jack"],
  "message": "Hello from the DM scraper!",
  "delay_seconds": 10
}
```

#### Advanced Usage with User IDs

```json
{
  "cookies": [
    {"name": "auth_token", "value": "abc123..."},
    {"name": "ct0", "value": "def456..."},
    {"name": "kdt", "value": "ghi789..."}
  ],
  "targets": [
    "44196397",
    "https://twitter.com/username",
    "another_user"
  ],
  "message": "Custom message with personalization",
  "delay_seconds": 15
}
```

### Output Schema

The actor returns a JSON object with the following structure:

```json
{
  "total_targets": 3,
  "successful_sends": 2,
  "failed_sends": 1,
  "results": [
    {
      "target": "@username1",
      "success": true,
      "error": null,
      "message": "Hello! This is a test message."
    },
    {
      "target": "@username2",
      "success": false,
      "error": "User not found",
      "message": "Hello! This is a test message."
    }
  ]
}
```

### Error Handling

Common errors and solutions:

#### Authentication Errors

- **"No cookies found"**: Ensure cookies are properly formatted in input
- **"Authentication verification failed"**: Cookies may be expired or invalid
- **"404 account/settings"**: Account may be restricted or suspended

#### DM Sending Errors

- **"User not found"**: Target username/ID doesn't exist
- **"DM send failed"**: User may have DMs disabled or blocked you
- **"Rate limit exceeded"**: Increase delay\_seconds value

### Rate Limiting

Twitter has strict rate limits for DMs:

- **Recommended delay**: 10-30 seconds between messages
- **Daily limit**: ~1000 DMs per day for verified accounts
- **Hourly limit**: ~150 DMs per hour

### Best Practices

1. **Start Small**: Test with 2-3 targets first
2. **Use Delays**: Always set delay\_seconds to at least 5 seconds
3. **Fresh Cookies**: Extract cookies from a fresh browser session
4. **Monitor Logs**: Check actor logs for authentication and sending status
5. **Respect Limits**: Don't exceed Twitter's rate limits
6. **Personalize Messages**: Avoid generic spam-like content

### Limitations

- Requires valid Twitter cookies (expires periodically)
- Subject to Twitter's rate limiting and terms of service
- May not work with accounts that have restricted DM settings

### Legal and Ethical Considerations

- Comply with Twitter's Terms of Service
- Respect user privacy and consent
- Avoid sending spam or unsolicited messages
- Use for legitimate business or personal communication only
- Consider implementing opt-out mechanisms

### License

This actor is provided for educational and legitimate use cases. Users are responsible for compliance with Twitter's terms of service and applicable laws.

***

**Note**: This tool is designed for legitimate communication purposes. Please use responsibly and in accordance with Twitter's terms of service.

# Actor input Schema

## `cookies` (type: `array`):

Browser cookies from Twitter/X session. Export from browser developer tools (F12 -> Application -> Cookies -> x.com). Must include auth\_token, ct0, and other session cookies.

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

The direct message content to send to all targets. Keep it friendly and comply with Twitter's terms of service.

## `targets` (type: `array`):

List of Twitter usernames, user IDs, or profile URLs to send DMs to. Can be usernames (without @), user IDs, or full URLs.

## `delay_seconds` (type: `integer`):

Number of seconds to wait between sending each DM. Recommended: 10-30 seconds to avoid rate limiting.

## Actor input object example

```json
{
  "cookies": [
    {
      "domain": ".x.com",
      "expirationDate": 1771085083.01971,
      "hostOnly": false,
      "httpOnly": true,
      "name": "auth_token",
      "path": "/",
      "sameSite": "no_restriction",
      "secure": true,
      "session": false,
      "storeId": null,
      "value": "e8ebde28ed35f60bbaa480fadf171a2706262770"
    },
    {
      "domain": ".x.com",
      "expirationDate": 1767339612.610054,
      "hostOnly": false,
      "httpOnly": false,
      "name": "guest_id",
      "path": "/",
      "sameSite": "no_restriction",
      "secure": true,
      "session": false,
      "storeId": null,
      "value": "v1%3A172490945488285787"
    },
    {
      "domain": ".x.com",
      "expirationDate": 1785341371.234635,
      "hostOnly": false,
      "httpOnly": false,
      "name": "twid",
      "path": "/",
      "sameSite": "no_restriction",
      "secure": true,
      "session": false,
      "storeId": null,
      "value": "u%3D1877748387220799489"
    },
    {
      "domain": ".x.com",
      "expirationDate": 1754031954.325617,
      "hostOnly": false,
      "httpOnly": false,
      "name": "external_referer",
      "path": "/",
      "sameSite": null,
      "secure": true,
      "session": false,
      "storeId": null,
      "value": "padhuUp37zjgzgv1mFWxJ12Ozwit7owX|0|8e8t2xd8A2w%3D"
    },
    {
      "domain": ".x.com",
      "expirationDate": 1785341364.009978,
      "hostOnly": false,
      "httpOnly": false,
      "name": "night_mode",
      "path": "/",
      "sameSite": "no_restriction",
      "secure": true,
      "session": false,
      "storeId": null,
      "value": "2"
    },
    {
      "domain": ".x.com",
      "expirationDate": 1753807162.25974,
      "hostOnly": false,
      "httpOnly": true,
      "name": "__cf_bm",
      "path": "/",
      "sameSite": "no_restriction",
      "secure": true,
      "session": false,
      "storeId": null,
      "value": "lF45rpP7OaBlJmu9Tj3suIRkJDraRGmUf6xctTswTfE-1753805364-1.0.1.1-Dr6v4LFkzFZd2JP4EsgYuoF6h1PRiRR1eTwNWEyINc7YD3h6capXEkLy9JXfa9NlO4Ad.B37zmBFIWOx9gojv.Y.cA3VzpeLuha2sjqYDX8"
    },
    {
      "domain": ".x.com",
      "expirationDate": 1771085083.370993,
      "hostOnly": false,
      "httpOnly": false,
      "name": "ct0",
      "path": "/",
      "sameSite": "lax",
      "secure": true,
      "session": false,
      "storeId": null,
      "value": "b49f42546ed0263e7ed05dd736255e27cb99c44fb82abe573b42ae3132c7a5272856579502280f5624892335fcc0c6a686836b689565d9d0aaf4ad2c630fb7d77a67b7863020e130eeb1ed7dbf907a0c"
    },
    {
      "domain": ".x.com",
      "expirationDate": 1785926098.181782,
      "hostOnly": false,
      "httpOnly": false,
      "name": "dnt",
      "path": "/",
      "sameSite": "no_restriction",
      "secure": true,
      "session": false,
      "storeId": null,
      "value": "1"
    },
    {
      "domain": ".x.com",
      "expirationDate": 1788365371.23405,
      "hostOnly": false,
      "httpOnly": false,
      "name": "guest_id_ads",
      "path": "/",
      "sameSite": "no_restriction",
      "secure": true,
      "session": false,
      "storeId": null,
      "value": "v1%3A172490945488285787"
    },
    {
      "domain": ".x.com",
      "expirationDate": 1788365371.234436,
      "hostOnly": false,
      "httpOnly": false,
      "name": "guest_id_marketing",
      "path": "/",
      "sameSite": "no_restriction",
      "secure": true,
      "session": false,
      "storeId": null,
      "value": "v1%3A172490945488285787"
    },
    {
      "domain": ".x.com",
      "expirationDate": 1771085083.019629,
      "hostOnly": false,
      "httpOnly": true,
      "name": "kdt",
      "path": "/",
      "sameSite": null,
      "secure": true,
      "session": false,
      "storeId": null,
      "value": "0MprSsNU5W2zirK0Kdo6YW1QFh58oyeb4Qw5RChk"
    },
    {
      "domain": ".x.com",
      "expirationDate": 1768061146.52658,
      "hostOnly": false,
      "httpOnly": false,
      "name": "personalization_id",
      "path": "/",
      "sameSite": "no_restriction",
      "secure": true,
      "session": false,
      "storeId": null,
      "value": "\"v1_fo7TidorU55HXywHnSY3Yw==\""
    }
  ],
  "message": "Hello! Hope you're having a great day! 😊",
  "targets": [
    "John_Matthew_T"
  ],
  "delay_seconds": 10
}
```

# 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 = {
    "targets": [
        "John_Matthew_T"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("dead00/twitter-auto-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 = { "targets": ["John_Matthew_T"] }

# Run the Actor and wait for it to finish
run = client.actor("dead00/twitter-auto-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 '{
  "targets": [
    "John_Matthew_T"
  ]
}' |
apify call dead00/twitter-auto-dm --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/onG7h3iPfqEpQhowi/builds/5w0wj2qcLfsrhatSr/openapi.json
