WordPress · Arazzo Workflow

WordPress Comment on Found Post

Version 1.0.0

Search for a post, post a comment on it, then list comments to confirm.

1 workflow 1 source API 1 provider
View Spec View on GitHub CMSContent ManagementOpen SourceWordPressArazzoWorkflows

Provider

wordpress

Workflows

comment-on-found-post
Find a post by search and add a comment to it.
Searches content scoped to posts for the supplied query, and when a post is found creates a comment on that post, then lists the post's comments to verify the comment was recorded.
3 steps inputs: authorEmail, authorName, commentContent, query outputs: commentId, commentStatus, postId
1
findPost
searchContent
Search site content scoped to the post type for the supplied query, returning at most one result.
2
createComment
createComment
Create a comment against the post found by the search. WordPress returns 201 with the new comment id on success.
3
listPostComments
listComments
List the comments for the post to confirm the newly created comment is present.

Source API Descriptions

Arazzo Workflow Specification

wordpress-comment-on-found-post-workflow.yml Raw ↑
arazzo: 1.0.1
info:
  title: WordPress Comment on Found Post
  summary: Search for a post, post a comment on it, then list comments to confirm.
  description: >-
    A community-engagement pattern for headless WordPress. The workflow searches
    site content scoped to posts for a matching title, branches on whether a post
    was found, and when it is, creates a comment against that post id, then lists
    comments for the post to confirm the new comment landed. Each step spells out
    its request inline so the flow can be read and executed without opening the
    underlying OpenAPI description.
  version: 1.0.0
sourceDescriptions:
- name: wordpressRestApi
  url: ../openapi/wordpress-rest-api-openapi.yml
  type: openapi
workflows:
- workflowId: comment-on-found-post
  summary: Find a post by search and add a comment to it.
  description: >-
    Searches content scoped to posts for the supplied query, and when a post is
    found creates a comment on that post, then lists the post's comments to verify
    the comment was recorded.
  inputs:
    type: object
    required:
    - query
    - commentContent
    properties:
      query:
        type: string
        description: The search string used to locate the target post.
      authorName:
        type: string
        description: Display name for the comment author.
      authorEmail:
        type: string
        description: Email address for the comment author.
      commentContent:
        type: string
        description: The body of the comment to post.
  steps:
  - stepId: findPost
    description: >-
      Search site content scoped to the post type for the supplied query,
      returning at most one result.
    operationId: searchContent
    parameters:
    - name: search
      in: query
      value: $inputs.query
    - name: type
      in: query
      value: post
    - name: per_page
      in: query
      value: 1
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      postId: $response.body#/0/id
    onSuccess:
    - name: postFound
      type: goto
      stepId: createComment
      criteria:
      - context: $response.body
        condition: $.length > 0
        type: jsonpath
    - name: postMissing
      type: end
      criteria:
      - context: $response.body
        condition: $.length == 0
        type: jsonpath
  - stepId: createComment
    description: >-
      Create a comment against the post found by the search. WordPress returns 201
      with the new comment id on success.
    operationId: createComment
    requestBody:
      contentType: application/json
      payload:
        post: $steps.findPost.outputs.postId
        author_name: $inputs.authorName
        author_email: $inputs.authorEmail
        content: $inputs.commentContent
    successCriteria:
    - condition: $statusCode == 201
    outputs:
      commentId: $response.body#/id
      commentStatus: $response.body#/status
  - stepId: listPostComments
    description: >-
      List the comments for the post to confirm the newly created comment is
      present.
    operationId: listComments
    parameters:
    - name: post
      in: query
      value: $steps.findPost.outputs.postId
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      firstCommentId: $response.body#/0/id
  outputs:
    postId: $steps.findPost.outputs.postId
    commentId: $steps.createComment.outputs.commentId
    commentStatus: $steps.createComment.outputs.commentStatus