# Comment Post for Linkedin (`addeus/comment-post`) Actor

Programmatically post comments on LinkedIn. Perfect for integrating with AI workflows (ChatGPT) or auto-reply systems. Supports emojis and residential proxies. Designed for precision engagement, not spam.

- **URL**: https://apify.com/addeus/comment-post.md
- **Developed by:** [Addeus](https://apify.com/addeus) (community)
- **Categories:** Social media, Automation, Integrations
- **Stats:** 30 total users, 0 monthly users, 0.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.005 / actor start

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## LinkedIn Comment Post Actor

Actor Apify pour automatiser les commentaires sur les posts LinkedIn en utilisant Puppeteer pour une simulation complète du comportement utilisateur.

### Fonctionnalités

- **Commentaire automatique** sur n'importe quel post LinkedIn via son URL
- **Authentification par cookies** (li_at) - pas besoin d'OAuth
- **Détection intelligente** de la zone de commentaire avec plusieurs stratégies
- **Soumission automatique** du commentaire
- **Anti-détection** - masque les flags webdriver pour éviter la détection
- **Gestion d'erreurs robuste** avec retry et fallback

### Input Parameters

| Paramètre     | Type   | Requis | Description                                                 |
| ------------- | ------ | ------ | ----------------------------------------------------------- |
| `postUrl`     | String | ✅ Oui | L'URL complète du post LinkedIn à commenter                 |
| `commentText` | String | ✅ Oui | Le texte du commentaire à poster                            |
| `liAtCookie`  | String | ✅ Oui | Cookie d'authentification LinkedIn (li_at)                  |
| `userAgent`   | String | ❌ Non | User-Agent personnalisé (défaut: Chrome 131 Windows)        |
| `jsessionid`  | String | ❌ Non | Cookie JSESSIONID optionnel pour authentification renforcée |

#### Exemple d'Input

```json
{
    "postUrl": "https://www.linkedin.com/feed/update/urn:li:activity:1234567890",
    "commentText": "Great post! Thanks for sharing this valuable information.",
    "liAtCookie": "AQEDATxxxxxx..."
}
```

### Comment Obtenir Vos Cookies

#### Cookie li_at (REQUIS)

1. Ouvre ton navigateur et connecte-toi sur LinkedIn
2. Ouvre les DevTools (F12)
3. Va dans **Application** → **Cookies** → **https://www.linkedin.com**
4. Trouve le cookie `li_at` et copie sa valeur complète

### Output

```json
{
    "postUrl": "https://www.linkedin.com/feed/update/urn:li:activity:1234567890",
    "success": true,
    "message": "Comment posted successfully",
    "commentText": "Great post!",
    "timestamp": "2025-10-16T14:30:00.000Z"
}
```

### Formats d'URL Supportés

- `https://www.linkedin.com/feed/update/urn:li:activity:1234567890`
- `https://www.linkedin.com/posts/username_activity-1234567890-abcd`
- `https://linkedin.com/feed/update/...` (sans www)

### Architecture Technique

#### Stratégies de Détection du Champ Commentaire

L'actor utilise plusieurs stratégies pour trouver la zone de commentaire:

1. `.comments-comment-box__form .ql-editor`
2. `div[role="textbox"][contenteditable="true"]`
3. `.comments-comment-texteditor .ql-editor`
4. `.comments-comment-box-comment__text-editor .ql-editor`

#### Workflow

1. **Lancement du browser** Puppeteer en mode headless
2. **Configuration** user-agent, cookies
3. **Navigation** vers l'URL du post
4. **Attente** du chargement de la page
5. **Détection** du champ commentaire
6. **Saisie** du texte du commentaire
7. **Click** sur le bouton de soumission
8. **Sauvegarde** du résultat dans le dataset

### Notes Importantes

#### Sécurité & Authentification

- Le cookie `li_at` est ta session LinkedIn - **garde-le secret**
- Les cookies expirent après un certain temps (renouvelle-les si erreur)

#### Rate Limiting

- LinkedIn peut limiter les actions automatisées trop fréquentes
- Recommandé: ajouter des délais entre plusieurs commentaires
- Utilise avec modération pour éviter les restrictions de compte

#### Légal & CGU

- Cet actor est à des fins **éducatives et de test**
- L'automatisation peut violer les CGU de LinkedIn
- **Utilise à tes propres risques**

### Développement Local

#### Installation

```bash
cd comment-post
npm install
```

#### Test Local

Crée un fichier `input.json`:

```json
{
    "postUrl": "https://www.linkedin.com/feed/update/urn:li:activity:YOUR_POST_ID",
    "commentText": "Your comment here",
    "liAtCookie": "YOUR_LI_AT_COOKIE"
}
```

Lance:

```bash
npm start
```

### Dépendances

- **Apify SDK** v3.1.0+ - Framework pour actors
- **Puppeteer** v24.0.0+ - Automation du navigateur Chrome
- **Node.js** 20.0.0+ - Runtime

### Troubleshooting

#### "Not logged in" Error

- Vérifie que ton cookie `li_at` est valide et complet
- Le cookie peut avoir expiré

#### "Comment box not found"

- L'URL du post est peut-être incorrecte
- Le post peut ne plus exister ou être privé

#### "Submit button not found or not enabled"

- Le commentaire peut être trop court
- LinkedIn peut nécessiter une action supplémentaire (captcha, etc.)

### License

ISC

***

**Créé avec ❤️ pour Apify**

# Actor input Schema

## `postUrl` (type: `string`):

The full URL of the LinkedIn post you want to comment on

## `commentText` (type: `string`):

The text of your comment

## `liAtCookie` (type: `string`):

Your LinkedIn authentication cookie (li_at). You can find it in your browser's cookies for linkedin.com

## `userAgent` (type: `string`):

The User-Agent string to use (REQUIRED)

## Actor input object example

```json
{
  "postUrl": "https://www.linkedin.com/feed/update/urn:li:activity:1234567890",
  "commentText": "Great post! Thanks for sharing.",
  "liAtCookie": "AQEDATxxxxxx...",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
}
```

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("addeus/comment-post").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("addeus/comment-post").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{}' |
apify call addeus/comment-post --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,addeus/comment-post"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/zFd1JjAf6WHHohz1C/builds/hCthfbMK3bkHo2DqE/openapi.json
