RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
40.06k stars 10.34k forks source link

Integration with Incoming Webhooks from Slack for Confluence #12072

Open aldaverwalda opened 6 years ago

aldaverwalda commented 6 years ago

Hi!

We're using Confluence Server and RocketChat and would like to notify RC channels about changes in Confluence. Since Confluence Server doesn't support webhooks, we use a plugin called Slack for Confluence (https://marketplace.atlassian.com/apps/1215055/slack-for-confluence?hosting=cloud&tab=overview). We've managed to make the webhooks work basically, but they're displayed empty in RocketChat, although they work in Slack and Mattermost (We've checked with the exact same hooks). The logs in RocketChat show no errors, but the message doesn't appear to be parsed correctly. Comparing it with Messages created by Microsoft TFS Webhooks, it appears that Slack for Confluence does not limit itself to sending the "attachments", but also sets attributes like the channel which are direct message attributes and not attachments.

Is there something we can do here or do we need an extra Rocket Chat feature? I don't know if a script could do the job, but so far I've failed to understand how exactly this could be accomplished.

I've attached a log file: sample_log.txt

aldaverwalda commented 6 years ago

Strangely, I managed to make it work parsing the request body and not the request content via an import script:

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

class Script {
  /**
   * @params {object} request
   */
  process_incoming_request({ request }) {

    var content = JSON.parse(request.body.payload);

    return {
      content: {
        username: "confluence",
        text: content.attachments[0].title,
        attachments: content.attachments,
        channel: content.channel
      }
}
  }
}

When I try to parse the content, it gives me an error. I'm not enough of an expert to understand why ...

Routhgen commented 4 years ago

Strangely, I managed to make it work parsing the request body and not the request content via an import script:

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

class Script {
  /**
   * @params {object} request
   */
  process_incoming_request({ request }) {

    var content = JSON.parse(request.body.payload);

    return {
      content: {
        username: "confluence",
        text: content.attachments[0].title,
        attachments: content.attachments,
        channel: content.channel
      }
}
  }
}

When I try to parse the content, it gives me an error. I'm not enough of an expert to understand why ...

And use request.content

class Script {
  process_incoming_request({ request }) {
    return {
      content:{
        username: "confluence",
        text: request.content.attachments[0].title,
        attachments: request.content.attachments,
        channel: request.content.channel
      }
    }
  }
}

Dont parse anything. Its already parsed!

mostafa8026 commented 3 years ago

Could you provider a more detailed instruction on how to integrate (slack for confluence) with rocket.chat?

charisteed28 commented 2 years ago

Anybody can share example script for webhook, please?