Supporting Rocket.Chat - ackbarr/Emby.Plugins GitHub Wiki

Background

Rocket.Chat is an open source chat platform similar to Slack. It uses a webhook system similar to Slack and the Emby.Notification.Slack plugin can work with Rocket.Chat using a Rocket.Chat incoming webhook script.

Webhook Scripts are written in ECMASCript 6 and are designed to accept XML or JSON payloads and transform them into a native rocket.chat message object. Since the Slack and Rocket.Chat message formats are so similar, a script to accept an Emby notification designed for Slack and converting it into a Rocket.Chat message is very simple. If you use the sample script below, the only Emby plugin setting that has any impact is the Slack Incoming Webhook URI value, which should be configured to the rocket.chat generated Webhook value.

Emby Plugin Settings

  • Slack Incoming Webhook URI - use the rocket.chat webhook value
  • Message Channel - ignored The rocket.chat webhook controls the destination channel
  • Emoji - ignored The script below uses the author icon defined in the rocket.chat webhook.
  • Slack Username - ignored The sample script below uses the author name defined in the rocket.chat webhook

Webhook Script

/* exported Script */
/* globals console, _, s */

/** Global Helpers
*
* console - A normal console instance
* _       - An underscore instance
* s       - An underscore string instance
*/

class Script {
/**
* @params {object} request
*/
    process_incoming_request({ request }) {
        // request.url.hash
        // request.url.search
        // request.url.query
        // request.url.pathname
        // request.url.path
        // request.url_raw
        // request.url_params
        // request.headers
        // request.user._id
        // request.user.name
        // request.user.username
        // request.content_raw
        // request.content
    
        // console is a global helper to improve debug
        console.log(request.content);
    
        return {
            content:{
                text: request.content.text
            }
        };
    
    
    }
}