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

[feature] Add an option to send embed messages to Discord webhooks #907

Open
XXCoreRangerX opened this issue Sep 5, 2022 · 14 comments
Open
Labels
enhancement New feature or request Notifications systems Development of notifications of changes

Comments

@XXCoreRangerX
Copy link

Version and OS
0.39.18 on linux/docker

Is your feature request related to a problem? Please describe.
My monitored URL's {diff} often exceeds the 1700 characters limit. Using embeds could increase the limit up to 4096 characters by using the description field for diffs.

Describe the solution you'd like
Add an embed message type for Discord notifications with a customizable structure consisting of embedded fields. I'm pretty sure Apprise, the dependency used for notifications, already has support for embeds, so adding it here shouldn't be much of an issue.

Describe the use-case and give concrete real-world examples
The limit of diffs would be increased from 1700 to 4096 characters. Additionally, embedded Discord notifications would simply look better than pure text.

@XXCoreRangerX XXCoreRangerX added the enhancement New feature or request label Sep 5, 2022
@dgtlmoon
Copy link
Owner

dgtlmoon commented Sep 8, 2022

Thanks for that info!

Also looking interesting is the 'attachment object' too

@Repooc
Copy link

Repooc commented Nov 2, 2022

please please, i would love it if you were to add this functionality as that is prob the only thing keeping me from using this as I would like.

@dgtlmoon dgtlmoon added the Notifications systems Development of notifications of changes label Nov 14, 2022
@dhanadhan
Copy link

I would love to have the embed option as well. Currently, the web url is embedded when sent through Discord webhook and it looks pretty ugly lol. There is no way to post a plain web link though webhook. If the Embed Message feature described in this post is added, it would solve this issue as well.

Thanks

@jpdsc
Copy link

jpdsc commented Apr 26, 2023

You can use the apprise embeded option by adding ?format=markdown. Example:
discord://webhook_id/webhook_token?format=markdown

Doing, apprise will embed the message.
image

You can also add additional parameters: https://github.com/caronc/apprise/wiki/Notify_discord#parameter-breakdown

I checked footer, avatar_url and these are working.
However, the footer cannot be changed and shows changedetection.io information.

@dhanadhan
Copy link

You can use the apprise embeded option by adding ?format=markdown. Example: discord://webhook_id/webhook_token?format=markdown

Doing, apprise will embed the message. image

You can also add additional parameters: https://github.com/caronc/apprise/wiki/Notify_discord#parameter-breakdown

I checked footer, avatar_url and these are working. However, the footer cannot be changed and shows changedetection.io information.

Awesome, that worked. Thank you.

Do you know how to get rid of that "changedetection.io" link on every embed?

@jpdsc
Copy link

jpdsc commented Apr 27, 2023

That is the author field, not sure how apprise embeds this one as there is no reference to it in the apprise documentation.

Same for footer text and footer image.

@naviem
Copy link

naviem commented Oct 3, 2023

Anyone ever figure out how to remove the author field? I don't like it showing it. Trying to keep the notification simple and clean as possible

@dhanadhan
Copy link

dhanadhan commented Oct 4, 2023

Anyone ever figure out how to remove the author field? I don't like it showing it. Trying to keep the notification simple and clean as possible

Nope, still can't figure out a way to remove author. It does look annoying so I don't use embed anymore. I wish dev can add it eventually 🤞

@BlackWolfWoof
Copy link

BlackWolfWoof commented Aug 3, 2024

@XXCoreRangerX Hehe hello, 2 years later you have your answer :)
It is still not natively supported BUUUT...
posts://discord.com/api/webhooks/IDHERE/TOKENHERE?+Content-Type=application/json

{% set title = watch_title if watch_title else "N/A" %}
{% set title = title | replace("\n", "") %}
{% set restock_info = restock if restock else {} %}

{% set description = "" %}
{% if restock_info %}
{% set description = "**In Stock:** " ~ restock.in_stock ~ "\\n" %}
{% set description = description ~ "**Price:** " ~ restock_info.price ~ " " ~ restock_info.currency ~ "\\n" %}
{% set description = description ~ "**Original Price:** " ~ restock_info.original_price ~ " " ~ restock_info.currency ~ "\\n" %}
{% endif %}
{% set diffContent = diff | replace("\n", "\\n") %}

{
    "username": "Changedetection.io",
    "avatar_url": "https://cdn.discordapp.com/avatars/1269225949942124594/7cd30e60dd046655c0f02071c70122d2.webp",
    "embeds": [
        {
            "title": "{{ title }}",
            "url": "{{ watch_url }}",
            "color": 4372701,
            "description": "{% if description %}{{ description }}{% else %}{% endif %}**Difference:** [Link]({{diff_url}})\n{{diffContent}}"
        }
    ]
}

as example.
Note: use a service like https://webhook.site/ to see what info gets sent and make sure newlines are escaped and you don't forget a , in the json like i did which added an additional 3h of troubleshooting 💀💀
1920-1078-max

@dhanadhan
Copy link

@BlackWolfWoof Thank you sir! That worked great 👍

@dreww
Copy link

dreww commented Oct 2, 2024

@BlackWolfWoof thanks!! was wondering if you have any advice - I can't get the webhook to show up successfully straight from changedetector.io (hosted), but if I copy and paste the json out of webhook.site and send it via postman, it works just fine. is there any way to easily tell why a discord webhook attempt is failing?

@dhanadhan
Copy link

@BlackWolfWoof thanks!! was wondering if you have any advice - I can't get the webhook to show up successfully straight from changedetector.io (hosted), but if I copy and paste the json out of webhook.site and send it via postman, it works just fine. is there any way to easily tell why a discord webhook attempt is failing?

There is no easy way to tell why it's failing. I removed some stuff from the JSON code and made sure I am using the mentioned post discord webhook with text output format.

{ "username": "Change", "avatar_url": "https://cdn.discordapp.com/avatars/1269225949942124594/7cd30e60dd046655c0f02071c70122d2.webp", "embeds": [ { "title": "**{{watch_title}}**", "url": "{{watch_url}}", "color": 2895667, "description": "{{current_snapshot}}" } ] }

@dreww
Copy link

dreww commented Oct 2, 2024

i had a typo in the url... carry on. 😭

@Reginald-Gillespie
Copy link

Reginald-Gillespie commented Oct 17, 2024

A file upload as I suggested here #2723 would be simpler than embeds, allow direct formatting, and increase the limit to theoretically >10 million chars (upload max is 10MB, right?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Notifications systems Development of notifications of changes
Projects
None yet
Development

No branches or pull requests

9 participants