Reacting and commenting
This page describes how to create workflows for reacting and commenting on LinkedIn posts.
Each example below has its Node SDK call in the Node tab, and the label over each completion says what that call returns.
Each example below has its Python SDK call in the Python tab, and the label over each completion says what that call returns.
Each example below has its CLI command in the CLI tab, and the label over each completion says what the command prints.
Reacting to post
To react to a post, you need to include st.reactToPost action in your workflow. Here's an example:
Workflow:
{
"actionType": "st.reactToPost",
"postUrl": "https://www.linkedin.com/posts/post1",
"type": "like"
}Completion:
Completion – the method returns no data; a failed action comes back in errors:
Completion – with --json the CLI prints {"success": true, "data": null}, or the action's error:
{
"actionType": "st.reactToPost",
"success": true
}Commenting on post
To comment on a post, you need to include st.commentOnPost action in your workflow. Here's an example:
Workflow:
{
"actionType": "st.commentOnPost",
"postUrl": "https://www.linkedin.com/posts/post1",
"text": "I completely agree with your point."
}Completion:
Completion – result() returns its data in data, and a failed action in errors:
Completion – with --json the CLI prints its data as data, or the action's error:
{
"actionType": "st.commentOnPost",
"success": true
}Reacting + commenting
To react and comment on the same post, you need to include st.reactToPost and st.commentOnPost as child actions of st.openPost action. Here's an example:
Workflow:
{
"actionType": "st.openPost",
"postUrl": "https://www.linkedin.com/posts/post1",
"basicInfo": false,
"then": [
{
"actionType": "st.reactToPost",
"type": "like"
},
{
"actionType": "st.commentOnPost",
"text": "I completely agree with your point."
}
]
}Completion:
Completion – result() returns this whole completion in data:
Completion – linkedin workflow run prints this whole completion as data:
{
"actionType": "st.openPost",
"success": true,
"data": {
"then": [
{
"actionType": "st.reactToPost",
"success": true
},
{
"actionType": "st.commentOnPost",
"success": true
}
]
}
}Reacting to a comment
To react to a comment, you need to include st.reactToComment action in your workflow. It accepts a commentUrl, which you can obtain from the commentUrl field returned by st.commentOnPost, st.replyToComment, or st.retrievePostComments. Here's an example:
Workflow:
{
"actionType": "st.reactToComment",
"commentUrl": "https://www.linkedin.com/feed/update/urn:li:activity:1234567890123456789/?dashCommentUrn=urn%3Ali%3Afsd_comment%3A(9876543210%2Curn%3Ali%3Aactivity%3A1234567890123456789)",
"type": "like"
}Completion:
Completion – the method returns no data; a failed action comes back in errors:
Completion – with --json the CLI prints {"success": true, "data": null}, or the action's error:
{
"actionType": "st.reactToComment",
"success": true
}Replying to a comment
To reply to a comment, you need to include st.replyToComment action in your workflow. It returns the commentUrn and commentUrl of the created reply. Here's an example:
Workflow:
{
"actionType": "st.replyToComment",
"commentUrl": "https://www.linkedin.com/feed/update/urn:li:activity:1234567890123456789/?dashCommentUrn=urn%3Ali%3Afsd_comment%3A(9876543210%2Curn%3Ali%3Aactivity%3A1234567890123456789)",
"text": "Thanks for sharing your thoughts!"
}Completion:
Completion – result() returns its data in data, and a failed action in errors:
Completion – with --json the CLI prints its data as data, or the action's error:
{
"actionType": "st.replyToComment",
"success": true,
"data": {
"commentUrn": "urn:li:comment:(urn:li:activity:1234567890123456789,1122334455)",
"commentUrl": "https://www.linkedin.com/feed/update/urn:li:activity:1234567890123456789/?dashCommentUrn=urn%3Ali%3Afsd_comment%3A(1122334455%2Curn%3Ali%3Aactivity%3A1234567890123456789)"
}
}Engaging with all comments on a post
To react to or reply to every comment on a post without knowing their URLs upfront, retrieve the comments with st.retrievePostComments and iterate over them with st.doForComments. Each iterated comment can either react/reply directly, or open first with st.openComment to run several comment-scoped actions. Here's an example that likes and replies to each of the 3 most relevant comments:
Workflow:
{
"actionType": "st.retrievePostComments",
"postUrl": "https://www.linkedin.com/posts/post1",
"limit": 3,
"sort": "mostRelevant",
"then": {
"actionType": "st.doForComments",
"then": {
"actionType": "st.openComment",
"then": [
{
"actionType": "st.reactToComment",
"type": "celebrate"
},
{
"actionType": "st.replyToComment",
"text": "Great point, thanks for sharing!"
}
]
}
}
}Completion:
Completion – result() returns this whole completion in data:
Completion – linkedin workflow run prints this whole completion as data:
{
"actionType": "st.retrievePostComments",
"success": true,
"data": [
{
...
"then": {
"actionType": "st.openComment",
"success": true,
"data": {
"commentUrn": "urn:li:comment:(urn:li:activity:1234567890123456789,9876543210)",
"commentUrl": "https://www.linkedin.com/feed/update/urn:li:activity:1234567890123456789/?dashCommentUrn=urn%3Ali%3Afsd_comment%3A(9876543210%2Curn%3Ali%3Aactivity%3A1234567890123456789)",
"then": [
{
"actionType": "st.reactToComment",
"success": true
},
{
"actionType": "st.replyToComment",
"success": true,
"data": {
"commentUrn": "urn:li:comment:(urn:li:activity:1234567890123456789,1122334455)",
"commentUrl": "https://www.linkedin.com/feed/update/urn:li:activity:1234567890123456789/?dashCommentUrn=urn%3Ali%3Afsd_comment%3A(1122334455%2Curn%3Ali%3Aactivity%3A1234567890123456789)"
}
}
]
}
}
}
]
}This page provides examples of workflows and their completions. For detailed documentation on constraints, parameters, and possible results of specific actions, always refer to the corresponding action documentation pages.