Using webhook only when the topic been created

Hello dear Discourse users :slight_smile:
Recently I have started to use Webhooks. I have set a webhook and integromat (similar to zapier) so that every new topic that has been created in my community, will be published on our Facebook page. The problem is that it will publish it again if someone has done some change to the topic (like edit or comment). I would like to set a Webhook which sends data only when new topic has been created (meaning only one).
So I thought of two approaches to this issue. The first approach is somehow to make the webhook send only when the topic had been created. But I could not find if its possible on Discourse. The second approach is somehow to check if the page with that id, already been published. This way is more complicated and a bit overkill.
Maybe I’m missing something and the solution is far more easier. What is the proper way to solve it?
Is it a valid request to ask to make the Webhooks options more specific?
Thank you all for the help! :smiley:

1 Like

You can check whether a webhook has been sent for a new post, or for an edited post, by looking at the webhook’s X-Discourse-Event header. For a new post the header will be set to post_created. For an edited post it will be set to post_edited.

I haven’t used intergromat, but the process for filtering based on the event type on Zapier is outlined here: Discourse Webhooks and Zapier - #32 by simon.

Yes, I think so. I haven’t run into issues with the Post Event webhook, but I’d really like to see a way of limiting the User Event webhook so that it is only sent when a user is created or updated.

4 Likes

Here’s how you set up the filter in integromat:

5 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.