Admin notifications to Discord

Hey all!

I’ve been setting up a Discourse instance and I’m trying to configure direct webhooks to a Discord server. But I’m not having any luck getting anything pushed in Discord. I have some experience with webhooks in other software, and it was pretty straightforward - but with Discourse it doesn’t seem so.

The ping tests always return 400 bad requests - see info:

Headers:

ate: Wed, 01 Nov 2023 11:57:42 GMT
content-type: application/json
content-length: 58
connection: close
set-cookie: __dcfduid=dcf0233a78ad11eebb88d697d01a97e7; Expires=Mon, 30-Oct-2028 11:57:42 GMT; Max-Age=157680000; Secure; HttpOnly; Path=/, __sdcfduid=dcf0233a78ad11eebb88d697d01a97e78400f2bac802b92ae5cd11d0fb83f18916f0fdca5d48d309bd75aaaaba4d1431; Expires=Mon, 30-Oct-2028 11:57:42 GMT; Max-Age=157680000; Secure; HttpOnly; Path=/, __cf_bm=ACfLMGcKwXZiIw0euAAqKlZ1iroL0N.lG_2clanSP5M-1698839862-0-AUp8RGopNouFfnPVX/qbsLKr+5d1F9HQJ7zS9cGBeg6YH0urIlNg62SSP2cSSZFeZB9mC4TFRf323pdEHk5bTyY=; path=/; expires=Wed, 01-Nov-23 12:27:42 GMT; domain=.discordapp.com; HttpOnly; Secure; SameSite=None, __cfruid=7777c6c50b4e0b129fbc66ba8f4f6ab654a756c5-1698839862; path=/; domain=.discordapp.com; HttpOnly; Secure; SameSite=None, _cfuvid=mgEBXzSq5xWc_05ETnRJURj3e3yjIaRGrJQ0DeJyYA0-1698839862706-0-604800000; path=/; domain=.discordapp.com; HttpOnly; Secure; SameSite=None
strict-transport-security: max-age=31536000; includeSubDomains
x-ratelimit-bucket: 3d2712a9e4fe17cc9d3fed4a8e672e5f
x-ratelimit-limit: 5
x-ratelimit-remaining: 3
x-ratelimit-reset: 1698839864
x-ratelimit-reset-after: 1
via: 1.1 google
alt-svc: h3=":443"; ma=86400
cf-cache-status: DYNAMIC
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=WbIOWcprUjt2ga6UbHxwUh34HscqFqtWix5A9U%2FBKHOhRSCnydePJMngumK%2BgyupooTEjMuLVC%2FLhieBLLbD%2BQhTDdfNb4v%2BH2kO7ah8BdYbNNAU27fFaeErzlQYifFG"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 81f3f634dcf470fa-HEL

And return content:

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

Does anyone know what to check? Do we need the chat plugin to make it work (which we tried to no avail)? It seems like we’re missing something obvious. Also, I tried enabling everything in the webhook, and even with a payload that is not empty - I still get that same return content.

{
  "category": {
    "id": 2,
    "name": "Feedback",
    "color": "0E76BD",
    "text_color": "FFFFFF",
    "slug": "feedback",
    "topic_count": 1,
    "post_count": 0,
    "position": 1,
    "description": "Feedback over ons forum <strong>forum.dtvwp.nl</strong>, onze website <strong>dtvwp.nl</strong> of over <strong>onze Facebook groepen</strong> mag hier geplaatst worden. We houden van constructieve feedback, dus feedback en suggesties zijn altijd welkom en erg gewaardeerd!",
    "description_text": "Feedback over ons forum forum.dtvwp.nl, onze website dtvwp.nl of over onze Facebook groepen mag hier geplaatst worden. We houden van constructieve feedback, dus feedback en suggesties zijn altijd welkom en erg gewaardeerd!",
    "description_excerpt": "Feedback over ons forum forum.dtvwp.nl, onze website dtvwp.nl of over onze Facebook groepen mag hier geplaatst worden. We houden van constructieve feedback, dus feedback en suggesties zijn altijd welkom en erg gewaardeerd!",
    "topic_url": "/t/over-het-forum-feedback/1",
    "read_restricted": false,
    "permission": null,
    "topic_template": null,
    "has_children": null,
    "sort_order": null,
    "sort_ascending": null,
    "show_subcategory_list": false,
    "num_featured_topics": 3,
    "default_view": null,
    "subcategory_list_style": "rows_with_featured_topics",
    "default_top_period": "all",
    "default_list_filter": "all",
    "minimum_required_tags": 0,
    "navigate_to_first_post_after_read": false,
    "custom_fields": {},
    "allowed_tags": [],
    "allowed_tag_groups": [],
    "allow_global_tags": false,
    "read_only_banner": null,
    "form_template_ids": [],
    "auto_close_hours": null,
    "auto_close_based_on_last_post": false,
    "group_permissions": [
      {
        "permission_type": 1,
        "group_name": "iedereen"
      }
    ],
    "email_in": null,
    "email_in_allow_strangers": false,
    "mailinglist_mirror": false,
    "all_topics_wiki": false,
    "allow_unlimited_owner_edits_on_first_post": false,
    "cannot_delete_reason": "Deze categorie kan niet worden verwijderd, omdat het aantal topics 1 is.",
    "is_special": true,
    "allow_badges": true,
    "topic_featured_link_allowed": true,
    "search_priority": 0,
    "default_slow_mode_seconds": null,
    "uploaded_logo": null,
    "uploaded_logo_dark": null,
    "uploaded_background": null,
    "required_tag_groups": [],
    "category_setting": {
      "auto_bump_cooldown_days": 1,
      "num_auto_bump_daily": 0,
      "require_reply_approval": false,
      "require_topic_approval": false
    }
  }
}

For now, the only hook / notification we would like to see is when a new user confirmed his email and is up for confirmation by mods/admins - we get a ping in our discord channel.

1 Like

This has come up before. I think the issue is that the data that’s posted in a Discourse webhook isn’t in the form that Discord is looking for. There are details about the issue in the first two replies to this topic: Has any one tried webhooks with Discord?.

You could point the webhook at Zapier, then use Zapier to parse the webhook into the form that Discord is looking for. That would cost at least $20/month though.

I don’t think it will help for your current case, but a good way to post from Discourse to Discord is outlined here: Set up Discord notifications with the discourse-chat-integration plugin.

1 Like