Jump to content

Giving Webhooks Some Attention


Luke

Recommended Posts

Here's what to look for in the next update to the Webhooks plugin (requires Emby Server 4.7.9+):

  • Easy button to view a sample webhook payload
  • Select individual events, making it easier to send different actions to different urls
  • New events added for new media and camera upload
  • User selection is now a multi-select
  • You can also filter on libraries

image.png

 

 

 

  • User selection is now a multi-select
  • You can also filter on libraries

image.png

  • Like 10
Link to comment
Share on other sites

OK this is included in the beta server 4.8.0.13+, so you'll need that in order to try it out. It may also get backported to a 4.7 stable release but that's undecided as of now.

Due to the extent of the changes, you should double check your webhooks settings and re-save them if necessary.

Even more event have been added beyond the ones in this screenshot, and that's because ultimately the work done here is going to serve as the basis for a revamp of the server notifications system.

  • Like 4
Link to comment
Share on other sites

  • 3 weeks later...

I've tested it today with server 4.7.9 

One question to `library.new`:

payload:

{"Title":"New Endlich.Witwe on Emby Server","Date":"2022-11-06T11:58:40.6056215Z","Event":"library.new","Item":{"Name":"Endlich.Witwe","ServerId":"09f1e39efddb4cb6a21e8925c3f108e6","Id":"764327","DateCreated":"2022-11-06T11:58:40.5935991Z","SortName":"Endlich.Witwe","ExternalUrls":[],"Path":"/mnt/mount/movie/Endlich Witwe/Endlich.Witwe.2007.German.EAC3.DL.1080p.BluRay.x265-HDSource.mkv","Taglines":[],"Genres":[],"FileName":"Endlich.Witwe.2007.German.EAC3.DL.1080p.BluRay.x265-HDSource.mkv","ProductionYear":2007,"RemoteTrailers":[],"ProviderIds":{},"IsFolder":false,"ParentId":"764326","Type":"Movie","Studios":[],"GenreItems":[],"TagItems":[],"ImageTags":{},"BackdropImageTags":[],"MediaType":"Video"},"Server":{"Name":"Emby","Id":"09*hidden*e6","Version":"4.7.9.0"}}

Why are some field empty? Would be greate to have the IMDB id or externals URLs in my case. The Media was correctly scrapped.

Link to comment
Share on other sites

4 hours ago, dual-o said:

I've tested it today with server 4.7.9 

One question to `library.new`:

payload:

{"Title":"New Endlich.Witwe on Emby Server","Date":"2022-11-06T11:58:40.6056215Z","Event":"library.new","Item":{"Name":"Endlich.Witwe","ServerId":"09f1e39efddb4cb6a21e8925c3f108e6","Id":"764327","DateCreated":"2022-11-06T11:58:40.5935991Z","SortName":"Endlich.Witwe","ExternalUrls":[],"Path":"/mnt/mount/movie/Endlich Witwe/Endlich.Witwe.2007.German.EAC3.DL.1080p.BluRay.x265-HDSource.mkv","Taglines":[],"Genres":[],"FileName":"Endlich.Witwe.2007.German.EAC3.DL.1080p.BluRay.x265-HDSource.mkv","ProductionYear":2007,"RemoteTrailers":[],"ProviderIds":{},"IsFolder":false,"ParentId":"764326","Type":"Movie","Studios":[],"GenreItems":[],"TagItems":[],"ImageTags":{},"BackdropImageTags":[],"MediaType":"Video"},"Server":{"Name":"Emby","Id":"09*hidden*e6","Version":"4.7.9.0"}}

Why are some field empty? Would be greate to have the IMDB id or externals URLs in my case. The Media was correctly scrapped.

That's the data the server had available at the time of sending the webhook. It might have been sent before metadata had finished downloading. In the upcoming 4.8 server it's delayed until afterwards so that will help make sure it has more information.

  • Like 1
Link to comment
Share on other sites

11 minutes ago, Luke said:

That's the data the server had available at the time of sending the webhook. It might have been sent before metadata had finished downloading. In the upcoming 4.8 server it's delayed until afterwards so that will help make sure it has more information.

Indeed in addition it seems to be missing the user. object as well, i think it due to the nature of the event being well.. not really user related. However, is it possible to include the user. object if the user is selected at the webhook edit page? i.e. "Limit user events to:" i cannot even select it if there is only one user there. 

Link to comment
Share on other sites

On 11/6/2022 at 8:22 PM, Luke said:

There is no user object for new library additions.

I see, is it going to support SeasonNumber and EpisodeNumber properties or the payload is final as it is?

Edit:

is it also possible to allow custom headers to be sent? would greatly help hiding the apikey for custom webhook endpoints.

Edited by m7eesn
Link to comment
Share on other sites

1 hour ago, Luke said:

That's the data the server had available at the time of sending the webhook. It might have been sent before metadata had finished downloading. In the upcoming 4.8 server it's delayed until afterwards so that will help make sure it has more information.

Thanks for the info. This will be great!

  • Thanks 1
Link to comment
Share on other sites

svyaznoy362

Hello. You can add a trigger. When a movie is added, webhooks are sent before matching, and it would be desirable to do this after and then I can get pictures. EMBY version 4.8.0.16

Edited by svyaznoy362
Link to comment
Share on other sites

  • 2 weeks later...

Hey @Luke, Any chance we could get this working with Discord WebHooks Intergration? Seem to get an error in testing it. When testing on the Webhooks plugin the error log mentions something about "can't send an empty message".

 

 

DiscordError.txt

Link to comment
Share on other sites

2 minutes ago, PaulW08 said:

Hey @Luke, Any chance we could get this working with Discord WebHooks Intergration? Seem to get an error in testing it. When testing on the Webhooks plugin the error log mentions something about "can't send an empty message".

 

 

DiscordError.txt 3.35 kB · 0 downloads

You'll have to get more info from the Discord side about what the problem is. Obviously we're not building just for Discord so we're not going to design around it, but if we need to add a toggle to change certain behaviors then we can do that.

Link to comment
Share on other sites

3 hours ago, Luke said:

You'll have to get more info from the Discord side about what the problem is. Obviously we're not building just for Discord so we're not going to design around it, but if we need to add a toggle to change certain behaviors then we can do that.

Hey @Luke, Thanks for the reply. Honestly I have no idea what I am doing but looking at the Emby logs it's getting a response of: 

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

When doing the test. Looking at the Sample Payload in the Webhook Plugin, it must have something to do with the formatting of the variables. An example of working code for a description is: 

{
  "embeds": [{
    "description": "*Hi!* **Wow!** I can __use__ hyperlinks [here](https://discord.com)."
  }]
}
 

An example of a working Title would be:

{
  "embeds": [{
    "title": "Meow!"
  }]
}
 

Maybe it's just the formatting and a space is needed after the colon for the field. I really don't know what I'm doing and just know just enough to be dangerous... I also know you are very busy, so if this isn't really worth the time we can drop it. It's such a niche use case.

 

Edited by PaulW08
Link to comment
Share on other sites

GrimReaper
7 hours ago, Luke said:

@GrimReaper do you have any tips?

Getting same error (50006) when sending payload directly to Discord, I'd assume it's something at their side as Test webhooks are being posted everywhere else without issue.

For Discord notifications, there's community made plugin (still working):

GitHub - oonqt/Emby.Notifications.Discord: Emby plugin for Discord notifications

And of course, Notifiarr for ultimate discord integration:

https://notifiarr.com/

 

Link to comment
Share on other sites

GrimReaper
15 hours ago, Luke said:

You'll have to get more info from the Discord side about what the problem is. Obviously we're not building just for Discord so we're not going to design around it, but if we need to add a toggle to change certain behaviors then we can do that.

Looks like at least one of the below params is required, "content" being the most likely culprit:

Quote

Note that when sending a message, you must provide a value for at least one of contentembedscomponents, or file.

JSON/Form Params

FIELD TYPE DESCRIPTION REQUIRED
content string the message contents (up to 2000 characters) one of content, file, embeds
username string override the default username of the webhook false
avatar_url string override the default avatar of the webhook false
tts boolean true if this is a TTS message false
embeds array of up to 10 embed objects embedded rich content one of content, file, embeds
allowed_mentions allowed mention object allowed mentions for the message false
components * array of message component the components to include with the message false
files[n] ** file contents the contents of the file being sent one of content, file, embeds
payload_json ** string JSON encoded body of non-file params multipart/form-data only
attachments ** array of partial attachment objects attachment objects with filename and description false
flags integer message flags combined as a bitfield (only SUPPRESS_EMBEDS can be set) false
thread_name string name of thread to create (requires the webhook channel to be a forum channel) false

 

 

Discord Developer Portal — Documentation — Webhook

Edited by GrimReaper
Link to comment
Share on other sites

3 hours ago, GrimReaper said:

Looks like at least one of the below params is required, "content" being the most likely culprit:

 

 

Discord Developer Portal — Documentation — Webhook

This is it.

 

Looking at how the community plugin works that seems to be how it is doing it as well.

 

Quote

    DiscordMessage discordMessage = new DiscordMessage()
            {
                avatar_url = options.AvatarUrl,
                username = options.Username,
               embeds = new List<DiscordEmbed>()
                {
                    new DiscordEmbed()
                    {
                        color = int.Parse(options.EmbedColor.Substring(1, 6), System.Globalization.NumberStyles.HexNumber),
                        description = "This is a test notification from Emby",
                        title = "It worked!",
                        footer = new Footer
                        {
                            icon_url = options.AvatarUrl,
                            text = footerText
                        },
                        timestamp = DateTime.Now
                    }
                }
            };

 

Link to comment
Share on other sites

Hello,

I've tested it with new version 4.7.10.0 because of the changelog:

  • Delay triggering new item additions under after metadata download. This should help improve the experience with Trakt, Webhooks, notifications, etc.

 

Still the same issue:

{"Title":"New Shantaram - Shantaram.S01E09.German.EAC3.Atmos.DL.1080p.WEB.x265-VECTOR on Emby Server","Date":"2022-11-25T15:51:33.1624041Z","Event":"library.new","Item":{"Name":"Shantaram.S01E09.German.EAC3.Atmos.DL.1080p.WEB.x265-VECTOR","ServerId":"09f1e39efddb4cb6a21e8925c3f108e6","Id":"798549","DateCreated":"2022-11-25T15:51:32.8494090Z","SortName":"Shantaram.S01E09.German.EAC3.Atmos.DL.1080p.WEB.x265-VECTOR","ExternalUrls":[],"Path":"/mnt/mount/tv/Shantaram/S01/Shantaram.S01E09.German.EAC3.Atmos.DL.1080p.WEB.x265-VECTOR.mkv","Taglines":[],"Genres":[],"FileName":"Shantaram.S01E09.German.EAC3.Atmos.DL.1080p.WEB.x265-VECTOR.mkv","RemoteTrailers":[],"ProviderIds":{},"IsFolder":false,"ParentId":"733114","Type":"Episode","Studios":[],"GenreItems":[],"TagItems":[],"ParentLogoItemId":"733099","ParentBackdropItemId":"733099","ParentBackdropImageTags":["4c8d8828f1c617e5d42b204fcba33788"],"SeriesName":"Shantaram","SeriesId":"733099","SeasonId":"733114","SeriesPrimaryImageTag":"94ee515c16f58af58ddf07092b2d00f9","SeasonName":"Staffel 1","ImageTags":{},"BackdropImageTags":[],"ParentLogoImageTag":"b2a1f64290ee7b7564ea2cdaea004e2c","MediaType":"Video"},"Server":{"Name":"OWS Emby","Id":"09f1e39efddb4cb6a21e8925c3f108e6","Version":"4.7.10.0"}}

 

Link to comment
Share on other sites

3 hours ago, dual-o said:

Hello,

I've tested it with new version 4.7.10.0 because of the changelog:

  • Delay triggering new item additions under after metadata download. This should help improve the experience with Trakt, Webhooks, notifications, etc.

 

Still the same issue:

{"Title":"New Shantaram - Shantaram.S01E09.German.EAC3.Atmos.DL.1080p.WEB.x265-VECTOR on Emby Server","Date":"2022-11-25T15:51:33.1624041Z","Event":"library.new","Item":{"Name":"Shantaram.S01E09.German.EAC3.Atmos.DL.1080p.WEB.x265-VECTOR","ServerId":"09f1e39efddb4cb6a21e8925c3f108e6","Id":"798549","DateCreated":"2022-11-25T15:51:32.8494090Z","SortName":"Shantaram.S01E09.German.EAC3.Atmos.DL.1080p.WEB.x265-VECTOR","ExternalUrls":[],"Path":"/mnt/mount/tv/Shantaram/S01/Shantaram.S01E09.German.EAC3.Atmos.DL.1080p.WEB.x265-VECTOR.mkv","Taglines":[],"Genres":[],"FileName":"Shantaram.S01E09.German.EAC3.Atmos.DL.1080p.WEB.x265-VECTOR.mkv","RemoteTrailers":[],"ProviderIds":{},"IsFolder":false,"ParentId":"733114","Type":"Episode","Studios":[],"GenreItems":[],"TagItems":[],"ParentLogoItemId":"733099","ParentBackdropItemId":"733099","ParentBackdropImageTags":["4c8d8828f1c617e5d42b204fcba33788"],"SeriesName":"Shantaram","SeriesId":"733099","SeasonId":"733114","SeriesPrimaryImageTag":"94ee515c16f58af58ddf07092b2d00f9","SeasonName":"Staffel 1","ImageTags":{},"BackdropImageTags":[],"ParentLogoImageTag":"b2a1f64290ee7b7564ea2cdaea004e2c","MediaType":"Video"},"Server":{"Name":"OWS Emby","Id":"09f1e39efddb4cb6a21e8925c3f108e6","Version":"4.7.10.0"}}

 

Hi, server log?

Link to comment
Share on other sites

On 11/26/2022 at 5:49 AM, dual-o said:

yes of course
https://pastebin.com/mra4vZrr

the log is a bit difficult to read because I also use ScripterX for webhooks, wich works as expected by the way.

I don't see any mention of Shantaram in this log file. Are you sure this is the right one?

Link to comment
Share on other sites

  • 3 weeks later...
Khalimerot
On 17/11/2022 at 22:20, Luke said:

You'll have to get more info from the Discord side about what the problem is. Obviously we're not building just for Discord so we're not going to design around it, but if we need to add a toggle to change certain behaviors then we can do that.

Don't know if it help or not, but it's the answer i got from discord support

 

John T (Discord)

Dec 14, 2022, 08:00 PST

Hey there Khalimerot

Thanks for reaching out! Oh no, I’m really sorry to hear your webhook isn’t working as expected!

As a first step here, if your webhook isn’t posting messages, and the connection logs are delivering a 50006 error, this is typically caused by developers using the wrong content-type header for their webhook.

If you’re the developer of the webhook in question, make sure to change your content-type header to application/json! If you’re just using this webhook and didn't develop it yourself, reach out to the webhook’s developer and ask them to make this change.

If swapping the content-type header doesn’t do the trick, either have the developer contact us for help or share any connection logs you might have so we can isolate this error for you!

Best,
John Daniel
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...