st.doForComments
This action allows you to apply the actions specified in its then parameter to each comment provided by the parent action.
This action cannot start a workflow, so the SDK has no method for it: put it under its parent action in the workflow you pass to customWorkflow – see Building Workflows.
This action cannot start a workflow, so the CLI has no command for it: put it under its parent action in the workflow you pass to linkedin workflow run – see Building Workflows.
The comments this action iterates over are the ones returned by the parent st.retrievePostComments action, so their number is controlled by its
limitparameter.
Constraints
⏺️ Root Start: not allowed.
⬆️ Parent Actions: st.retrievePostComments.
⬇️ Child Actions: st.openComment, st.reactToComment, st.replyToComment.
Parameters
{
"actionType": "st.doForComments",
"then": { ... }
}then– object or array of child actions to apply to each comment from the parent action.
Result options
This action doesn't produce its own distinct result. The effects are visible in the comments that were involved, as they will contain a then field with the results of the applied actions. See usage examples for more details.
Usage examples
- Liking the 5 most relevant comments on a post:
Workflow:
{
"actionType": "st.retrievePostComments",
"postUrl": "https://www.linkedin.com/posts/post1",
"limit": 5,
"sort": "mostRelevant",
"then": {
"actionType": "st.doForComments",
"then": {
"actionType": "st.reactToComment",
"type": "like"
}
}
}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.reactToComment",
"success": true
}
},
{
...
"then": {
"actionType": "st.reactToComment",
"success": true
}
}
]
}- Reacting to and replying to each comment through the
st.openCommentwrapper:
Workflow:
{
"actionType": "st.retrievePostComments",
"postUrl": "https://www.linkedin.com/posts/post1",
"limit": 3,
"then": {
"actionType": "st.doForComments",
"then": {
"actionType": "st.openComment",
"then": [
{
"actionType": "st.reactToComment",
"type": "celebrate"
},
{
"actionType": "st.replyToComment",
"text": "Well said, 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)"
}
}
]
}
}
}
]
}