I'd like to customize the _format_ for messages that come in through my github webhook integration. Currently, it is possible to customize the _content_ of webhook integrations, using a custom script as described in the documentation.
However, this doesn't give me any control over the layout/format/CSS that gets applied to these messages. For example, to format a Github issue comment notification, I tried the following script:
return {
content: {
attachments: [
{
thumb_url: user.avatar_url,
title: '#' + request.content.issue.number + ' - ' + request.content.issue.title,
title_link: request.content.comment.html_url,
text: request.content.comment.body,
fields: []
}
]
}
};
Note the use of thumb_url
to grab the commentor's avatar and place it in the message. This produces something like:
Note that the title is placed above the thumbnail, rather than aligned to the right above the text. Also, I cannot control the size of the thumbnail. I would like to instead format it to look more like:
It would appear that the DOM for message attachments like this is specified in:
https://github.com/RocketChat/Rocket.Chat/blob/3c919925964f9b5705e30ecbbfc3ae619ba39d27/packages/rocketchat-message-attachments/client/messageAttachment.html
It would be good to have a way to modify this in production.
Your Rocket.Chat version: 0.35.0
in the text property you can include html and inline css if you wish
Hi,
can you explain how to use html in the text property?
"text": '<span>' + request.content.foo + '</span>'
prints just the html and replaces the tags with entities.
I've tested it inside and outside the attachment key.
@geekgonecrazy Is this still the case? I'm unable to get any custom HTML to render when putting it in the text property.
Sorry for posting in a old issue.
I too see HTML rendered as text in attachments.text
.
any resolution for this issue?
Adding html in message API is not working for me as well:
Doing
body = {channel: "aaaaaaaaa", text: "<span>abc</span>"}
spits out <span>abc</span>
instead of just the content.
Any update on this?
I think this is related to some security changes we've made to prevent XSS.
@rodrigok do we intend for that to still work? Or is this no longer supported?
It's no longer supported and we are migrating to use uikit for rich messages.
Most helpful comment
@rodrigok do we intend for that to still work? Or is this no longer supported?