# Making a difference between public topic and private message on API

**URL:** https://meta.discourse.org/t/making-a-difference-between-public-topic-and-private-message-on-api/108119
**Category:** Feature
**Created:** [2월 1, 2019, 11:54오전 UTC](https://meta.discourse.org/t/making-a-difference-between-public-topic-and-private-message-on-api/108119 "2019-02-01T11:54:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![TheChachara](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thechachara/32/130217_2.png) [@TheChachara](https://meta.discourse.org/u/TheChachara)
#### Post date: [2월 1, 2019, 11:54오전 UTC](https://meta.discourse.org/t/making-a-difference-between-public-topic-and-private-message-on-api/108119/1 "2019-02-01T11:54:05Z")

</div>

Hi y’all.  
I’ve created a very tiny bot for our discourse installation which fires upon a webhook.  
I’ve also connected the bot to Twitter, so every time anybody creates a new topic, a tweet is posted on our Twitter account (Thanks to Abraham for his [https://twitteroauth.com](https://twitteroauth.com))

The thing is that, because of how Discourse is created, everything is a post. Both public and private messages.  
In my particular case, here’s the post object from a _public post_:

```plaintext
stdClass Object
(
    [post] => stdClass Object
        (
            [id] => 909
            [username] => TheChachara
            [avatar_template] => /user_avatar/thechachara.com/thechachara/{size}/46_2.png
            [created_at] => 2019-02-01T11:50:23.974Z
            [cooked] => <p>Posted on a public category.</p>
            [post_number] => 1
            [post_type] => 1
            [updated_at] => 2019-02-01T11:50:23.974Z
            [reply_count] => 0
            [reply_to_post_number] => 
            [quote_count] => 0
            [avg_time] => 
            [incoming_link_count] => 0
            [reads] => 0
            [score] => 0
            [topic_id] => 63
            [topic_slug] => this-is-a-public-topic
            [topic_title] => This is a public topic
            [primary_group_name] => 
            [version] => 1
            [user_title] => 
            [moderator] => 
            [admin] => 1
            [staff] => 1
            [user_id] => 1
            [hidden] => 
            [trust_level] => 1
            [deleted_at] => 
            [user_deleted] => 
            [edit_reason] => 
            [wiki] => 
            [topic_posts_count] => 1
        )

)

```

On the other hand, this is a _private message_:

```plaintext
stdClass Object
(
    [post] => stdClass Object
        (
            [id] => 908
            [username] => TheChachara
            [avatar_template] => /user_avatar/thechachara.com/thechachara/{size}/46_2.png
            [created_at] => 2019-02-01T11:37:14.954Z
            [cooked] => <p>Esto es un mensaje de prueba</p>
            [post_number] => 1
            [post_type] => 1
            [updated_at] => 2019-02-01T11:37:14.954Z
            [reply_count] => 0
            [reply_to_post_number] => 
            [quote_count] => 0
            [avg_time] => 
            [incoming_link_count] => 0
            [reads] => 0
            [score] => 0
            [topic_id] => 62
            [topic_slug] => nuevo-mensaje-publicado
            [topic_title] => Nuevo mensaje publicado
            [primary_group_name] => 
            [version] => 1
            [user_title] => 
            [moderator] => 
            [admin] => 1
            [staff] => 1
            [user_id] => 1
            [hidden] => 
            [trust_level] => 1
            [deleted_at] => 
            [user_deleted] => 
            [edit_reason] => 
            [wiki] => 
            [topic_posts_count] => 1
        )

)

```

I can’t find a way to make a difference between them.

The solution I came to is to set which categories to report by the webhook, but I would like to control it from the bot, because tomorrow (yep, [Dory](https://www.muyinteresante.com.mx/wp-content/uploads/2018/05/httpstved-prod.adobecqms.netcontentdameditorialTelevisamexicomuyinteresantemxcuriosidadespreguntas-y-respuestas17074dorynemo.imgo_.jpeg)’s memory here) I could add a new category, and forget to allow this category to be checked when sending the webhook.

Is there a way to send more data over the webhook?

TiA people 🙂

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2월 1, 2019, 12:08오후 UTC](https://meta.discourse.org/t/making-a-difference-between-public-topic-and-private-message-on-api/108119/2 "2019-02-01T12:08:46Z")

</div>

You’ll need to look at the topic that the post belongs to. There is a field there that tells you if it is a pm.

---

<div class="post-metadata">

### Author: ![TheChachara](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thechachara/32/130217_2.png) [@TheChachara](https://meta.discourse.org/u/TheChachara)
#### Post date: [2월 1, 2019, 12:26오후 UTC](https://meta.discourse.org/t/making-a-difference-between-public-topic-and-private-message-on-api/108119/3 "2019-02-01T12:26:03Z")

</div>

> [@pfaffman](#):
>
> You’ll need to look at the topic that the post belongs to.

OK, sorry not to mention. I only process those posts that are

```plaintext
[post_number] => 1

```

Which means it’s the start of a thread.

* * *

Or maybe you’re saying that I can retrieve the more data by requesting the post by its `id` ?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2월 1, 2019, 12:30오후 UTC](https://meta.discourse.org/t/making-a-difference-between-public-topic-and-private-message-on-api/108119/4 "2019-02-01T12:30:50Z")

</div>

You need to pull the topic record. There is a topic\_id field in the post record.
