Hipchat's html capabilities for XMPP bot

Hello guys,

I writing a bot and need to send a couple of html formatted messages, but what is possible seems to be pretty basic.

First of all, Is this documented somewhere?

And then,

- Is it possible to render an html table with borders? I've been trying inline styles with no luck

- What about consistency among devices? I've managed to render a <table> in hipchat desktop, but on iOS it is totally ignored.

- And regarding how hipchat manages xmpp stanzas: 

<message to='some-id' type='chat'>
  <body>dummy</body>
  <html xmlns='http://jabber.org/protocol/xhtml-im'>
    <body xmlns='http://www.w3.org/1999/xhtml'>
      <b> this is the message text</b>
    </body>
 </html>
</message>

If I don't add the `<body>dummy</body>` tag there, the html message won't get displayed. Is this on purpose or it is a bug?

 

thanks in advance!

 

1 answer

1 accepted

This widget could not be displayed.

Support for the XHTML-IM XEP is pretty basic and isn't something we document specifically, since we only use it behind the scenes (and like you've noticed, it's not necessarily fleshed out on all platforms, like mobile).

I believe including the <body> element is a requirement on the server side (certainly most of the examples in the spec have it). As far as tag support, your best best is to check out https://developer.atlassian.com/hipchat/guide/sending-messages (see the table at the bottom for a list of HTML tags and attributes). Chances are the XHTML-IM support through XMPP will be similar to that list.

What other requirements are there and can you tell me what I am missing? I composed the message below but hipchat always just shows the plain-text body.

<message to='12345_bot_test@conf.hipchat.com' type='groupchat' xmlns='jabber:client'>
<body>test</body>
<x xmlns='http://hipchat.com/protocol/muc#room'>
<type>system</type>
<notify>0</notify>
<message_format>html</message_format>
</x>
<html xmlns='http://jabber.org/protocol/xhtml-im'>
<body xmlns='http://www.w3.org/1999/xhtml'>
<p>hello <b>world</b></p>
</body>
</html>
</message>

You can probably leave out the hipchat-specific extension node (xmlns='http://hipchat.com/protocol/muc#room') - that's meant for the HipChat server to send down additional information to the client.

I believe if you follow the examples under https://xmpp.org/extensions/xep-0071.html#examples you should be able to get things to work. I just ran a test using Adium and it was able to send bold/italic text successfully, so it's probably just a matter of trying out a few different things. Unfortunately, it's not something we have docs for or officially support like I mentioned, so I'm not sure what specifically you'd need to change.

Is hipchat also support xhtml inside the room ? It works when it's 1-1 chat, but It doesn't work for me when it is in a room chat.

This example works :

<message from="28219_4606420@chat.hipchat.com/hubot-hipchat" to="28219_4531247@chat.hipchat.com" type="chat">
<inactive xmlns="http://jabber/protocol/chatstates"/>
<body>&lt;p&gt;&lt;p&gt;&amp;lt;pre&amp;gt;test&amp;lt;strong&amp;gt;sdfsfsd&amp;lt;/strong&amp;gt;html&amp;lt;/pre&amp;gt;&lt;/p&gt;&lt;/p&gt;</body>
<html xmlns="http://jabber.org/protocol/xhtml-im">
<body xmlns="http://www.w3.org/1999/xhtml">
<p>
<p>&lt;pre&gt;test&lt;strong&gt;sdfsfsd&lt;/strong&gt;html&lt;/pre&gt;</p>
</p>
</body>
</html>
</message>

 But not this:

<message from="28219_jarvisbot_test@conf.hipchat.com/jarvisbot" to="28219_jarvisbot_test@conf.hipchat.com" type="groupchat">
<body>&lt;p&gt;&lt;p&gt;&amp;lt;pre&amp;gt;test&amp;lt;strong&amp;gt;sdfsfsd&amp;lt;/strong&amp;gt;html&amp;lt;/pre&amp;gt;&lt;/p&gt;&lt;/p&gt;</body>
<html xmlns="http://jabber.org/protocol/xhtml-im">
<body xmlns="http://www.w3.org/1999/xhtml">
<p>
<p>&lt;pre&gt;test&lt;strong&gt;sdfsfsd&lt;/strong&gt;html&lt;/pre&gt;</p>
</p>
</body>
</html>
</message>

I believe we only pass through XHTML bodies in 1-1 chats, although I'm not totally sure what the purpose behind the restriction is. Generally if you want to display custom content in rooms, the best option is using the API or creating an addon. We do have plans to allow more custom formatting of chat messages as well, but it's not yet available as a feature.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published Aug 10, 2018 in Hipchat

What should I think about when migrating HipChat to Slack?

...from the beginning. We have built up a lot of content in HipChat, with it being a core tool in our distributed company model. While it is true that we didn’t need to move to Slack immediately, we felt it...

243 views 1 9
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