Passing request parameters from HipChat action to sidebar

I'm developing an add-on that uses a message action. The action opens a sidebar view.

How can I send the ID of the message as a request parameter to the sidebar view?

I need to know which message the user clicked, so that I can fill the sidebar with data related to this message.


2 answers

2 votes

Here's how it works. First, you register your message action in your descriptor:

    "action": [
          "key": "my.message.action",
          "name": {
            "value": "Send this to the sidebar"
          "target": "my.sidebar",
          "location": "hipchat.message.action"

Take note of the action's key (my.message.action). That's the event you need to subscribe to in your JS:

  "my.message.action": function(message) {

That's it!

Now, when you click on the "Send this to the sidebar" action on a message, you should get something like this in your console:

  "body": "This is a test",
  "sender": {
    "id": 51380,
    "name": "Rich Manalang",
    "mention": "rich"
  "mid": "a4444933-56ca-4fb8-8f1c-319635835617",
  "type": "message",
  "metadata": {}


0 vote

Pages loaded in HipChat dialogs or the sidebar can facilitate the Javascript API - in particular, you might want to look into Working with Sidebar Views, which illustrates how to pass parameters to the sidebar view and and receive them fin the sidebar iframe in turn.

Hi Steffen, thank you for your answer. I have already read this part of the documentation, but can't get it to work. I'm calling AP.register from the sidebar during $(document).ready(), using the action key in the parameters. But the callback function is not triggered.

Where and when does AP.register need to be called?

Secondly is it possible to call a JavaScript function when a message action gets clicked? This way I could use HipChat.sidebar.openView and pass the required request parameters.

Please provide examples if you can, because the documentation lacks some important details to get things working.

@Rob Laveaux - it's been a while since I last worked with those APIs myself in a PoC, so I'm unable to provide more detailed guidance myself right now. That being said, if you are looking for specific examples, I recommend checking out the well maintained HipChat Connect Tester sources, which should at least provide more insight/guidance on how those APIs are supposed to be used, or by chance even provide the exact code you are looking for - good luck!

Thank you, I found my mistake. I was calling AP.register multiple times to register different handlers. This overwrites the handlers on each call.

Instead I need to call AP.register once with an array of handlers. Like this:

      "": showMessage,
      "receive-parameters": showMessage

In addition to Rob's comments, It looks like HipChat.register and Ap.register overwrite each other so second call may unregister first even listeners.

Suggest an answer

Log in or Join to answer
Community showcase
Maarten Cautreels
Published Oct 07, 2017 in Hipchat

Bringing Structure to your HipChat Instance

...have mention name FirstnameLastname. Fe.: @MaartenCautreels This certainly helps to know who is being mentioned in a conversation. Imagine your colleague sends the following message...

464 views 1 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot