Webhook event `post_type`

AI-generated summary

In a support discussion about the post_type field in Discourse webhooks, Lucas_Alves seeks documentation and clarification on how to distinguish between user actions like comments, shared posts, or other events. simon explains that Post.types in the Rails console reveals four post types: :regular=>1, :moderator_action=>2, :small_action=>3, and :whisper=>4. Regular user posts (comments or topic starters) are type 1; moderator actions (e.g., handling flags) are type 2; system-generated topic status changes are type 3; and whispers are type 4. Lucas_Alves further asks how to tell if a post is a reply versus a new topic, and whether sharing events are available. smileBeda responds that a post is likely a comment if post_type=1, post_number>1, and version=1. To identify replies to specific posts, check reply_to_post_number. They also express frustration over the lack of documentation and suggest renaming post to comment for clarity. The discussion highlights gaps in official webhook documentation and offers practical workarounds for developers integrating with Discourse.

I’m integrating with the webhook, and when I receive a Post event, we have the post_type field. How can I find the type list? Do we have documentation about webhook events?

In resume, I wondering to discover if the user made a comment, shared a post, or another related event.

Maybe this should be documented here: Configure webhooks that trigger on Discourse events to integrate with external services.

You can get the post types from the rails console by running Post.types. That returns

:regular=>1, :moderator_action=>2, :small_action=>3, :whisper=>4

Any regular post on the site will have its post_type field set to 1 (regular.)

Post type 2 (moderator_actions) is for posts that are generated when moderators handle flags in the review queue. I think that’s the only time that post type is used.

Post type 3 (small_actions) is for posts that are automatically generated when a topic is opened, closed, etc.

Post type 4 is for whisper posts.

Got it.

Is there some way to know if the user created a post or just reply another post?
And do we have the event when the user shares a topic/post?

@Lucas_Alves … must be so frustrating to just get no instructions, but also to completely miss any doc about it. Like, at least, for me it is frustrating.

Now, since I found your post here which was exactly what I was looking for, let me share how I detect if it is a “comment” (strictly speaking a POST that is a FOLLOW UP of any kind to the TOPIC)

  1. the post_type is 1
  2. the post_number is greater than 1
  3. the version is 1

If you want to specifically get only replies to a specific other coment you could use reply_to_post_number (if not empty, that is the post number of the post being replied to)

I hope this helps, and I wish, Discourse would call this object property comment, not post, just like they call like for Like actions!