Webhooks - Feedback request

Not a new feature, as I’ve already implemented it, but I was posting here to see if there was any feedback and if the documentation needed updating at all.

If you don’t know the term webhook. Its essentially a system for an application (Sonarr) to post to a webservice with data. I personally use it for a slackbot to notify me when new content is published.

Works great for me. But I only use it to call one static page, without any parameters or such, so I can’t say anything about that.

I was just wondering about integrating Sonarr and Slack since I just set up a Slack team for my family and thought that it would be cool to push notifications about new episodes to a Slack channel. I’ve not looked into the Slack API yet - I was looking around to see if someone had already done it. Would you be willing to share how you configured your webhook?

Thats actually what I was thinking when I added the first implementation of webhooks. Sadly webooks isn’t great at conforming to other peoples APIs. Plus I wanted more features.

So I went with a hubot connecting to slack. Unfinished Hubot Module

It really wouldn’t be all that hard to add a new integration for slack to sonarr, there might already be an issue tracker for it.

I’m trying to get webhooks / Slack integration going using this and I’m running into 500 errors when I set it up appropriately. Would LOVE to get this working, so any tips are appreciated! Thanks!

this being hubot?

My url is:
http://localhost:8052/hubot/sonarr/general
Method is:
Post

If you just mean slack + webhooks integration, its not really setup for that. Slack requires specific data posted.

I’d prefer direct Sonarr to Slack integration, but I wouldn’t mind using Hubot as a translator either if it was a way to get it working. I’ll throw Hubot up in a docker later and see if I can’t get that working (I have no prior Hubot experience).

You can file a idea/feature request for that, it shouldn’t be that hard. The webhooks feature isn’t designed for that though.

https://trello.com/b/MadvFKy4/sonarr (not 100% certain thats the trello link)

@ryankoski I am working on a tiny Python script to receive the Sonarr WebHook and send to Slack

@halkeye I am getting an error (copied below) in Sonarr, despite the fact that the Python server receives the JSON data and sends back a 200 OK response. Here is the code I am running: http://pastebin.com/DQdLFiq0

Any ideas?

Error communicating with server: Error getting response stream (ReadDone2): ReceiveFailure

System.Net.WebException: Error getting response stream (ReadDone2): ReceiveFailure ---> System.Exception:
    at System.Net.WebConnection.HandleError(WebExceptionStatus st, System.Exception e, System.String where)
    at System.Net.WebConnection.ReadDone(IAsyncResult result)
    at System.Net.WebConnection.HandleError (WebExceptionStatus st, System.Exception e, System.String where) [0x00000] in <filename unknown>:0 
    --- End of inner exception stack trace ---
    at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
    at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0 
    at RestSharp.Http.GetRawResponse (System.Net.HttpWebRequest request) [0x00000] in <filename unknown>:0

@jzplusplus I don’t really know any python, but looking at the docs, maybe provide a body as well? self.send_response(200, “OK”)

You were partially right, the response did need to include a body. Found the solution here: http://stackoverflow.com/a/31747798

Thanks for the suggestion! I will post back here when I get the script completed in case others want to use it.

@ryankoski my finished script is available here: https://github.com/jzplusplus/sonarr-to-slackbot

Let me know if there are any issues.

@halkeye thanks for the Webhook support! Seems to work perfectly, after I figured out the previous problem.

@halkeye Thanks for adding this, great feature!

Would it be possible to add the filename to the returned data like the custom script?
I think the filename is the one important piece of data missing as it makes it a lot harder to do something with the notification without knowing where the file is. I know scene name is present, but its not really helpful if Sonarr renames your files.

Is there any way to have this functionality running from a mac server that I use to run sonarr?

Here’s my solution for forwarding Sonarr webhooks to Slack:

Um, I havn’t done any sonarr development in a while, when I get a chance I can take a look, but it won’t be any time soon.

Hello,

I am using webhooks to connect to Azure, Azure’s webhooks seem to return a 202 (Accepted but not yet processed) instead of a 200 (OK).

When I tried to configured it via the Sonarr config page, it won’t let me save it despite the webhook working, because it didn’t return a 200. Is there any chance that Sonarr can be updated to also accept 202 as a valid return code for webhooks?

Thanks!

Hi!

I created a sort of relay-url to make webhooks working for Slack, without the use of any other scripts or programming on your own. I wanted to share it with you guys here, but if someone wants to integrate it in Sonarr itself, maybe it’s better to host this relay elsewhere (on the Sonarr site for example).

Steps:

  • Create an incoming webhook integration in Slack, and attach it to a channel or your choice (I’m using slackbot myself)
  • Give it a nice icon, and copy the Webhook URL.
  • Now, go to Sonarr -> Settings -> Connect and Add a Webhook connection.
  • Choose which notifications you’d like (I only tested grab, download and update so far) and use the following url:
    https://projectfive.nl/inc/slackpush.php?slack=[YOUR-ENTIRE-SLACK-WEBHOOK-URL]&type=sonarr

That’s it!

– edit, updated tested notification types

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.