How to differentiate webhooks for created, approved or updated

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?

Thanks!

2 Likes

Hmm I think our webhook should be more distinct here.

  • user created
  • user updated

Can you add this to your list @neil

5 Likes

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.

Thanks @simon 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

https://gist.github.com/YesThatAllen/8e6f835042a4fc6fb09c9dfee2163e2c#file-discourse_webhook_data-txt-L8-L14

2 Likes

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: https://hooks.zapier.com/hooks/catch/REDACTED/
Request method: POST
Accept: */*
Connection: close
Content-Length: 7429
Content-Type: application/json
Host: hooks.zapier.com
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

3 Likes

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

6 Likes

It’s somewhat complicated, but you can extract the webhook’s request header on Zapier with the method outlined in this post: https://meta.discourse.org/t/discourse-webhooks-and-zapier/56753/32.

2 Likes