Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discord Webhook Messages #591

Open
Skyfay opened this issue Apr 18, 2023 · 9 comments
Open

Discord Webhook Messages #591

Skyfay opened this issue Apr 18, 2023 · 9 comments

Comments

@Skyfay
Copy link

Skyfay commented Apr 18, 2023

Summary

I am trying to send a report to Discord via Webhoock after a job. However, it does not work. Is that even possible?

Steps to reproduce the problem

I created a Webhook link in Discord and then entered it in the software under "Web Hook" under "E-mail".
image

@mikeTWC1984
Copy link

That's because discord expects message text under "content" property, while cronicle uses "text" property (would work with slack and many other messengers). e.g.

curl  -H "Content-Type: application/json"  -d '{"content": "hello"}'   $WEBHOOK_URL

I don't think you can configure that, although you may do a little tweak in lib/job.js file
locate this line:

hook_data.text = Tools.sub( hook_text_templates[hook_action], hook_data );

then on the next line add something like hook_data.content = hook_data.text

@Skyfay
Copy link
Author

Skyfay commented Apr 19, 2023

Thank you, that works for now. I'll see if I can make it a bit more beautiful with embeds, but that's already great. Is there a reason why webhooks don't have two, one for success and one for failure?

@jhuckaby
Copy link
Owner

Thank you for that, @mikeTWC1984. If I add that line into the base code, would it break Slack or others? Hmmm... maybe it should be a configurable property name instead.

In Cronicle v2, the web hooks are much more configurable, including assigning them as actions to job complete, job failure, other error codes, etc.

@jhuckaby
Copy link
Owner

Adding content as a copy of text seems to work on both Discord and Slack, in my testing. I'll go ahead and commit that right now.

@jhuckaby
Copy link
Owner

Released v0.9.21 with a fix for this. Thanks again, @mikeTWC1984!

@Skyfay
Copy link
Author

Skyfay commented Apr 20, 2023

Hey @jhuckaby

  1. How is it now possible, for example, to send only failed jobs via Webhook?
  2. I would like to change the webhook for Discord. Embed it so it looks better visually and add information like the email notifications. I don't know how to do that though.

@jhuckaby
Copy link
Owner

@Skyfay See Wiki here: https://github.com/jhuckaby/Cronicle/wiki/Discord-Webhook-Integration

I believe it answers both of your questions.

@Skyfay
Copy link
Author

Skyfay commented Apr 21, 2023

@jhuckaby Thanks.
So, embeds work like this:

{
  "embeds": [{
    "title": "Hello!",
    "description": "Hi! :grinning:"
  }]
}

How could I now integrate this into the config, can you give me an example?
And is it possible to configure that the different templates (start, complet, failure) can be sent (Global) to different webhook URL's?

@jhuckaby
Copy link
Owner

I'm sorry, there's no way to do that with Cronicle. You can only customize the text for the notification.

Apologies, but there's also no way to customize the webhook URLs per outcome. However, this feature will be coming in Cronicle v2 (will release sometime in 2023).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants