Discord WEb Hook

Infos:

  • Used Zammad version: 6.3.1
  • Used Zammad installation type: Zammad Hosted
  • Operating system: Windows 11
  • Browser + version: Chrome (latest)

Expected behavior:

*I created a channel in Discord and created a webook link. I then created the webhook record in Zammad and copied the Discord webhook link. I assigned that webhook to a trigger that goes off when a ticket is new or updated. I see the post record when look at the webhook but nothing happens on the Discord side. I’m new to webhooks so I’m probably missing something but from what I could gather it should be that simple?

Actual behavior:

  • no post in Discord channel

Steps to reproduce the behavior:

  • tried making changes to several tickets and created new ones.

Hi!

I have not tested discord webhooks with Zammad yet, but I remember that Discord has some special requirements, like e.g. the Github webhook requires you to add /github to your webhook link according to the documentation

https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks

After that you have to format the webhook correctly. I do not see an option in Zammad to set the Content type of the webhook e.g. to application/json

As I can see in this thread a custom middleware might be a solution to get the webhook payload from Zammad and then forward it to the Discord channel

Sourcecode here:

Let me know if this brings you on the right path.

Best,
Skip

For simple notifications the build in Zammad webhooks are enough to set up notifications for Discord.

Discord has Slack compatible webhooks:

Simply use that combined with the predefined Slack webhook from Zammad and you should be good to go. I’ve been successfully using this.

1 Like

I think I might have found the issue. I found this error today. Not sure how to fix it yet though:

Failed to run background job #1 ‘TriggerWebhookJob’ 1 time(s) with 3 attempt(s)

Your production log file will tell you what’s wrong.

Thanks for the comment. This was the error I found but I am still unsure what it means. Networking issue or syntax issue? This is from a docker environment not the Zammad cloud like I stated above.

E, [2024-08-23T01:56:39.950874#1-149160] ERROR – : 2024-08-23T01:56:39+0200: [Worker(host:b20fb4da172d pid:1)] Job TriggerWebhookJob [da2768bd-1754-45c3-a850-590d7908c6b7] from DelayedJob(default) with arguments: [{“_aj_globalid”=>“gid://zammad/Trigger/4”}, {“_aj_globalid”=>“gid://zammad/Ticket/23”}, {“_aj_globalid”=>“gid://zammad/Ticket::Article/106”}, {“changes”=>{“_aj_symbol_keys”=>}, “user_id”=>3, “execution_type”=>“trigger”, “event_type”=>“create”, “_aj_ruby2_keywords”=>[“changes”, “user_id”, “execution_type”, “event_type”]}] (id=2997) (queue=default) FAILED (4 prior attempts) with TriggerWebhookJob::RequestError: TriggerWebhookJob::RequestError
E, [2024-08-23T01:56:39.951031#1-149160] ERROR – : 2024-08-23T01:56:39+0200: [Worker(host:b20fb4da172d pid:1)] Job TriggerWebhookJob [da2768bd-1754-45c3-a850-590d7908c6b7] from DelayedJob(default) with arguments: [{“_aj_globalid”=>“gid://zammad/Trigger/4”}, {“_aj_globalid”=>“gid://zammad/Ticket/23”}, {“_aj_globalid”=>“gid://zammad/Ticket::Article/106”}, {“changes”=>{“_aj_symbol_keys”=>}, “user_id”=>3, “execution_type”=>“trigger”, “event_type”=>“create”, “_aj_ruby2_keywords”=>[“changes”, “user_id”, “execution_type”, “event_type”]}] (id=2997) (queue=default) FAILED permanently because of 5 consecutive failures

I did test from the scheduler console using Curl and sent a payload to the discord channel and it worked fine so it isn’t a network issue. Maybe something with the payload Zammad creates?

Here is an example request that was created by Zammad:

accept-encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\naccept: /\nuser-agent: Zammad User Agent\nhost: discordapp.com\nx-zammad-trigger: auto reply (on new tickets)\nx-zammad-delivery: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\ncontent-type: application/json; charset=utf-8\n\n{"content":"A new support ticket has been created!"}"