How to differentiate webhooks for created, approved or updated

(Allen - Watchman Monitoring) #1

I’m using webhooks to process new users via zapier, and lately it’s being triggered too often.

The option we have in the admin is When a user is created, approved or updated.

I thought that the email would only be sent on new user creation. but we’re getting it even if the user had a badge awarded, joined a group, etc.

So the question is… what’s the best way to identify when the webhook is related to a new user, vs a user being updated?


Webhooks for discobot and other system users
Webhooks for discobot and other system users
(Jeff Atwood) #2

Hmm I think our webhook should be more distinct here.

  • user created
  • user updated

Can you add this to your list @neil

Webhooks for discobot and other system users
(Simon Cossar) #3

You can get that from the X-Discourse-Event header field. When a user is created that field’s value will be user_created.

It seems that the User user_updated webhook is being sent every time a user creates a Topic or a Post. This didn’t used to happen and seems like a bug.

(Allen - Watchman Monitoring) #4

Thanks @Simon_Cossar it looks like Zapier doesn’t surface the headers which are sent over. Assuming we get the user_created & user_updated in the body of the webhook, I should be able to know just when to perform an action for a newly created user.

For the record, these are the fields I can act on via Zapier as of Oct 7 2017

(Allen - Watchman Monitoring) #5

I asked Zapier about this, and while the information sent in the header is awesome, they don’t include it in Zaps.

I’d love to see this information sent in the body of Discourse’s webhook, and not just the headers.

Given this set of headers:

Request URL:
Request method: POST
Accept: */*
Connection: close
Content-Length: 7429
Content-Type: application/json
User-Agent: Discourse/1.9.0.beta12
X-Discourse-Instance: https://SITE_NAME
X-Discourse-Event-Id: 168
X-Discourse-Event-Type: user
X-Discourse-Event: user_updated

Specifically: X-Discourse-Event-Type and X-Discourse-Event

Though I can see where X-Discourse-Instance would be useful too.

Maybe this change can be included with the fix for 71643

Webhook for new users
(Neil Lalonde) #6

The issue with user_updated always being triggered was fixed by @tgxworld. :tada: