Setting up webhooks


#21

As per a couple of posts above is there anyway to extract the user email address on user event create/update? As I dont see it on the user payload.


(Erlend Sogge Heggen) #22

A post was split to a new topic: Trying to set up SSO


#23

I’ve been playing with this and I am getting nowhere. Need some help here :slight_smile:

I am trying to deliver new forum posts into a Discord chat channel. The webhook is triggered, but it fails with this error in the response:

{"code": 50006, "message": "Cannot send an empty message"} 

So it looks like for some reason Discourse is sending an empty message to Discord.

Any clues?

Thanks


(Daniela) #24

You can try cloning this repo from critcola


(Allen Huang) #25

Is the notification web hook plugin available now? I can not find it on Github.


(Erick Guan) #26

This sample plugin enables the notification web hook. GitHub - fantasticfears/discourse-webhooks-example


(Pad Pors) #27

Hi,

is there any way to make a webhook that notifies when a new user is created?

it should be possible using “user event”, but this item notifies for every user and not just the new ones. any idea how to limit it for new sign ups?

p.s.: I also tried new user event webhook limited to “TL0” group, but it doesn’t notify anything.


(Allen - Watchman Monitoring) #28

I don’t see how to limit the webhook to just “new user” but the headers have the webhook reason:

X-Discourse-Event-Id: 414
X-Discourse-Event-Type: user
X-Discourse-Event: user_created

Unfortunately, the last time I asked, some services like Zapier can’t filter on the header data.

You might be able to act on last_seen_at, or other keys which would only be empty on their first visit:

  "last_seen_at": null,
  "time_read": 0,
  "stats": [],

Or check out @fantasticfears plugin, see if it works for you:


(Nitin Sapre) #29

Hey Erick, does this plugin still work? I’ve installed it and enabled the notification events for my web hook. Although users are receiving notifications, I don’t see any events being triggered for the web hook. Please help me figure this out. Thanks!


(Tranquyet) #30

Hi @fantasticfears,
How can i get user email include in POST payload ? Is there any config to allow include user email ?
Thanks.

{
  "post": {
    "id": 19,
    "name": "user",
    "username": "user",
    "avatar_template": "/letter_avatar_proxy/v2/letter/u/c0e974/{size}.png",
    "created_at": "2018-07-20T06:24:33.205Z",
    "cooked": "<p>Cool, now i have you, haha</p>",
    "post_number": 6,
    "post_type": 1,
    "updated_at": "2018-07-20T06:24:33.205Z",
    "reply_count": 0,
    "reply_to_post_number": null,
    "quote_count": 0,
    "avg_time": null,
    "incoming_link_count": 0,
    "reads": 0,
    "score": 0,
    "topic_id": 11,
    "topic_slug": "this-is-new-topic",
    "topic_title": "This is new topic",
    "display_username": "user",
    "primary_group_name": null,
    "version": 1,
    "user_title": null,
    "moderator": false,
    "admin": true,
    "staff": true,
    "user_id": 1,
    "hidden": false,
    "trust_level": 1,
    "deleted_at": null,
    "user_deleted": false,
    "edit_reason": null,
    "wiki": false,
    "topic_posts_count": 6
  }
}

(Vinoth Kannan) #31

The post payload will never include the email address. If you want then you can add it in a custom plugin code using add_to_serializer(:web_hook_post, ....) method.


(Andrey Tepaykin) #32

I created webhook for “User Event”.

  1. As I investigated, there are only 3 events:
    user_logged_in - when user logged in
    user_logged_out - when user ogged out
    user_created - when user created but not activated
    No user_activated event or any other.

  2. If I set content type application/json, I get empty $_REQUEST.
    If I set content type application/x-www-form-urlencoded, I get this $_REQUEST:
    Array(
    [{“user”:“id”:33,“username”:“andrey_gmail”,“avatar_template”:"/letter_avatar_proxy/v2/letter/a/ecb155/{size}_png",“name”:“Andrey_Tepaykin”,“email”:“andrey_tepaykin@gmail_com”,“last_posted_at”:null,“last_seen_at”:“2018-09-10T10:44:55_848Z”,“created_at”:“2018-09-10T10:43:56_243Z”,“stats”:] => Array(
    [{“action_type”:13,“count”:1}] =>
    )
    )

Seems bug in request formatter. Why I get so weird request data?


(Vinoth Kannan) #33

When a user logs in, logs out, is created, approved or updated.

user_activated - no such an event exist. user_approved will be triggered when you enabled must approve users site setting and a user is approved by staff.

Can you see anything related in your /logs?


(Andrey Tepaykin) #34

Oh, so it’s impossible to catch when user activate account using activation link?

Nothinh in [Error Logs] related this problem.


(Vinoth Kannan) #35

Yes, you can create feature request topic for that.

I didn’t received any other reports from users/customers who using application/json content type. Can you please check your end again.


(Tranquyet) #38

Thanks @vinothkannans,

Just wondering that, I can see the “New webhook” button on my dev site, but can’t see on live site. Seem they have same versions. Can you have a look ? Thanks

Dev site info:

Installed v2.1.0.beta2 +75

Latest 2.2.0.beta1

Live site info:

Installed v2.1.0.beta2 +125

Latest 2.2.0.beta1


(Vinoth Kannan) #39

They don’t have same version v2.1.0.beta2 +125 > v2.1.0.beta2 +75.


(Andrey Tepaykin) #40

Yes you right, it was problem with my backend. I got valid json with
file_get_contents("php://input")
Hope this will help somebody.