How to retrieve order comment via REST?

I have a question about order comment. I post comment below an order, and I want to retrieve order comment. But how can I get these data? Like who post the comment, and what content he post? Can I get these information by webhook?

2 Likes

Hey @Alfred27

Alas, it’s not possible to do this in REST presently, though you may know it’s possible to get Order timeline comment events via the GraphQL Admin API. Something like this would work :

query {
  order(id: "gid://shopify/Order/xxxxxxxxxxxxx"){
        id
        createdAt
        hasTimelineComment
   
        events(first: 10) {
          edges {
            node {
              __typename
              id
              message
            }
      }
    }
  }
}

This would return you :

"node": {
              "__typename": "CommentEvent",
              "id": "gid:\/\/shopify\/CommentEvent\/78327073407032",
              "message": "test comment"
            }
      }

I will certainly make it known as a feature request though internally. Hope that helps.

2 Likes

Any news on getting query access to these via API?

1 Like

Would love this too! I think order comments are super useful to include in the app

Is it possible to post order timeline comment using graphql?

Thank you for this ! In my case, I was interested in fetching the attachments that were linked to the order comments.

I struggled with the query for a bit but finally got it to work, in case anybody is stuck on this, here’s how you can modify the above query to also get the attachments from the comments:

order(id: "gid://shopify/Order/xxxxxxxx"){
        id
        createdAt
        hasTimelineComment
        events(first: 10) {
          edges {
            node {
              __typename
              ... on CommentEvent {
                id
                message
                attachments {
                  id
                  url
                }
              }
            }
      }
    }
  }

This will only return the ‘id’ and ‘url’ attributes for all events that are typed “CommentEvent”

Hi Luke, Any update on this request through the rest API? I can see Shopify are pushing more towards graph ql, is this why the feature still has not been action 2 years later?

Does anyone know if there is a way to fetch the timeline comments based on the text within the message?

I am trying to identify the payout ID via a workflow and it is written in the timeline comments, but I do not need to grab all of the timeline comments, just the 1 which contains the payout.

The events are all accessible through the graph ql

Thanks. I didn’t know how to modify the request to only grab the relevant messages. Not a developer here, just know enough to automate a few things. I am using make.com’s shopify connection and was able to grab all the timeline comments and pull out the one I need which will work for now.

Go on a course and learn how to do i would suggest or ask chat gbt to do it for you if you don’t know what your doing.

I was able to modify the query to get the information I needed. thanks again.

Moin Moin @Alfred27 . Any news on this feature request? I’d love to use it via API too.

@all: Do you know a way to receive comments via webhook?