LinkedIn + ConnectSafely.ai, DMs sent to commenters
“Comment link and I’ll send it over.” Then your post does well. Now you are stuck scrolling, checking who asked, copying the same DM, and hoping you don’t miss anyone (or message the same person twice).
This is the kind of LinkedIn DM automation that helps creators keep momentum, but it’s also a lifesaver for coaches and marketers running lead magnets. You deliver the resource fast, keep your follow-ups consistent, and stop losing leads in the comments.
Below is the exact n8n workflow that watches a post for a keyword, checks connection status, and sends a safe, paced DM through ConnectSafely.ai. You’ll see how it works, what you need, and where teams usually trip up.
How This Automation Works
The full n8n workflow, from trigger to final output:
n8n Workflow Template: LinkedIn + ConnectSafely.ai, DMs sent to commenters
flowchart LR
subgraph sg0["1️⃣ Form: Enter Post Details Flow"]
direction LR
n0["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/form.svg' width='40' height='40' /></div><br/>1️⃣ Form: Enter Post Details"]
n1@{ icon: "mdi:cog", form: "rounded", label: "2️⃣ Fetch All Comments", pos: "b", h: 48 }
n2@{ icon: "mdi:swap-vertical", form: "rounded", label: "3️⃣ Split Comments Array", pos: "b", h: 48 }
n3@{ icon: "mdi:swap-vertical", form: "rounded", label: "4️⃣ Loop: Process Each Comment", pos: "b", h: 48 }
n4["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>5️⃣ Detect Keyword Match"]
n5@{ icon: "mdi:swap-horizontal", form: "rounded", label: "6️⃣ If: Keyword Found?", pos: "b", h: 48 }
n6@{ icon: "mdi:cog", form: "rounded", label: "7️⃣ Check Connection Status", pos: "b", h: 48 }
n7@{ icon: "mdi:swap-horizontal", form: "rounded", label: "8️⃣ If: Connected?", pos: "b", h: 48 }
n8@{ icon: "mdi:cog", form: "rounded", label: "9️⃣ Send DM with Link", pos: "b", h: 48 }
n9@{ icon: "mdi:cog", form: "rounded", label: "🔟 Wait: Rate Limiting", pos: "b", h: 48 }
n10@{ icon: "mdi:cog", form: "rounded", label: "⏭️ Skip: No Match / Not Conn..", pos: "b", h: 48 }
n11@{ icon: "mdi:cog", form: "rounded", label: "✅ All Comments Processed", pos: "b", h: 48 }
n7 --> n8
n7 --> n10
n9 --> n3
n8 --> n9
n1 --> n2
n5 --> n6
n5 --> n10
n2 --> n3
n4 --> n5
n6 --> n7
n0 --> n1
n3 --> n11
n3 --> n4
n10 --> n3
end
%% Styling
classDef trigger fill:#e8f5e9,stroke:#388e3c,stroke-width:2px
classDef ai fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
classDef aiModel fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
classDef decision fill:#fff8e1,stroke:#f9a825,stroke-width:2px
classDef database fill:#fce4ec,stroke:#c2185b,stroke-width:2px
classDef api fill:#fff3e0,stroke:#e65100,stroke-width:2px
classDef code fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
classDef disabled stroke-dasharray: 5 5,opacity: 0.5
class n0 trigger
class n5,n7 decision
class n4 code
classDef customIcon fill:none,stroke:none
class n0,n4 customIcon
The Problem: “Comment for link” turns into inbox chaos
On paper, “comment X and I’ll DM you” is simple. In real life, it’s a mess once comments stack up. You have to open the post, scan for the keyword, click each profile, check if they’re a 1st-degree connection, then send a message that doesn’t feel copy-pasted. Do that for 30 people and you’ve burned a chunk of your afternoon. Do it for a post that goes semi-viral and you will either give up, reply late, or make sloppy mistakes that cost trust (and leads).
It adds up fast. Here’s where the friction usually hits.
- You end up doing the same “deliver the link” DM dozens of times per post, which quietly steals about 1–2 hours when engagement is high.
- People who comment early get the resource, and everyone else waits, which makes you look inconsistent even if your content is solid.
- You can’t DM non-connections, so you waste time clicking around just to discover you’re blocked from messaging them.
- When you rerun the process later, duplicates happen, and frankly that’s the fastest way to feel spammy without meaning to.
The Solution: Keyword-triggered DMs sent safely via ConnectSafely.ai
This workflow turns your LinkedIn comments into an automated fulfillment pipeline. You submit three inputs in a simple form: your post URL, the trigger keyword (like “link” or “template”), and the resource URL you want to send. n8n then pulls every comment on that post using the ConnectSafely.ai API, loops through them one by one, and checks if the keyword appears (case-insensitive). If it matches, the workflow verifies the commenter is a 1st-degree connection, because that’s required for DMs. Then it sends a personalized message that includes their name and your link. Finally, it waits a randomized delay between sends to reduce the risk of LinkedIn flagging your account, and continues until it finishes the comment list.
The workflow starts with your form submission. It fetches and splits comments into individual items, checks keyword match, checks connection eligibility, then sends the DM and waits about 15–30 minutes before the next send. Slow on purpose. Safer, too.
What You Get: Automation vs. Results
| What This Workflow Automates | Results You’ll Get |
|---|---|
|
|
Example: What This Looks Like
Say a post gets 60 comments, and 30 people type your keyword (“link”). Manually, even a quick routine is maybe 2 minutes per person to find them, confirm you can DM, paste the message, and send. That’s about an hour, and it’s boring work. With this workflow, you spend about 5 minutes filling the form once. Then it runs in the background and sends DMs with safe delays (so it can take several hours), but your hands-on time is basically done.
What You’ll Need
- n8n instance (try n8n Cloud free)
- Self-hosting option if you prefer (Hostinger works well)
- ConnectSafely.ai for LinkedIn comments, connection checks, and DMs
- LinkedIn account connected inside ConnectSafely.ai
- ConnectSafely.ai API key (get it from Settings → API Keys)
Skill level: Beginner. You’ll mostly paste credentials, pick nodes, and test with a real post.
Don’t want to set this up yourself? Talk to an automation expert (free 15-minute consultation).
How It Works
You submit the post details. The workflow begins when you fill out the n8n form with the LinkedIn post URL, your trigger keyword, the content link to deliver, and your name for the signature.
Comments are fetched and cleaned up. n8n calls the ConnectSafely.ai LinkedIn endpoint to retrieve comments, then splits them into individual comment items so each one can be evaluated on its own.
Matching and eligibility checks happen before any DM goes out. A keyword check (case-insensitive) filters to only the people who actually asked. Then a second check verifies the commenter is a 1st-degree connection, since LinkedIn DMs don’t reliably work otherwise.
DMs are sent, then paced out. When someone qualifies, the workflow sends a personalized DM with the promised link, waits a randomized delay for account safety, and loops to the next comment until it reaches the end.
You can easily modify the keyword logic to support multiple trigger words, or adjust the wait time to be more conservative. See the full implementation guide below for customization options.
Step-by-Step Implementation Guide
Step 1: Configure the Form Trigger
Set up the input form that captures the LinkedIn post URL, keyword, and link to send before the workflow begins processing comments.
- Add and configure 1️⃣ Capture Post Inputs as the trigger.
- Set the Form Title to
🤖 LinkedIn Keyword Auto-Responder. - Confirm the form fields exist with labels: LinkedIn Post URL, Trigger Keyword, Content Link to Send, and Your Name (for signature) (all required).
- Keep the Form Description content as provided to guide users through the submission.
Step 2: Connect LinkedIn and Load Comments
Retrieve comments from the specified LinkedIn post and prepare them for batch processing.
- Open 2️⃣ Retrieve Post Comments and set Post URL to
={{ $json['LinkedIn Post URL'] }}. - Set Account ID to your LinkedIn account identifier (replace
[YOUR_ID]). - Credential Required: Connect your ConnectSafely LinkedIn credentials in 2️⃣ Retrieve Post Comments.
- In 3️⃣ Separate Comment Items, set Field to Split Out to
comments. - Keep 4️⃣ Iterate Through Comments as the batch controller to loop through each comment item.
[YOUR_ID] is not replaced in 2️⃣ Retrieve Post Comments, the API call will fail.Step 3: Set Up Keyword Matching and Routing
Evaluate each comment for the trigger keyword and verify if the commenter is a first-degree connection before sending a DM.
- In 5️⃣ Evaluate Keyword Match, keep the provided JavaScript logic for case-insensitive matching.
- Verify that 6️⃣ Keyword Match Check uses the condition Left Value
={{ $json.isKeywordMatch }}with the boolean operator set to true. - Configure 7️⃣ Verify Connection Status with Profile ID set to
={{ $('4️⃣ Iterate Through Comments').item.json.publicIdentifier }}and replace[YOUR_ID]in Account ID. - Credential Required: Connect your ConnectSafely LinkedIn credentials in 7️⃣ Verify Connection Status.
- In 8️⃣ Connection Approved?, confirm the condition Left Value is
={{ $json.connected }}with the boolean operator set to true. - Route non-matching or unapproved connections to ⏭️ Skip Non-qualifiers, which loops back to 4️⃣ Iterate Through Comments.
Step 4: Configure DM Dispatch and Rate Control
Send the personalized DM to qualified commenters and add a randomized delay to avoid rate limits.
- Open 9️⃣ Dispatch DM with Link and set Message to
=Hey {{ $('4️⃣ Iterate Through Comments').item.json.authorName }}! 👋 Thanks for your comment on my post! As promised, here's the link you requested: 👉 {{ $('1️⃣ Capture Post Inputs').item.json['Content Link to Send'] }} If you have any questions or want more resources like this, just let me know! Best, {{ $('1️⃣ Capture Post Inputs').item.json['Your Name (for signature)'] }}. - Set Recipient Profile ID to
={{ $('4️⃣ Iterate Through Comments').item.json.publicIdentifier }}and replace[YOUR_ID]in Account ID. - Credential Required: Connect your ConnectSafely LinkedIn credentials in 9️⃣ Dispatch DM with Link.
- In 🔟 Delay for Rate Control, set Amount to
={{ Math.floor(Math.random() * (1800 - 900 + 1)) + 900 }}to pause 15–30 minutes between messages. - Confirm the loop: 9️⃣ Dispatch DM with Link → 🔟 Delay for Rate Control → 4️⃣ Iterate Through Comments, and the final completion node ✅ Comments Processing Done.
Step 5: Test and Activate Your Workflow
Validate the workflow end-to-end using a real LinkedIn post and keyword before turning it on for production use.
- Click Execute Workflow and submit the form in 1️⃣ Capture Post Inputs with a valid post URL and keyword.
- Confirm that 2️⃣ Retrieve Post Comments returns comment data and 3️⃣ Separate Comment Items splits them correctly.
- Verify a matching comment routes through 6️⃣ Keyword Match Check → 7️⃣ Verify Connection Status → 8️⃣ Connection Approved? and triggers 9️⃣ Dispatch DM with Link.
- Check that non-matching comments route through ⏭️ Skip Non-qualifiers and still allow the batch loop to continue.
- Once successful, toggle the workflow to Active to run in production.
Common Gotchas
- ConnectSafely.ai credentials can expire or lose permissions. If things break, check your ConnectSafely.ai dashboard connection status (it should show LinkedIn as connected) before editing anything in n8n.
- If you’re using Wait nodes or external processing, timing is not guaranteed. This workflow intentionally waits about 15–30 minutes between DMs, so increase the delay if downstream nodes fail or LinkedIn starts throwing “cannot send message” errors.
- Default message templates are polite but generic. Add your brand voice in the “Dispatch DM with Link” step, or you’ll end up rewriting messages manually anyway.
Frequently Asked Questions
About 30 minutes if your ConnectSafely.ai account is already connected to LinkedIn.
No coding is required for the basic setup. You’ll mainly paste your API key, choose the right credentials in the ConnectSafely nodes, and run a test submission.
Yes. n8n has a free self-hosted option and a free trial on n8n Cloud. Cloud plans start at $20/month for higher volume. You’ll also need to factor in ConnectSafely.ai costs based on your plan.
Two options: n8n Cloud (managed, easiest setup) or self-hosting on a VPS. For self-hosting, Hostinger VPS is affordable and handles n8n well. Self-hosting gives you unlimited executions but requires basic server management.
Yes, and it’s one of the best tweaks to make. In the “Evaluate Keyword Match” code step, you can switch from a single keyword to a simple list (for example: “code”, “template”, “link”). You can also tighten matching so “link” doesn’t match unrelated words, which helps when comments get noisy.
Usually it’s an expired API key or your LinkedIn session inside ConnectSafely.ai is no longer connected. Regenerate the API key (Settings → API Keys), update the credential in n8n, and confirm your LinkedIn status shows as connected in the ConnectSafely.ai dashboard. If the post is private or the URL is incomplete, comment retrieval can fail too. Also worth checking: some commenters can’t be messaged even if they’re connected, because their messaging settings are restricted.
A lot, but it will take time because of the built-in 15–30 minute delay between messages. Practically, many accounts stick to about 30–50 DMs per day for safety, and higher-volume accounts often spread sends across multiple days for the same post.
Often, yes, because this workflow depends on looping through many comments, adding logic checks, and pacing sends safely. Zapier/Make can handle simple triggers, but they get awkward (and expensive) when you need batching, conditional routing, and waits between items. n8n also gives you the self-hosting option, which matters once you’re processing lots of engagement. If you want help deciding based on your volume and risk tolerance, Talk to an automation expert.
Once this is live, your posts can take off without creating a DM backlog you dread. Set it up once, then let the workflow handle delivery while you stay focused on the next piece of content.
Need Help Setting This Up?
Our automation experts can build and customize this workflow for your specific needs. Free 15-minute consultation—no commitment required.