Solved

How to retrieve order comment via REST?

Alfred27
Visitor
2 0 2

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?

Accepted Solution (1)

Luke_K
Shopify Staff
402 66 100

This is an accepted solution.

 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.

 

| Shopify |
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!

View solution in original post

Replies 12 (12)

Luke_K
Shopify Staff
402 66 100

This is an accepted solution.

 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.

 

| Shopify |
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
alex-hancock
Tourist
4 0 5

Any news on getting query access to these via API?

DaisyDreamsSG
Shopify Partner
28 0 6

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

ShubhamEkade
Shopify Partner
5 0 0

Is it possible to post order timeline comment using graphql?

AliYous
Shopify Partner
1 0 0

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"

robwatkins88
Shopify Partner
16 0 0

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?

Joseph_Levatino
New Member
8 0 0

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. 

robwatkins88
Shopify Partner
16 0 0

The events are all accessible through the graph ql

Joseph_Levatino
New Member
8 0 0

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. 

robwatkins88
Shopify Partner
16 0 0

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. 

Joseph_Levatino
New Member
8 0 0

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

dj_thossi
Shopify Partner
9 0 1

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?