It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
rich Atlassian Team Jun 15, 2016

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 votes

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 Sign up to answer
Community showcase
Published in Hipchat

Hipchat Cloud and Stride have reached End of Life (updated)

All good things come to an end - thanks to all our customers and partners who have been along the Hipchat and Stride journey with us.  As of Feb 15th 2019, Hipchat Cloud and Stride have reached ...

35,211 views 9 8
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you